docshell/test/browser/browser_bug388121-2.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.

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

mercurial