Bug 1387611 - Delay formautofill system add-on updates until the next restart. r=lchang draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 04 Aug 2017 15:44:34 -0700
changeset 621481 17926e3f4139f1d91bd4e18c369dc0a0441562d6
parent 621476 c541ddcbcac582fb517db3599289e8b012a656f4
child 724686 b382e1e427d5503409daff3b876d7e82cc107888
push id72397
push usermozilla@noorenberghe.ca
push dateFri, 04 Aug 2017 22:46:55 +0000
reviewerslchang
bugs1387611
milestone57.0a1
Bug 1387611 - Delay formautofill system add-on updates until the next restart. r=lchang 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);