Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | function test() { |
michael@0 | 2 | waitForExplicitFinish(); |
michael@0 | 3 | |
michael@0 | 4 | var w; |
michael@0 | 5 | const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager); |
michael@0 | 6 | var iteration = 1; |
michael@0 | 7 | const uris = ["", "about:blank"]; |
michael@0 | 8 | var uri; |
michael@0 | 9 | var origDoc; |
michael@0 | 10 | |
michael@0 | 11 | function testLoad() { |
michael@0 | 12 | if (w.document == origDoc) { |
michael@0 | 13 | // Go back to polling |
michael@0 | 14 | setTimeout(testLoad, 10); |
michael@0 | 15 | return; |
michael@0 | 16 | } |
michael@0 | 17 | var prin = w.document.nodePrincipal; |
michael@0 | 18 | isnot(prin, null, "Loaded principal must not be null when adding " + uri); |
michael@0 | 19 | isnot(prin, undefined, "Loaded principal must not be undefined when loading " + uri); |
michael@0 | 20 | is(secMan.isSystemPrincipal(prin), false, |
michael@0 | 21 | "Loaded principal must not be system when loading " + uri); |
michael@0 | 22 | w.close(); |
michael@0 | 23 | |
michael@0 | 24 | if (iteration == uris.length) { |
michael@0 | 25 | finish(); |
michael@0 | 26 | } else { |
michael@0 | 27 | ++iteration; |
michael@0 | 28 | doTest(); |
michael@0 | 29 | } |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function doTest() { |
michael@0 | 33 | uri = uris[iteration - 1]; |
michael@0 | 34 | w = window.open(uri, "_blank", "width=10,height=10"); |
michael@0 | 35 | var prin = w.document.nodePrincipal; |
michael@0 | 36 | if (!uri) { |
michael@0 | 37 | uri = undefined; |
michael@0 | 38 | } |
michael@0 | 39 | isnot(prin, null, "Forced principal must not be null when loading " + uri); |
michael@0 | 40 | isnot(prin, undefined, |
michael@0 | 41 | "Forced principal must not be undefined when loading " + uri); |
michael@0 | 42 | is(secMan.isSystemPrincipal(prin), false, |
michael@0 | 43 | "Forced principal must not be system when loading " + uri); |
michael@0 | 44 | if (uri == undefined) { |
michael@0 | 45 | // No actual load here, so just move along. |
michael@0 | 46 | w.close(); |
michael@0 | 47 | ++iteration; |
michael@0 | 48 | doTest(); |
michael@0 | 49 | } else { |
michael@0 | 50 | origDoc = w.document; |
michael@0 | 51 | // Need to poll, because load listeners on the content window won't |
michael@0 | 52 | // survive the load. |
michael@0 | 53 | setTimeout(testLoad, 10); |
michael@0 | 54 | } |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | doTest(); |
michael@0 | 58 | } |