|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=353334 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 353334</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 <script>var x = "PASS"</script> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=353334">Mozilla Bug 353334</a> |
|
14 <p id="display"> |
|
15 <iframe id="one"></iframe> |
|
16 <object id="two" data="about:blank"></object> |
|
17 <iframe id="three" src="data:text/html,<body>test</body>"></iframe> |
|
18 <object id="four" data="data:text/html,<body>test</body>"></object> |
|
19 <iframe id="five" src="javascript:parent.x"></iframe> |
|
20 <object id="six" data="javascript:x"></object> |
|
21 </p> |
|
22 <div id="content" style="display: none"> |
|
23 |
|
24 </div> |
|
25 <pre id="test"> |
|
26 <script class="testbody" type="text/javascript"> |
|
27 |
|
28 /** Test for Bug 353334 **/ |
|
29 SimpleTest.waitForExplicitFinish(); |
|
30 |
|
31 function doPrincipalTest(id) { |
|
32 var doc = SpecialPowers.wrap($(id).contentDocument); |
|
33 |
|
34 isnot(doc.nodePrincipal, undefined, "Should have a principal"); |
|
35 isnot(doc.nodePrincipal, null, "Should have a non-null principal"); |
|
36 is(doc.nodePrincipal.origin, SpecialPowers.wrap(document).nodePrincipal.origin, |
|
37 "Wrong principal for document in node with id='" + id + "'"); |
|
38 } |
|
39 |
|
40 function doContentTest(id) { |
|
41 is($(id).contentDocument.documentElement.textContent, "PASS", |
|
42 "Script executed in wrong context in node with id='" + id + "'"); |
|
43 } |
|
44 |
|
45 function checkPrincipal() { |
|
46 ok(SpecialPowers.call_Instanceof(SpecialPowers.wrap(document).nodePrincipal, SpecialPowers.Ci.nsIPrincipal), |
|
47 "Should be a principal"); |
|
48 } |
|
49 |
|
50 addLoadEvent(function() { |
|
51 checkPrincipal(); |
|
52 |
|
53 for (var i of [ "one", "two", "three", "four" ]) { |
|
54 doPrincipalTest(i); |
|
55 } |
|
56 |
|
57 for (i of [ "five", "six" ]) { |
|
58 doContentTest(i); |
|
59 } |
|
60 |
|
61 SimpleTest.finish(); |
|
62 }); |
|
63 </script> |
|
64 </pre> |
|
65 </body> |
|
66 </html> |
|
67 |