summaryrefslogtreecommitdiffstats
path: root/browser/components/firefoxview/tests/browser/browser_sync_admin_disabled.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/firefoxview/tests/browser/browser_sync_admin_disabled.js')
-rw-r--r--browser/components/firefoxview/tests/browser/browser_sync_admin_disabled.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/browser/components/firefoxview/tests/browser/browser_sync_admin_disabled.js b/browser/components/firefoxview/tests/browser/browser_sync_admin_disabled.js
new file mode 100644
index 0000000000..d2dc76974c
--- /dev/null
+++ b/browser/components/firefoxview/tests/browser/browser_sync_admin_disabled.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var gSandbox;
+
+add_setup(async function () {
+ Services.prefs.lockPref("identity.fxaccounts.enabled");
+
+ registerCleanupFunction(() => {
+ gSandbox?.restore();
+ Services.prefs.clearUserPref("services.sync.lastTabFetch");
+ Services.prefs.unlockPref("identity.fxaccounts.enabled");
+ Services.prefs.clearUserPref("identity.fxaccounts.enabled");
+ // reset internal state so it doesn't affect the next tests
+ TabsSetupFlowManager.resetInternalState();
+ });
+
+ // gSync.init() is called in a requestIdleCallback. Force its initialization.
+ gSync.init();
+});
+
+add_task(async function test_sync_admin_disabled() {
+ const sandbox = (gSandbox = sinon.createSandbox());
+ sandbox.stub(UIState, "get").callsFake(() => {
+ return {
+ status: UIState.STATUS_NOT_CONFIGURED,
+ syncEnabled: false,
+ };
+ });
+ await withFirefoxView({}, async browser => {
+ const { document } = browser.contentWindow;
+
+ Services.obs.notifyObservers(null, UIState.ON_UPDATE);
+ is(
+ Services.prefs.getBoolPref("identity.fxaccounts.enabled"),
+ true,
+ "Expected identity.fxaccounts.enabled pref to be false"
+ );
+
+ is(
+ Services.prefs.prefIsLocked("identity.fxaccounts.enabled"),
+ true,
+ "Expected identity.fxaccounts.enabled pref to be locked"
+ );
+
+ await waitForVisibleSetupStep(browser, {
+ expectedVisible: "#tabpickup-steps-view0",
+ });
+
+ const errorStateHeader = document.querySelector(
+ "#tabpickup-steps-view0-header"
+ );
+
+ await BrowserTestUtils.waitForMutationCondition(
+ errorStateHeader,
+ { childList: true },
+ () => errorStateHeader.textContent.includes("disabled")
+ );
+
+ ok(
+ errorStateHeader
+ .getAttribute("data-l10n-id")
+ .includes("fxa-admin-disabled"),
+ "Correct message should show when fxa is disabled by an admin"
+ );
+ });
+ Services.prefs.unlockPref("identity.fxaccounts.enabled");
+});