fune/browser/base/content/test/trackingUI/browser_trackingUI_appMenu_toggle.js
Ehsan Akhgari 09d4b61b43 Bug 1501286 - Part 2: Remove support for tracking protection UI from Control Centre r=johannh
Depends on D9519

Differential Revision: https://phabricator.services.mozilla.com/D9520

--HG--
extra : moz-landing-system : lando
2018-10-25 16:52:19 +00:00

43 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const CB_PREF = "browser.contentblocking.enabled";
const TOGGLE_PREF = "browser.contentblocking.global-toggle.enabled";
ChromeUtils.import("resource://testing-common/CustomizableUITestUtils.jsm", this);
// Test that the app menu toggle correctly flips the TP pref in
// normal windows and private windows.
add_task(async function testGlobalToggle() {
await SpecialPowers.pushPrefEnv({set: [
[TOGGLE_PREF, true],
]});
let panelUIButton = await TestUtils.waitForCondition(() => document.getElementById("PanelUI-menu-button"));
info("Opening main menu");
let promiseShown = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown");
panelUIButton.click();
await promiseShown;
info("Opened main menu");
let toggle = document.getElementById("appMenu-tp-toggle");
Services.prefs.setBoolPref(CB_PREF, false);
await TestUtils.waitForCondition(() => toggle.getAttribute("enabled") == "false");
Services.prefs.setBoolPref(CB_PREF, true);
await TestUtils.waitForCondition(() => toggle.getAttribute("enabled") == "true");
toggle.click();
is(Services.prefs.getBoolPref(CB_PREF), false);
toggle.click();
is(Services.prefs.getBoolPref(CB_PREF), true);
Services.prefs.clearUserPref(CB_PREF);
});