Bug 1396578 Remove startup notification for non-mpc extensions r=rhelmer
authorAndrew Swan <aswan@mozilla.com>
Tue, 05 Sep 2017 07:35:59 -0700
changeset 428429 54c594c4f68c977a7e0d02464409ef405713170c
parent 428428 2adbaf665a26354a7abced57248a05fc4f27d854
child 428430 afca47b3d59b841b248a1db605275e67c1f3b8b9
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1396578
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 1396578 Remove startup notification for non-mpc extensions r=rhelmer MozReview-Commit-ID: 6oSi63pGCqK
browser/components/nsBrowserGlue.js
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/internal/XPIProviderUtils.js
toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -826,40 +826,16 @@ BrowserGlue.prototype = {
       },
     ];
 
     let nb = win.document.getElementById("high-priority-global-notificationbox");
     nb.appendNotification(message, "unsigned-addons-disabled", "",
                           nb.PRIORITY_WARNING_MEDIUM, buttons);
   },
 
-  _notifyDisabledNonMpc() {
-    let win = RecentWindow.getMostRecentBrowserWindow();
-    if (!win)
-      return;
-
-    // This is only going to be on Nightly and only for the 55 and 56
-    // cycles, and it points to a wiki page that is not localized, so
-    // no need to localize the message here...
-    let message = "Due to performance testing, we have disabled some of your add-ons. They can be re-enabled in your browser settings.";
-    let buttons = [
-      {
-        label: "Manage Add-Ons",
-        accessKey: "M",
-        callback() {
-          win.BrowserOpenAddonsMgr("addons://list/extension");
-        }
-      },
-    ];
-
-    let nb = win.document.getElementById("high-priority-global-notificationbox");
-    nb.appendNotification(message, "non-mpc-addons-disabled", "",
-                          nb.PRIORITY_WARNING_MEDIUM, buttons);
-  },
-
   _firstWindowTelemetry(aWindow) {
     let scaling = aWindow.devicePixelRatio * 100;
     try {
       Services.telemetry.getHistogramById("DISPLAY_SCALING").add(scaling);
     } catch (ex) {}
   },
 
   // the first browser window has finished initializing
@@ -1047,20 +1023,16 @@ BrowserGlue.prototype = {
           if (addon.signedState <= AddonManager.SIGNEDSTATE_MISSING) {
             this._notifyUnsignedAddonsDisabled();
             break;
           }
         }
       });
     }
 
-    if (AddonManager.nonMpcDisabled) {
-      this._notifyDisabledNonMpc();
-    }
-
     if (AppConstants.MOZ_CRASHREPORTER) {
       UnsubmittedCrashHandler.init();
     }
 
     this._sanitizer.onStartup();
     E10SAccessibilityCheck.onWindowsRestored();
 
     this._scheduleStartupIdleTasks();
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -613,17 +613,16 @@ var gUpdateEnabled = true;
 var gAutoUpdateDefault = true;
 var gHotfixID = "";
 var gWebExtensionsMinPlatformVersion = "";
 var gShutdownBarrier = null;
 var gRepoShutdownState = "";
 var gShutdownInProgress = false;
 var gPluginPageListener = null;
 var gBrowserUpdated = null;
