Blame docshell/test/browser/browser_dataURI_unique_opaque_origin.js

Packit f0b94e
add_task(async function setup() {
Packit f0b94e
  Services.prefs.setBoolPref("security.data_uri.unique_opaque_origin", true);
Packit f0b94e
Packit f0b94e
  registerCleanupFunction(function() {
Packit f0b94e
    Services.prefs.clearUserPref("security.data_uri.unique_opaque_origin");
Packit f0b94e
  });
Packit f0b94e
});
Packit f0b94e
Packit f0b94e
add_task(async function test_dataURI_unique_opaque_origin() {
Packit f0b94e
  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
Packit f0b94e
  let browser = tab.linkedBrowser;
Packit f0b94e
  await BrowserTestUtils.browserLoaded(browser);
Packit f0b94e
Packit f0b94e
  let pagePrincipal = browser.contentPrincipal;
Packit f0b94e
  info("pagePrincial " + pagePrincipal.origin);
Packit f0b94e
Packit f0b94e
  browser.loadURIWithFlags("data:text/html,hi", 0, null, null, null);
Packit f0b94e
  await BrowserTestUtils.browserLoaded(browser);
Packit f0b94e
Packit f0b94e
  await ContentTask.spawn(browser, { principal: pagePrincipal }, async function(args) {
Packit f0b94e
    info("data URI principal: " + content.document.nodePrincipal.origin);
Packit f0b94e
    Assert.ok(content.document.nodePrincipal.isNullPrincipal,
Packit f0b94e
              "data: URI should have NullPrincipal.");
Packit f0b94e
    Assert.ok(!content.document.nodePrincipal.equals(args.principal),
Packit f0b94e
              "data: URI should have unique opaque origin.");
Packit f0b94e
  });
Packit f0b94e
Packit f0b94e
  gBrowser.removeTab(tab);
Packit f0b94e
});