summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/browser_dataURI_unique_opaque_origin.js
blob: c46012fa82d67e3b567fb6f38ee161e85a557ed7 (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
add_task(async function test_dataURI_unique_opaque_origin() {
  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
  let browser = tab.linkedBrowser;
  await BrowserTestUtils.browserLoaded(browser);

  let pagePrincipal = browser.contentPrincipal;
  info("pagePrincial " + pagePrincipal.origin);

  BrowserTestUtils.loadURIString(browser, "data:text/html,hi");
  await BrowserTestUtils.browserLoaded(browser);

  await SpecialPowers.spawn(
    browser,
    [{ principal: pagePrincipal }],
    async function (args) {
      info("data URI principal: " + content.document.nodePrincipal.origin);
      Assert.ok(
        content.document.nodePrincipal.isNullPrincipal,
        "data: URI should have NullPrincipal."
      );
      Assert.ok(
        !content.document.nodePrincipal.equals(args.principal),
        "data: URI should have unique opaque origin."
      );
    }
  );

  gBrowser.removeTab(tab);
});