fune/browser/base/content/test/trackingUI/browser_trackingUI_open_preferences.js
Johann Hofmann eea47c667c Bug 1470020 - Part 1 - Don't show the "Enable Protection" button when it links to the TP preferences. r=florian
UX found this confusing and unnecessary, after all.

MozReview-Commit-ID: DSBu8Xyo3YO

--HG--
extra : rebase_source : baec57bcb107cd8c6359aeeebc9bf2010116da7c
2018-06-21 02:05:08 +02:00

51 lines
2 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const PREF = "privacy.trackingprotection.enabled";
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
async function waitAndAssertPreferencesShown() {
await BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popuphidden");
await TestUtils.waitForCondition(() => gBrowser.currentURI.spec == "about:preferences#privacy",
"Should open about:preferences.");
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let doc = content.document;
let section = await ContentTaskUtils.waitForCondition(
() => doc.querySelector(".spotlight"), "The spotlight should appear.");
is(section.getAttribute("data-subcategory"), "trackingprotection",
"The trackingprotection section is spotlighted.");
});
BrowserTestUtils.removeTab(gBrowser.selectedTab);
}
add_task(async function setup() {
await UrlClassifierTestUtils.addTestTrackers();
});
// Tests that pressing the preferences icon in the identity popup
// links to about:preferences
add_task(async function testOpenPreferencesFromPrefsButton() {
await BrowserTestUtils.withNewTab("https://example.com", async function() {
let promisePanelOpen = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
gIdentityHandler._identityBox.click();
await promisePanelOpen;
let preferencesButton = document.getElementById("tracking-protection-preferences-button");
ok(!BrowserTestUtils.is_hidden(preferencesButton), "The enable tracking protection button is shown.");
let shown = waitAndAssertPreferencesShown();
preferencesButton.click();
await shown;
});
});
add_task(async function cleanup() {
UrlClassifierTestUtils.cleanupTestTrackers();
});