summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
commitfc61780b35af913801d72086456f493f63197da6 (patch)
treef85891288a7bd988da9f0f15ae64e5c63f00d493 /toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js
parent69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff)
parent50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff)
downloadUXP-fc61780b35af913801d72086456f493f63197da6.tar
UXP-fc61780b35af913801d72086456f493f63197da6.tar.gz
UXP-fc61780b35af913801d72086456f493f63197da6.tar.lz
UXP-fc61780b35af913801d72086456f493f63197da6.tar.xz
UXP-fc61780b35af913801d72086456f493f63197da6.zip
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts: # browser/app/profile/firefox.js # browser/components/preferences/jar.mn
Diffstat (limited to 'toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js')
-rw-r--r--toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js131
1 files changed, 0 insertions, 131 deletions
diff --git a/toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js b/toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js
deleted file mode 100644
index 3dcd83da8..000000000
--- a/toolkit/mozapps/webextensions/test/xpcshell/test_experiment.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-var scope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
-const XPIProvider = scope.XPIProvider;
-const ID = "experiment1@tests.mozilla.org";
-
-var gIsNightly = false;
-
-function run_test() {
- BootstrapMonitor.init();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- startupManager();
-
- gIsNightly = isNightlyChannel();
-
- run_next_test();
-}
-
-add_task(function* test_experiment() {
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseInstallAllFiles([do_get_addon("test_experiment1")]);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- let addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Addon is found.");
-
- Assert.ok(addon.userDisabled, "Experiments are userDisabled by default.");
- Assert.ok(!addon.appDisabled, "Experiments are not appDisabled by compatibility.");
- Assert.equal(addon.isActive, false, "Add-on is not active.");
- Assert.equal(addon.updateURL, null, "No updateURL for experiments.");
- Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
- "Background updates are disabled.");
- Assert.equal(addon.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE,
- "Permissions are minimal.");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
- "Should not be pending enable");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
- "Should not be pending disable");
-
- // Setting applyBackgroundUpdates should not work.
- addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
- Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
- "Setting applyBackgroundUpdates shouldn't do anything.");
-
- let noCompatibleCalled = false;
- let noUpdateCalled = false;
- let finishedCalled = false;
-
- let listener = {
- onNoCompatibilityUpdateAvailable: () => { noCompatibleCalled = true; },
- onNoUpdateAvailable: () => { noUpdateCalled = true; },
- onUpdateFinished: () => { finishedCalled = true; },
- };
-
- addon.findUpdates(listener, "testing", null, null);
- Assert.ok(noCompatibleCalled, "Listener called.");
- Assert.ok(noUpdateCalled, "Listener called.");
- Assert.ok(finishedCalled, "Listener called.");
-});
-
-// Changes to userDisabled should not be persisted to the database.
-add_task(function* test_userDisabledNotPersisted() {
- let addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Add-on is found.");
- Assert.ok(addon.userDisabled, "Add-on is user disabled.");
-
- let promise = promiseAddonEvent("onEnabled");
- addon.userDisabled = false;
- let [addon2] = yield promise;
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- Assert.equal(addon2.id, addon.id, "Changed add-on matches expected.");
- Assert.equal(addon2.userDisabled, false, "Add-on is no longer user disabled.");
- Assert.ok(addon2.isActive, "Add-on is active.");
-
- Assert.ok(ID in XPIProvider.bootstrappedAddons,
- "Experiment add-on listed in XPIProvider bootstrapped list.");
-
- addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Add-on retrieved.");
- Assert.equal(addon.userDisabled, false, "Add-on is still enabled after API retrieve.");
- Assert.ok(addon.isActive, "Add-on is still active.");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
- "Should not be pending enable");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
- "Should not be pending disable");
-
- // Now when we restart the manager the add-on should revert state.
- yield promiseRestartManager();
- let persisted = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons"));
- Assert.ok(!(ID in persisted),
- "Experiment add-on not persisted to bootstrappedAddons.");
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Add-on retrieved.");
- Assert.ok(addon.userDisabled, "Add-on is disabled after restart.");
- Assert.equal(addon.isActive, false, "Add-on is not active after restart.");
- addon.uninstall();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-});
-
-add_task(function* test_checkCompatibility() {
- if (gIsNightly)
- Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
- else
- Services.prefs.setBoolPref("extensions.checkCompatibility.1", false);
-
- yield promiseRestartManager();
-
- yield promiseInstallAllFiles([do_get_addon("test_experiment1")]);
- let addon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- Assert.ok(addon, "Add-on is found.");
- Assert.ok(addon.userDisabled, "Add-on is user disabled.");
- Assert.ok(!addon.appDisabled, "Add-on is not app disabled.");
-});