-var gNonMpcDisabled = false;
 
 /**
  * This is the real manager, kept here rather than in AddonManager to keep its
  * contents hidden from API users.
  */
 var AddonManagerInternal = {
   managerListeners: new Set(),
   installListeners: new Set(),
@@ -3267,20 +3266,16 @@ this.AddonManagerPrivate = {
      if (!extensionId || typeof extensionId != "string")
        throw Components.Exception("extensionId must be a string",
                                   Cr.NS_ERROR_INVALID_ARG);
 
     return AddonManagerInternal._getProviderByName("XPIProvider")
                                .isTemporaryInstallID(extensionId);
   },
 
-  set nonMpcDisabled(val) {
-    gNonMpcDisabled = val;
-  },
-
   isDBLoaded() {
     let provider = AddonManagerInternal._getProviderByName("XPIProvider");
     return provider ? provider.isDBLoaded : false;
   },
 };
 
 /**
  * This is the public API that UI and developers should be calling. All methods
@@ -3791,20 +3786,16 @@ this.AddonManager = {
   getPreferredIconURL(aAddon, aSize, aWindow = undefined) {
     return AddonManagerInternal.getPreferredIconURL(aAddon, aSize, aWindow);
   },
 
   get webAPI() {
     return AddonManagerInternal.webAPI;
   },
 
-  get nonMpcDisabled() {
-    return gNonMpcDisabled;
-  },
-
   get shutdown() {
     return gShutdownBarrier.client;
   },
 };
 
 this.AddonManager.init();
 
 // load the timestamps module into AddonManagerInternal
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
+++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
@@ -27,19 +27,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "DeferredSave",
                                   "resource://gre/modules/DeferredSave.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyServiceGetter(this, "Blocklist",
                                    "@mozilla.org/extensions/blocklist;1",
                                    Ci.nsIBlocklistService);
 
-XPCOMUtils.defineLazyPreferenceGetter(this, "ALLOW_NON_MPC",
-                                      "extensions.allow-non-mpc-extensions");
-
 Cu.import("resource://gre/modules/Log.jsm");
 const LOGGER_ID = "addons.xpi-utils";
 
 const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
                                        "initWithPath");
 
 // Create a new logger for use by the Addons XPI Provider Utils
 // (Requires AddonManager.jsm)
@@ -1523,17 +1520,16 @@ this.XPIDatabaseReconcile = {
               if (xpiState.mtime < oldAddon.updateDate) {
                 XPIProvider.setTelemetry(oldAddon.id, "olderFile", {
                   mtime: xpiState.mtime,
                   oldtime: oldAddon.updateDate
                 });
               }
             }
 
-            let wasDisabled = oldAddon.appDisabled;
             let oldPath = oldAddon.path || descriptorToPath(oldAddon.descriptor);
 
             // The add-on has changed if the modification time has changed, if
             // we have an updated manifest for it, or if the schema version has
             // changed.
             //
             // Also reload the metadata for add-ons in the application directory
             // when the application version has changed.
@@ -1551,28 +1547,16 @@ this.XPIDatabaseReconcile = {
               newAddon = this.updateCompatibility(installLocation, oldAddon, xpiState,
                                                   aOldAppVersion, aOldPlatformVersion,
                                                   aSchemaChange);
             } else {
               // No change
               newAddon = oldAddon;
             }
 
-            // If an extension has just become appDisabled and it appears to
-            // be due to the ALLOW_NON_MPC pref, show a notification.  If the
-            // extension is also disabled for some other reason(s), don't
-            // bother with the notification since flipping the pref will leave
-            // the extension disabled.
-            if (!wasDisabled && newAddon.appDisabled &&
-                !ALLOW_NON_MPC && !newAddon.multiprocessCompatible &&
-                (newAddon.blocklistState != Ci.nsIBlocklistService.STATE_BLOCKED) &&
-                newAddon.isPlatformCompatible && newAddon.isCompatible) {
-              AddonManagerPrivate.nonMpcDisabled = true;
-            }
-
             if (newAddon)
               locationAddonMap.set(newAddon.id, newAddon);
           } else {
             // The add-on is in the DB, but not in xpiState (and thus not on disk).
             this.removeMetadata(oldAddon);
           }
         }
       }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
@@ -1,11 +1,9 @@
 Components.utils.import("resource://testing-common/httpd.js");
-Components.utils.import("resource://gre/modules/osfile.jsm");
-
 var gServer;
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 const NON_MPC_PREF = "extensions.allow-non-mpc-extensions";
 
 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
@@ -191,153 +189,16 @@ add_task(async function test_disable() {
 
   await testOnce(undefined);
   await testOnce(true);
   await testOnce(false);
 
   Services.prefs.clearUserPref(NON_MPC_PREF);
 });
 
-// Test that the nonMpcDisabled flag gets set properly at startup
-// when the allow-non-mpc-extensions pref is flipped.
-add_task(async function test_restart() {
-  const ID = "non-mpc@tests.mozilla.org";
-
-  let xpifile = createTempXPIFile({
-    id: ID,
-    name: "Test Add-on",
-    version: "1.0",
-    bootstrap: true,
-    multiprocessCompatible: false,
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "2"
-    }]
-  });
-
-  Services.prefs.setBoolPref(NON_MPC_PREF, true);
-  let install = await AddonManager.getInstallForFile(xpifile);
-  await promiseCompleteAllInstalls([install]);
-
-  let addon = await AddonManager.getAddonByID(ID);
-  do_check_neq(addon, null);
-  do_check_eq(addon.multiprocessCompatible, false);
-  do_check_eq(addon.appDisabled, false);
-
-  // Simulate a new app version in which the allow-non-mpc-extensions
-  // pref is flipped.
-  await promiseShutdownManager();
-  Services.prefs.setBoolPref(NON_MPC_PREF, false);
-  gAppInfo.version = "1.5";
-  await promiseStartupManager();
-
-  addon = await AddonManager.getAddonByID(ID);
-  do_check_neq(addon, null);
-  do_check_eq(addon.appDisabled, true);
-
-  // The flag we use for startup notification should be true
-  do_check_eq(AddonManager.nonMpcDisabled, true);
-
-  addon.uninstall();
-
-  Services.prefs.clearUserPref(NON_MPC_PREF);
-  AddonManagerPrivate.nonMpcDisabled = false;
-});
-
-// Test that the nonMpcDisabled flag is not set if there are non-mpc
-// extensions that are also disabled for some other reason.
-add_task(async function test_restart2() {
-  const ID1 = "blocked@tests.mozilla.org";
-  let xpi1 = createTempXPIFile({
-    id: ID1,
-    name: "Blocked Add-on",
-    version: "1.0",
-    bootstrap: true,
-    multiprocessCompatible: false,
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "2"
-    }]
-  });
-
-  const ID2 = "incompatible@tests.mozilla.org";
-  let xpi2 = createTempXPIFile({
-    id: ID2,
-    name: "Incompatible Add-on",
-    version: "1.0",
-    bootstrap: true,
-    multiprocessCompatible: false,
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "1.5"
-    }]
-  });
-
-  const BLOCKLIST = `<?xml version="1.0"?>
-  <blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1396046918000">
-  <emItems>
-  <emItem  blockID="i454" id="${ID1}">
-  <versionRange  minVersion="0" maxVersion="*" severity="3"/>
-  </emItem>
-  </emItems>
-  </blocklist>`;
-
-
-  Services.prefs.setBoolPref(NON_MPC_PREF, true);
-  let install1 = await AddonManager.getInstallForFile(xpi1);
-  let install2 = await AddonManager.getInstallForFile(xpi2);
-  await promiseCompleteAllInstalls([install1, install2]);
-
-  let [addon1, addon2] = await AddonManager.getAddonsByIDs([ID1, ID2]);
-  do_check_neq(addon1, null);
-  do_check_eq(addon1.multiprocessCompatible, false);
-  do_check_eq(addon1.appDisabled, false);
-  do_check_neq(addon2, null);
-  do_check_eq(addon2.multiprocessCompatible, false);
-  do_check_eq(addon2.appDisabled, false);
-
-  await promiseShutdownManager();
-
-  Services.prefs.setBoolPref(NON_MPC_PREF, false);
-  gAppInfo.version = "2";
-
-  // Simulate including a new blocklist with the new version by
-  // flipping the pref below which causes the blocklist to be re-read.
-  let blocklistPath = OS.Path.join(OS.Constants.Path.profileDir, "blocklist.xml");
-  await OS.File.writeAtomic(blocklistPath, BLOCKLIST);
-  let BLOCKLIST_PREF = "extensions.blocklist.enabled";
-  Services.prefs.setBoolPref(BLOCKLIST_PREF, false);
-  Services.prefs.setBoolPref(BLOCKLIST_PREF, true);
-
-  await promiseStartupManager();
-
-  // When we restart, one of the test addons should be blocklisted, and
-  // one is incompatible.  Both are MPC=false but that should not trigger
-  // the startup notification since flipping allow-non-mpc-extensions
-  // won't re-enable either extension.
-  const {STATE_BLOCKED} = Components.interfaces.nsIBlocklistService;
-  [addon1, addon2] = await AddonManager.getAddonsByIDs([ID1, ID2]);
-  do_check_neq(addon1, null);
-  do_check_eq(addon1.appDisabled, true);
-  do_check_eq(addon1.blocklistState, STATE_BLOCKED);
-  do_check_neq(addon2, null);
-  do_check_eq(addon2.appDisabled, true);
-  do_check_eq(addon2.isCompatible, false);
-
-  do_check_eq(AddonManager.nonMpcDisabled, false);
-
-  addon1.uninstall();
-  addon2.uninstall();
-
-  Services.prefs.clearUserPref(NON_MPC_PREF);
-});
-
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
   startupManager();
 
   // Create and configure the HTTP server.
   gServer = new HttpServer();
   gServer.registerDirectory("/data/", gTmpD);
   gServer.start(-1);