browser_protectionsUI_fetch.js (1397B)
1 const URL = 2 "http://mochi.test:8888/browser/browser/base/content/test/protectionsUI/file_protectionsUI_fetch.html"; 3 4 add_task(async function test_fetch() { 5 await SpecialPowers.pushPrefEnv({ 6 set: [["privacy.trackingprotection.enabled", true]], 7 }); 8 9 await BrowserTestUtils.withNewTab( 10 { gBrowser, url: URL }, 11 async function (newTabBrowser) { 12 const win = newTabBrowser.ownerGlobal; 13 await openProtectionsPanel(false, win); 14 let contentBlockingEvent = waitForContentBlockingEvent(); 15 await SpecialPowers.spawn(newTabBrowser, [], async function () { 16 await content.wrappedJSObject 17 .test_fetch() 18 .then(() => Assert.ok(false, "should have denied the request")) 19 .catch(e => Assert.ok(true, `Caught exception: ${e}`)); 20 }); 21 await contentBlockingEvent; 22 23 const gProtectionsHandler = win.gProtectionsHandler; 24 ok(gProtectionsHandler, "got CB object"); 25 26 ok( 27 gProtectionsHandler._protectionsPopup.hasAttribute("detected"), 28 "has detected content blocking" 29 ); 30 ok( 31 gProtectionsHandler.iconBox.hasAttribute("active"), 32 "icon box is active" 33 ); 34 is( 35 gProtectionsHandler._trackingProtectionIconTooltipLabel.getAttribute( 36 "data-l10n-id" 37 ), 38 "tracking-protection-icon-active", 39 "correct tooltip" 40 ); 41 } 42 ); 43 });