Bug 1387611 - Delay formautofill system add-on updates until the next restart. r=lchang
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 04 Aug 2017 15:44:34 -0700
changeset 373164 347ea0d06092d7fcd6c34e2c7ade389b0b71ae31
parent 373163 7f21a31de9faa0ba282c541efdf1017e86a74c69
child 373165 c3910ce15bbbe91658ddf9e43ec5a5d436342070
child 373190 8437bfefc8417d057015e8b4d77b6a5c67360863
push id48127
push usermozilla@noorenberghe.ca
push dateMon, 07 Aug 2017 06:35:53 +0000
treeherderautoland@347ea0d06092 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslchang
bugs1387611
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);