summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/browser_fileUrl.js
blob: 509c143a9bb58d869ac70ba25a222f8e9f00eba5 (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
/**
 * Bug 1663192 - Testing for ensuring the top-level window in a fire url is
 *               treated as first-party.
 */

"use strict";

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

add_task(async function () {
  let dir = getChromeDir(getResolvedURI(gTestPath));
  dir.append("file_localStorage.html");
  const uriString = Services.io.newFileURI(dir).spec;
  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uriString);

  await SpecialPowers.spawn(tab.linkedBrowser, [], function () {
    let result = content.document.getElementById("result");

    is(
      result.textContent,
      "PASS",
      "The localStorage is accessible in top-level window"
    );

    let loadInfo = content.docShell.currentDocumentChannel.loadInfo;

    ok(
      !loadInfo.isThirdPartyContextToTopWindow,
      "The top-level window shouldn't be third-party"
    );
  });

  BrowserTestUtils.removeTab(tab);
});