Bug 1549192 Send ADDON_ENABLE startupReason for addons enabled early during browser startup r=kmag
authorAndrew Swan <aswan@mozilla.com>
Thu, 09 May 2019 15:54:06 -0700
changeset 532530 90b6ea6c5c2ac2736134dbbc6d21c6515b13e8a3
parent 532529 0d1fd673085631fce1bad6e3aeeeb4b559c57493
child 532531 46b6ab028e3cb6259bae478a38c4b590384e7d4c
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1549192
milestone68.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 1549192 Send ADDON_ENABLE startupReason for addons enabled early during browser startup r=kmag Differential Revision: https://phabricator.services.mozilla.com/D30603
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_startup_enable.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -2314,16 +2314,19 @@ var XPIProvider = {
           }
           try {
             let reason = BOOTSTRAP_REASONS.APP_STARTUP;
             // Eventually set INSTALLED reason when a bootstrap addon
             // is dropped in profile folder and automatically installed
             if (AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_INSTALLED)
                             .includes(addon.id))
               reason = BOOTSTRAP_REASONS.ADDON_INSTALL;
+            else if (AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_ENABLED)
+                                 .includes(addon.id))
+              reason = BOOTSTRAP_REASONS.ADDON_ENABLE;
             BootstrapScope.get(addon).startup(reason);
           } catch (e) {
             logger.error("Failed to load bootstrap addon " + addon.id + " from " +
                          addon.descriptor, e);
           }
         }
         AddonManagerPrivate.recordTimestamp("XPI_bootstrap_addons_end");
       } catch (e) {
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_startup_enable.js
@@ -0,0 +1,43 @@
+
+
+createAppInfo("xpcshell@tessts.mozilla.org", "XPCShell", "1", "1");
+BootstrapMonitor.init();
+
+// Test that enabling an extension during startup generates the
+// proper reason for startup().
+add_task(async function test_startup_enable() {
+  const ID = "compat@tests.mozilla.org";
+
+  await promiseStartupManager();
+
+  await promiseInstallWebExtension({
+    manifest: {
+      applications: {
+        gecko: {
+          id: ID,
+          strict_min_version: "1",
+          strict_max_version: "1",
+        },
+      },
+    },
+  });
+
+  BootstrapMonitor.checkInstalled(ID);
+  BootstrapMonitor.checkStarted(ID);
+  let {reason} = BootstrapMonitor.started.get(ID);
+  equal(reason, BOOTSTRAP_REASONS.ADDON_INSTALL,
+        "Startup reason is ADDON_INSTALL at install");
+
+  gAppInfo.platformVersion = "2";
+  await promiseRestartManager("2");
+  BootstrapMonitor.checkInstalled(ID);
+  BootstrapMonitor.checkNotStarted(ID);
+
+  gAppInfo.platformVersion = "1";
+  await promiseRestartManager("1");
+  BootstrapMonitor.checkInstalled(ID);
+  BootstrapMonitor.checkStarted(ID);
+  ({reason} = BootstrapMonitor.started.get(ID));
+  equal(reason, BOOTSTRAP_REASONS.ADDON_ENABLE,
+        "Startup reason is ADDON_ENABLE when re-enabled at startup");
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -98,16 +98,17 @@ skip-if = true
 [test_signed_langpack.js]
 [test_signed_long.js]
 [test_signed_updatepref.js]
 skip-if = require_signing || !allow_legacy_extensions
 [test_signed_verify.js]
 [test_startup.js]
 # Bug 676992: test consistently fails on Android
 fail-if = os == "android"
+[test_startup_enable.js]
 [test_strictcompatibility.js]
 head = head_addons.js head_compat.js
 [test_syncGUID.js]
 [test_system_allowed.js]
 head = head_addons.js head_system_addons.js
 [test_system_delay_update.js]
 head = head_addons.js head_system_addons.js
 skip-if = true # Bug 1495021