Bug 1390433 - (From 1387611)Delay formautofill system add-on updates until the next restart. draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 04 Aug 2017 15:44:34 -0700
changeset 648816 99699094f3645311a807d7bf4170ce8ed08c5351
parent 648815 3069d6214f58f81d7b443f1b6cede2424ffdad1f
child 648817 8847057b92c88f85b25a3adc19faf806c512486c
push id74896
push userschung@mozilla.com
push dateFri, 18 Aug 2017 10:48:05 +0000
bugs1390433, 1387611
milestone56.0
Bug 1390433 - (From 1387611)Delay formautofill system add-on updates until the next restart. MozReview-Commit-ID: 6f4FhTg0KaA
browser/extensions/formautofill/bootstrap.js
--- a/browser/extensions/formautofill/bootstrap.js
+++ b/browser/extensions/formautofill/bootstrap.js
@@ -8,16 +8,17 @@
 
 const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
 const STYLESHEET_URI = "chrome://formautofill/content/formautofill.css";
 const CACHED_STYLESHEETS = new WeakMap();
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "FormAutofillParent",
                                   "resource://formautofill/FormAutofillParent.jsm");
 
 function insertStyleSheet(domWindow, url) {
   let doc = domWindow.document;
   let styleSheetAttr = `href="${url}" type="text/css"`;
   let styleSheet = doc.createProcessingInstruction("xml-stylesheet", styleSheetAttr);
 
@@ -35,22 +36,31 @@ function onMaybeOpenPopup(evt) {
   if (CACHED_STYLESHEETS.has(domWindow)) {
     // This window already has autofill stylesheets.
     return;
   }
 
   insertStyleSheet(domWindow, STYLESHEET_URI);
 }
 
-function startup() {
+function startup(data) {
   if (Services.prefs.getStringPref("extensions.formautofill.available") != "on") {
     Services.prefs.clearUserPref("dom.forms.autocomplete.formautofill");
     return;
   }
 
+  if (data.hasOwnProperty("instanceID") && data.instanceID) {
+    AddonManager.addUpgradeListener(data.instanceID, (upgrade) => {
+      // don't install the upgrade by doing nothing here.
+      // The upgrade will be installed upon next restart.
+    });
+  } else {
+    throw Error("no instanceID passed to bootstrap startup");
+  }
+
   // This pref is used for web contents to detect the autocomplete feature.
   // When it's true, "element.autocomplete" will return tokens we currently
   // support -- otherwise it'll return an empty string.
   Services.prefs.setBoolPref("dom.forms.autocomplete.formautofill", true);
 
   // Listen for the autocomplete popup message to lazily append our stylesheet related to the popup.
   Services.mm.addMessageListener("FormAutoComplete:MaybeOpenPopup", onMaybeOpenPopup);