Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test failed 12 times in the preceding 30 days. quicksearch this test
- Manifest: browser/base/content/test/protectionsUI/browser.toml
/* Any copyright is dedicated to the Public Domain.
/* This test checks pages of different URL variants (mostly differing in scheme)
* and verifies that the shield is only shown when content blocking can deal
* with the specific variant. */
const TEST_CASES = [
{
type: "http",
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
hidden: false,
},
{
type: "https",
hidden: false,
},
{
type: "chrome page",
testURL: "chrome://global/skin/in-content/info-pages.css",
hidden: true,
},
{
type: "content-privileged about page",
testURL: "about:robots",
hidden: true,
},
{
type: "non-chrome about page",
testURL: "about:about",
hidden: true,
},
{
type: "chrome about page",
testURL: "about:preferences",
hidden: true,
},
{
type: "file",
testURL: "benignPage.html",
hidden: true,
},
{
type: "certificateError",
hidden: true,
},
{
type: "localhost",
hidden: false,
},
{
type: "data URI",
testURL: "data:text/html,<div>",
hidden: true,
},
{
type: "view-source HTTP",
hidden: true,
},
{
type: "view-source HTTPS",
hidden: true,
},
{
type: "top level sandbox",
testURL:
hidden: false,
},
];
add_task(async function () {
await SpecialPowers.pushPrefEnv({
set: [
// By default, proxies don't apply to 127.0.0.1. We need them to for this test, though:
["network.proxy.allow_hijacking_localhost", true],
],
});
for (let testData of TEST_CASES) {
info(`Testing for ${testData.type}`);
let testURL = testData.testURL;
// Overwrite the url if it is testing the file url.
if (testData.type === "file") {
let dir = getChromeDir(getResolvedURI(gTestPath));
dir.append(testURL);
dir.normalize();
testURL = Services.io.newFileURI(dir).spec;
}
let pageLoaded;
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
() => {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, testURL);
let browser = gBrowser.selectedBrowser;
if (testData.type === "certificateError") {
pageLoaded = BrowserTestUtils.waitForErrorPage(browser);
} else {
pageLoaded = BrowserTestUtils.browserLoaded(browser, true);
}
},
false
);
await pageLoaded;
is(
BrowserTestUtils.isHidden(
gProtectionsHandler._trackingProtectionIconContainer
),
testData.hidden,
"tracking protection icon container is correctly displayed"
);
BrowserTestUtils.removeTab(tab);
}
});