Bug 1498827 - Ensure the webcompat report addon is disabled upon load, if extensions.webcompat-reporter.enabled=false, take two r=aswan,mixedpuppy
authorThomas Wisniewski <twisniewski@mozilla.com>
Wed, 17 Oct 2018 15:56:27 +0000
changeset 490147 6191777b6e40eab703c643088e6ad265cf960d32
parent 490146 19b1ad6ceade3ce4ce42e9b4dd793f03e5e81be9
child 490148 7dfafc01cf471ed9985443d9d370ad5a00852ac8
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersaswan, mixedpuppy
bugs1498827
milestone64.0a1
Bug 1498827 - Ensure the webcompat report addon is disabled upon load, if extensions.webcompat-reporter.enabled=false, take two r=aswan,mixedpuppy Ensure the webcompat report addon is disabled upon load, if extensions.webcompat-reporter.enabled=false, take two Differential Revision: https://phabricator.services.mozilla.com/D8678
browser/base/content/test/static/browser_all_files_referenced.js
browser/components/nsBrowserGlue.js
browser/extensions/webcompat-reporter/test/browser/browser.ini
toolkit/mozapps/extensions/internal/XPIDatabase.jsm
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -270,17 +270,24 @@ trackResourcePrefix("formautofill");
 trackChromeUri("chrome://formautofill/content/");
 
 function parseManifest(manifestUri) {
   return fetchFile(manifestUri.spec).then(data => {
     for (let line of data.split("\n")) {
       let [type, ...argv] = line.split(/\s+/);
       if (type == "content" || type == "skin" || type == "locale") {
         let chromeUri = `chrome://${argv[0]}/${type}/`;
-        trackChromeUri(chromeUri);
+        // The webcompat reporter's locale directory may not exist if
+        // the addon is preffed-off, and since it's a hack until we
+        // get bz1425104 landed, we'll just skip it for now.
+        if (chromeUri === "chrome://webcompat-reporter/locale/") {
+          gChromeMap.set("chrome://webcompat-reporter/locale/", true);
+        } else {
+          trackChromeUri(chromeUri);
+        }
       } else if (type == "override" || type == "overlay") {
         // Overlays aren't really overrides, but behave the same in
         // that the overlay is only referenced if the original xul
         // file is referenced somewhere.
         let os = "os=" + Services.appinfo.OS;
         if (!argv.some(s => s.startsWith("os=") && s != os)) {
           gOverrideMap.set(Services.io.newURI(argv[1]).specIgnoringRef,
                            Services.io.newURI(argv[0]).specIgnoringRef);
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1448,27 +1448,25 @@ BrowserGlue.prototype = {
         await addon.enable({allowSystemAddons: true});
       }
     });
   },
 
   _monitorWebcompatReporterPref() {
     const PREF = "extensions.webcompat-reporter.enabled";
     const ID = "webcompat-reporter@mozilla.org";
-    async function checkPref() {
+    Services.prefs.addObserver(PREF, async () => {
       let addon = await AddonManager.getAddonByID(ID);
       let enabled = Services.prefs.getBoolPref(PREF, false);
       if (enabled && !addon.isActive) {
         await addon.enable({allowSystemAddons: true});
       } else if (!enabled && addon.isActive) {
         await addon.disable({allowSystemAddons: true});
       }
-    }
-    Services.prefs.addObserver(PREF, checkPref);
-    checkPref();
+    });
   },
 
   // All initial windows have opened.
   _onWindowsRestored: function BG__onWindowsRestored() {
     if (this._windowsWereRestored) {
       return;
     }
     this._windowsWereRestored = true;
--- a/browser/extensions/webcompat-reporter/test/browser/browser.ini
+++ b/browser/extensions/webcompat-reporter/test/browser/browser.ini
@@ -2,9 +2,8 @@
 support-files =
   head.js
   test.html
   webcompat.html
 
 [browser_disabled_cleanup.js]
 [browser_button_state.js]
 [browser_report_site_issue.js]
-skip-if = !e10s && (os == "linux" && (debug || asan))
--- a/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
@@ -2447,16 +2447,21 @@ this.XPIDatabaseReconcile = {
 
     // Assume that add-ons in the system add-ons install location aren't
     // foreign and should default to enabled.
     aNewAddon.foreignInstall = isDetectedInstall && !aLocation.isSystem;
 
     // appDisabled depends on whether the add-on is a foreignInstall so update
     aNewAddon.appDisabled = !XPIDatabase.isUsableAddon(aNewAddon);
 
+    if (aLocation.isSystem) {
+      const pref = `extensions.${aId.split("@")[0]}.enabled`;
+      aNewAddon.userDisabled = !Services.prefs.getBoolPref(pref, true);
+    }
+
     if (isDetectedInstall && aNewAddon.foreignInstall) {
       // Add the installation source info for the sideloaded extension.
       aNewAddon.installTelemetryInfo = {
         source: aLocation.name,
         method: "sideload",
       };
 
       // If the add-on is a foreign install and is in a scope where add-ons