OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <script> | 2 <script> |
3 if (window.testRunner) { | 3 if (window.testRunner) { |
4 testRunner.setCanOpenWindows(); | 4 testRunner.setCanOpenWindows(); |
5 testRunner.dumpAsText(); | 5 testRunner.dumpAsText(); |
6 testRunner.waitUntilDone(); | 6 testRunner.waitUntilDone(); |
7 testRunner.globalFlag = false; | |
8 } | 7 } |
9 | 8 |
10 var w = window.open("http://127.0.0.1:8000/misc/resources/content-iframe.html"); | 9 function maybeStartTest(w) { |
11 w.opener = null; | 10 w.postMessage('start', '*'); |
11 } | |
12 | 12 |
13 function wait_to_start() { | 13 function runTest() { |
14 var child_window_opened; | |
15 | |
16 // polling testRunner.globalFlag or w.document | |
17 if (window.testRunner) { | |
18 child_window_opened = testRunner.globalFlag; | |
19 } else { | |
20 // polling w.document is not very reliable cross browsers, | |
21 // it works in chrome for manual testsing. | |
22 // We might want to change it to using postMessage when it | |
23 // is supported. | |
24 child_window_opened = !w.document; | |
25 } | |
26 | |
27 if (!child_window_opened) { | |
28 setTimeout(wait_to_start, 30); | |
29 return; | |
30 } | |
31 | |
32 var e = document.getElementById('console'); | 14 var e = document.getElementById('console'); |
33 e.innerHTML = w.opener == null ? 'PASS' : 'FAIL'; | 15 e.innerHTML = w.opener == null ? 'PASS' : 'FAIL'; |
34 | 16 |
35 w.close(); | 17 w.close(); |
36 | 18 |
37 if (window.testRunner) | 19 if (window.testRunner) |
38 testRunner.notifyDone(); | 20 testRunner.notifyDone(); |
39 } | 21 } |
40 | 22 |
41 window.onload = wait_to_start; | 23 window.addEventListener('message', runTest); |
42 | 24 var w = window.open('http://127.0.0.1:8000/misc/resources/content-iframe.html'); |
25 w.opener = null; | |
26 w.onload = function() { maybeStartTest(w); }; | |
esprehn
2014/08/21 19:44:07
This looks flakey, just add an onmessage listener
dcheng
2014/08/21 20:18:10
Unfortunately the other window doesn't have a conn
| |
43 </script> | 27 </script> |
44 <body> | 28 <body> |
45 This tests that following code works in Chrome: | 29 This tests that following code works in Chrome: |
46 <pre> | 30 <pre> |
47 var w = window.open(...); | 31 var w = window.open(...); |
48 w.opener = null; | 32 w.opener = null; |
49 </pre> | 33 </pre> |
50 After new page finishes loading, its opener should stay as null. | 34 After new page finishes loading, its opener should stay as null. |
51 | 35 |
52 <p> | 36 <p> |
53 <div id="console">Running ...<div> | 37 <div id="console">Running ...<div> |
54 </body> | 38 </body> |
55 </html> | 39 </html> |
OLD | NEW |