Files
firefox/docshell/test/browser/browser_dataURI_unique_opaque_origin.js
T
Yoshi Huang d59f60f0c4 Bug 1384825 : update browser_loadDisallowInherit.js for new data: URI origin model. r=smaug
Configured browser_loadDisallowInherit.js to run with legacy data: URI
behavior, also write a new browser_dataURI_unique_opaque_origin.js for
the new behavior.
2017-08-03 09:35:45 +08:00

30 lines
1.1 KiB
JavaScript

add_task(async function setup() {
Services.prefs.setBoolPref("security.data_uri.unique_opaque_origin", true);
registerCleanupFunction(function() {
Services.prefs.clearUserPref("security.data_uri.unique_opaque_origin");
});
});
add_task(async function test_dataURI_unique_opaque_origin() {
let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
let browser = tab.linkedBrowser;
await BrowserTestUtils.browserLoaded(browser);
let pagePrincipal = browser.contentPrincipal;
info("pagePrincial " + pagePrincipal.origin);
browser.loadURIWithFlags("data:text/html,hi", 0, null, null, null);
await BrowserTestUtils.browserLoaded(browser);
await ContentTask.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);
});