docshell/test/browser/browser_bug349769.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 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

mercurial