summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/browser_aboutblank.js
blob: f80a948771613d72d758c2679e21f592e9dc0518 (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
44
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function test_aboutblankInIframe() {
  await SpecialPowers.pushPrefEnv({
    set: [
      [
        "network.cookie.cookieBehavior",
        BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
      ],
      [
        "network.cookie.cookieBehavior.pbmode",
        BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
      ],
    ],
  });

  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    TEST_TOP_PAGE
  );
  let browser = tab.linkedBrowser;

  await SpecialPowers.spawn(browser, [], async function (obj) {
    let ifr = content.document.createElement("iframe");
    let loading = new content.Promise(resolve => {
      ifr.onload = resolve;
    });
    ifr.src = "about:blank";
    content.document.body.appendChild(ifr);
    await loading;

    await SpecialPowers.spawn(ifr, [], async function (obj) {
      ok(
        content.navigator.cookieEnabled,
        "Cookie should be enabled in about blank"
      );
    });
  });

  BrowserTestUtils.removeTab(tab);
});