summaryrefslogtreecommitdiffstats
path: root/browser/components/shell/test/browser_doesAppNeedPin.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/shell/test/browser_doesAppNeedPin.js')
-rw-r--r--browser/components/shell/test/browser_doesAppNeedPin.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/browser/components/shell/test/browser_doesAppNeedPin.js b/browser/components/shell/test/browser_doesAppNeedPin.js
new file mode 100644
index 0000000000..1ecb6cc108
--- /dev/null
+++ b/browser/components/shell/test/browser_doesAppNeedPin.js
@@ -0,0 +1,54 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+ ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm",
+ ExperimentFakes: "resource://testing-common/NimbusTestUtils.jsm",
+ NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
+});
+
+registerCleanupFunction(() => {
+ ExperimentAPI._store._deleteForTests("shellService");
+});
+
+let defaultValue;
+add_task(async function default_need() {
+ defaultValue = await ShellService.doesAppNeedPin();
+
+ Assert.ok(defaultValue !== undefined, "Got a default app need pin value");
+});
+
+add_task(async function remote_disable() {
+ if (defaultValue === false) {
+ info("Default pin already false, so nothing to test");
+ return;
+ }
+
+ let doCleanup = await ExperimentFakes.enrollWithRollout({
+ featureId: NimbusFeatures.shellService.featureId,
+ value: { disablePin: true, enabled: true },
+ });
+
+ Assert.equal(
+ await ShellService.doesAppNeedPin(),
+ false,
+ "Pinning disabled via nimbus"
+ );
+
+ await doCleanup();
+});
+
+add_task(async function restore_default() {
+ if (defaultValue === undefined) {
+ info("No default pin value set, so nothing to test");
+ return;
+ }
+
+ ExperimentAPI._store._deleteForTests("shellService");
+
+ Assert.equal(
+ await ShellService.doesAppNeedPin(),
+ defaultValue,
+ "Pinning restored to original"
+ );
+});