fune/browser/base/content/test/protectionsUI/browser_protectionsUI_fetch.js
Eemeli Aro 64e437b578 Bug 1760047 - Migrate browser-siteProtections.js to Fluent. r=anti-tracking-reviewers,fluent-reviewers,flod,bvandersloot
The `PanelMultiView.showSubView()` method needed to be made a bit more robust
for titles set by DOM localization rather than directly.

The following messages are dropped during the migration, as they are unused:
- contentBlocking.trackersView.blocked.label
- contentBlocking.cookiesView.firstParty.empty.label
- contentBlocking.cookiesView.trackers.empty.label
- contentBlocking.cookiesView.thirdParty.empty.label
- contentBlocking.fingerprintersView.blocked.label
- contentBlocking.cryptominersView.blocked.label

Differential Revision: https://phabricator.services.mozilla.com/D178829
2023-08-04 15:50:49 +00:00

43 lines
1.4 KiB
JavaScript

const URL =
"http://mochi.test:8888/browser/browser/base/content/test/protectionsUI/file_protectionsUI_fetch.html";
add_task(async function test_fetch() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.trackingprotection.enabled", true]],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: URL },
async function (newTabBrowser) {
const win = newTabBrowser.ownerGlobal;
await openProtectionsPanel(false, win);
let contentBlockingEvent = waitForContentBlockingEvent();
await SpecialPowers.spawn(newTabBrowser, [], async function () {
await content.wrappedJSObject
.test_fetch()
.then(response => Assert.ok(false, "should have denied the request"))
.catch(e => Assert.ok(true, `Caught exception: ${e}`));
});
await contentBlockingEvent;
const gProtectionsHandler = win.gProtectionsHandler;
ok(gProtectionsHandler, "got CB object");
ok(
gProtectionsHandler._protectionsPopup.hasAttribute("detected"),
"has detected content blocking"
);
ok(
gProtectionsHandler.iconBox.hasAttribute("active"),
"icon box is active"
);
is(
gProtectionsHandler._trackingProtectionIconTooltipLabel.getAttribute(
"data-l10n-id"
),
"tracking-protection-icon-active",
"correct tooltip"
);
}
);
});