tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_dataURI_unique_opaque_origin.js (994B)


      1 add_task(async function test_dataURI_unique_opaque_origin() {
      2  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      3  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
      4  let browser = tab.linkedBrowser;
      5  await BrowserTestUtils.browserLoaded(browser);
      6 
      7  let pagePrincipal = browser.contentPrincipal;
      8  info("pagePrincial " + pagePrincipal.origin);
      9 
     10  BrowserTestUtils.startLoadingURIString(browser, "data:text/html,hi");
     11  await BrowserTestUtils.browserLoaded(browser);
     12 
     13  await SpecialPowers.spawn(
     14    browser,
     15    [{ principal: pagePrincipal }],
     16    async function (args) {
     17      info("data URI principal: " + content.document.nodePrincipal.origin);
     18      Assert.ok(
     19        content.document.nodePrincipal.isNullPrincipal,
     20        "data: URI should have NullPrincipal."
     21      );
     22      Assert.ok(
     23        !content.document.nodePrincipal.equals(args.principal),
     24        "data: URI should have unique opaque origin."
     25      );
     26    }
     27  );
     28 
     29  gBrowser.removeTab(tab);
     30 });