michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let tab = gBrowser.selectedTab = gBrowser.addTab(); michael@0: registerCleanupFunction(function () { michael@0: gBrowser.removeTab(tab); michael@0: }); michael@0: michael@0: let browser = gBrowser.getBrowserForTab(tab); michael@0: michael@0: function loadURL(url, flags, func) { michael@0: browser.addEventListener("load", function loadListener(e) { michael@0: if (browser.currentURI.spec != url) michael@0: return; michael@0: browser.removeEventListener(e.type, loadListener, true); michael@0: func(); michael@0: }, true); michael@0: browser.loadURIWithFlags(url, flags, null, null, null); michael@0: } michael@0: michael@0: // Load a normal http URL michael@0: function testURL(url, func) { michael@0: loadURL("http://example.com/", 0, function () { michael@0: let pagePrincipal = browser.contentPrincipal; michael@0: ok(pagePrincipal, "got principal for http:// page"); michael@0: michael@0: // Now load the URL normally michael@0: loadURL(url, 0, function () { michael@0: ok(browser.contentPrincipal.equals(pagePrincipal), url + " should inherit principal"); michael@0: michael@0: // Now load the URL and disallow inheriting the principal michael@0: let webNav = Components.interfaces.nsIWebNavigation; michael@0: loadURL(url, webNav.LOAD_FLAGS_DISALLOW_INHERIT_OWNER, function () { michael@0: let newPrincipal = browser.contentPrincipal; michael@0: ok(newPrincipal, "got inner principal"); michael@0: ok(!newPrincipal.equals(pagePrincipal), michael@0: url + " should not inherit principal when loaded with DISALLOW_INHERIT_OWNER"); michael@0: michael@0: func(); michael@0: }); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: let urls = [ michael@0: "data:text/html,hi", michael@0: "javascript:1;" michael@0: ]; michael@0: michael@0: function nextTest() { michael@0: let url = urls.shift(); michael@0: if (url) michael@0: testURL(url, nextTest); michael@0: else michael@0: finish(); michael@0: } michael@0: michael@0: nextTest(); michael@0: } michael@0: