docshell/test/browser/browser_bug388121-2.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:55d1d7b0355e
1 function test() {
2 waitForExplicitFinish();
3
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;
10
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();
23
24 if (iteration == uris.length) {
25 finish();
26 } else {
27 ++iteration;
28 doTest();
29 }
30 }
31
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 }
56
57 doTest();
58 }

mercurial