|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=789713 |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 <title>Test for Bug 789713</title> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=789713">Mozilla Bug 789713</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 <iframe id="ifr"></iframe> |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript"> |
|
20 |
|
21 /** Test for Bug 789713 **/ |
|
22 |
|
23 function go() { |
|
24 var pass = true; |
|
25 var doc = document.getElementById('ifr').contentDocument; |
|
26 |
|
27 // Tree walkers use nsDOMGenericSH, which has a spineless PreCreate. |
|
28 var walker = doc.createTreeWalker(doc.body); |
|
29 pass = pass && (walker.root === doc.body); |
|
30 |
|
31 // Grab a reference to Object.prototype to make sure we test the machinery |
|
32 // with respect to standard prototype remapping. |
|
33 var objProto = ifr.contentWindow.Object.prototype; |
|
34 |
|
35 // First, do the document.domain operation. This shouldn't crash. |
|
36 document.domain = "example.org"; |
|
37 |
|
38 // Now, make sure that we still can't access cross-origin properties despite |
|
39 // the fact that the WN is shared under the hood. |
|
40 try { |
|
41 walker.root; |
|
42 pass = false; |
|
43 } catch (e) { pass = pass && /Permission denied/.exec(e.message); } |
|
44 window.parent.postMessage(pass, '*'); |
|
45 } |
|
46 |
|
47 // We can't set document.domain on mochi.test, because it's forbidden to set |
|
48 // document.domain to a TLD. |
|
49 var ifr = document.getElementById('ifr'); |
|
50 if (window.location.hostname == "mochi.test") { |
|
51 SimpleTest.waitForExplicitFinish(); |
|
52 ifr.src = window.location.toString().replace("mochi.test:8888", "test1.example.org").split('?')[0]; |
|
53 window.onmessage = function(message) { ok(message.data, "Test succeeded and didn't crash"); SimpleTest.finish(); }; |
|
54 } else { |
|
55 ifr.src = "file_empty.html"; |
|
56 ifr.onload = go; |
|
57 } |
|
58 |
|
59 </script> |
|
60 </pre> |
|
61 </body> |
|
62 </html> |