diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /docshell/test/browser/browser_loadDisallowInherit.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'docshell/test/browser/browser_loadDisallowInherit.js')
-rw-r--r-- | docshell/test/browser/browser_loadDisallowInherit.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/docshell/test/browser/browser_loadDisallowInherit.js b/docshell/test/browser/browser_loadDisallowInherit.js new file mode 100644 index 000000000..71789890f --- /dev/null +++ b/docshell/test/browser/browser_loadDisallowInherit.js @@ -0,0 +1,65 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + waitForExplicitFinish(); + + let tab = gBrowser.selectedTab = gBrowser.addTab(); + registerCleanupFunction(function () { + gBrowser.removeTab(tab); + }); + + let browser = gBrowser.getBrowserForTab(tab); + + function loadURL(url, flags, func) { + browser.addEventListener("load", function loadListener(e) { + if (browser.currentURI.spec != url) + return; + browser.removeEventListener(e.type, loadListener, true); + func(); + }, true); + browser.loadURIWithFlags(url, flags, null, null, null); + } + + // Load a normal http URL + function testURL(url, func) { + loadURL("http://example.com/", 0, function () { + let pagePrincipal = browser.contentPrincipal; + ok(pagePrincipal, "got principal for http:// page"); + + // Now load the URL normally + loadURL(url, 0, function () { + ok(browser.contentPrincipal.equals(pagePrincipal), url + " should inherit principal"); + + // Now load the URL and disallow inheriting the principal + let webNav = Components.interfaces.nsIWebNavigation; + loadURL(url, webNav.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL, function () { + let newPrincipal = browser.contentPrincipal; + ok(newPrincipal, "got inner principal"); + ok(!newPrincipal.equals(pagePrincipal), + url + " should not inherit principal when loaded with DISALLOW_INHERIT_OWNER"); + + func(); + }); + }); + }); + } + + let urls = [ + "data:text/html,<body>hi", + // We used to test javascript: here as well, but now that we no longer run + // javascript: in a sandbox, we end up not running it at all in the + // DISALLOW_INHERIT_OWNER case, so never actually do a load for it at all. + ]; + + function nextTest() { + let url = urls.shift(); + if (url) + testURL(url, nextTest); + else + finish(); + } + + nextTest(); +} + |