summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/protectionsUI/browser_protectionsUI_fetch.js
blob: 26b131d4eb2c5e0a727a5b451676d40209ac4fe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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"
      );
    }
  );
});