Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / before-unload-remove-itself.html
blobeda4e4dc8162cfefa8e1b26180c01a680a4d4018
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>This test ensures a beforeunload event handler can safely remove the frame to which the event is fired. You should see PASS below:</p>
5 <pre id="log"></pre>
6 <script>
8 if (window.testRunner) {
9 testRunner.dumpAsText();
10 testRunner.dumpChildFramesAsText();
11 testRunner.waitUntilDone();
14 var log = document.getElementById('log');
15 var done = false;
17 function test() {
18 if (done) {
19 // log's not having any content implies that load event was dispatched for the second time before beforeunload is dispatched.
20 if (!log.innerHTML.length)
21 log.innerHTML = 'FAIL: beforeunload event was never dispatched.\n';
22 else
23 log.innerHTML = 'FAIL: beforeunload event handler did not remove the frame.\n';
24 if (window.testRunner)
25 testRunner.notifyDone();
26 return;
28 done = true;
29 document.getElementsByTagName('iframe')[0].contentWindow.location.href = 'resources/before-unload-in-subframe-child.html';
32 function fired() {
33 document.body.removeChild(document.body.getElementsByTagName('iframe')[0]);
34 log.innerHTML = 'PASS\n';
35 if (window.testRunner)
36 testRunner.notifyDone();
39 </script>
40 <iframe onload="test()" src="resources/before-unload-in-subframe-child.html"></iframe>
41 </body>
42 </html>