Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | function test() { |
michael@0 | 2 | waitForExplicitFinish(); |
michael@0 | 3 | |
michael@0 | 4 | var newTab; |
michael@0 | 5 | var newBrowser; |
michael@0 | 6 | const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager); |
michael@0 | 7 | var iteration = 1; |
michael@0 | 8 | const uris = [undefined, "about:blank"]; |
michael@0 | 9 | var uri; |
michael@0 | 10 | |
michael@0 | 11 | function testLoad(event) { |
michael@0 | 12 | newBrowser.removeEventListener("load", testLoad, true); |
michael@0 | 13 | is (event.target, newBrowser.contentDocument, "Unexpected target"); |
michael@0 | 14 | var prin = newBrowser.contentDocument.nodePrincipal; |
michael@0 | 15 | isnot(prin, null, "Loaded principal must not be null when adding " + uri); |
michael@0 | 16 | isnot(prin, undefined, "Loaded principal must not be undefined when loading " + uri); |
michael@0 | 17 | is(secMan.isSystemPrincipal(prin), false, |
michael@0 | 18 | "Loaded principal must not be system when loading " + uri); |
michael@0 | 19 | gBrowser.removeTab(newTab); |
michael@0 | 20 | |
michael@0 | 21 | if (iteration == uris.length) { |
michael@0 | 22 | finish(); |
michael@0 | 23 | } else { |
michael@0 | 24 | ++iteration; |
michael@0 | 25 | doTest(); |
michael@0 | 26 | } |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function doTest() { |
michael@0 | 30 | uri = uris[iteration - 1]; |
michael@0 | 31 | newTab = gBrowser.addTab(uri); |
michael@0 | 32 | newBrowser = gBrowser.getBrowserForTab(newTab); |
michael@0 | 33 | newBrowser.addEventListener("load", testLoad, true); |
michael@0 | 34 | var prin = newBrowser.contentDocument.nodePrincipal; |
michael@0 | 35 | isnot(prin, null, "Forced principal must not be null when loading " + uri); |
michael@0 | 36 | isnot(prin, undefined, |
michael@0 | 37 | "Forced principal must not be undefined when loading " + uri); |
michael@0 | 38 | is(secMan.isSystemPrincipal(prin), false, |
michael@0 | 39 | "Forced principal must not be system when loading " + uri); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | doTest(); |
michael@0 | 43 | } |
michael@0 | 44 |