Do not fire readystatechange events at documents about to get replaced by javascript...
[WebKit-https.git] / LayoutTests / http / tests / dom / ready-state-on-javascript-replace.html
1 <script>
2 if (window.testRunner) {
3     testRunner.dumpAsText();
4     testRunner.waitUntilDone();
5 }
6
7 window.onload = () => {
8     frame = document.createElement('iframe');
9     frame.src = location;
10     document.body.appendChild(frame);
11
12     frame.contentDocument.open();
13     frame.contentDocument.onreadystatechange = () => {
14         alert("Outer handler: " + frame.contentDocument.readyState);
15         frame.contentWindow.addEventListener('readystatechange', () => {
16             alert("Inner handler: " + frame.contentDocument.readyState);
17         }, {capture: true, once: true});
18     }
19     frame.src = 'javascript:"<script>function endIt() { if (window.top.testRunner) window.top.testRunner.notifyDone(); }; setTimeout(endIt, 0);</scr' + 'ipt>"';
20 }
21
22 </script>
23 <body>
24 This test makes sure an iframe whose document is being closed to be replaced by a javascript: url doesn't fire a readystatechange event.<br>
25 You should see no alerts.<br>
26 </body>