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 421372 63ddd74e45786ff2aa6dd84581463932afe75cf7
parent 421371 105f53375b21d592a65f89f5d661d448f20354c2
child 421373 99d5923bcdbb748cb301519dbf80be5c1726ce9b
push id7664
push usermozilla@noorenberghe.ca
push dateThu, 24 Aug 2017 16:38:56 +0000
treeherdermozilla-beta@33a4e7ead964 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslchang
bugs1387611
milestone56.0
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);