Commit 54ce4c11 authored by Andrew Swan's avatar Andrew Swan
Browse files

Bug 1396578 Remove startup notification for non-mpc extensions r=rhelmer

MozReview-Commit-ID: 6oSi63pGCqK

--HG--
extra : rebase_source : 9908865d5db0949e72f2324158ebce98e3b2fe75
parent a4afd668
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -831,30 +831,6 @@ BrowserGlue.prototype = {
                          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 {
@@ -1052,10 +1028,6 @@ BrowserGlue.prototype = {
      });
    }

    if (AddonManager.nonMpcDisabled) {
      this._notifyDisabledNonMpc();
    }

    if (AppConstants.MOZ_CRASHREPORTER) {
      UnsubmittedCrashHandler.init();
    }
+0 −9
Original line number Diff line number Diff line
@@ -618,7 +618,6 @@ 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
@@ -3272,10 +3271,6 @@ this.AddonManagerPrivate = {
                               .isTemporaryInstallID(extensionId);
  },

  set nonMpcDisabled(val) {
    gNonMpcDisabled = val;
  },

  isDBLoaded() {
    let provider = AddonManagerInternal._getProviderByName("XPIProvider");
    return provider ? provider.isDBLoaded : false;
@@ -3796,10 +3791,6 @@ this.AddonManager = {
    return AddonManagerInternal.webAPI;
  },

  get nonMpcDisabled() {
    return gNonMpcDisabled;
  },

  get shutdown() {
    return gShutdownBarrier.client;
  },
+0 −16
Original line number Diff line number Diff line
@@ -32,9 +32,6 @@ 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";

@@ -1528,7 +1525,6 @@ this.XPIDatabaseReconcile = {
              }
            }

            let wasDisabled = oldAddon.appDisabled;
            let oldPath = oldAddon.path || descriptorToPath(oldAddon.descriptor);

            // The add-on has changed if the modification time has changed, if
@@ -1556,18 +1552,6 @@ this.XPIDatabaseReconcile = {
              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 {
+0 −139
Original line number Diff line number Diff line
Components.utils.import("resource://testing-common/httpd.js");
Components.utils.import("resource://gre/modules/osfile.jsm");

var gServer;

const profileDir = gProfD.clone();
@@ -196,143 +194,6 @@ add_task(async function test_disable() {
  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();