Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / before-unload-in-multiple-subframes.html
blobc6ae7cafbf04724bf5540a0e03139e3961ec463d
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>This tests beforeunload event in multiple subframes. You should see PASS below:</p>
5 <pre id="log"></pre>
6 <script>
8 if (window.testRunner) {
9 testRunner.dumpAsText();
10 testRunner.waitUntilDone();
13 var log = document.getElementById('log');
15 function test(iframe) {
16 if (iframe.done)
17 return;
18 iframe.done = true;
19 iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-child.html';
22 var numberOfBeforeUnloadInSubframes = 0;
23 var numberOfFrames = 3;
25 function logError() {
26 log.innerHTML = 'FAIL: ' + numberOfBeforeUnloadInSubframes + ' beforeunload events are fired but expected ' + numberOfFrames + ' events';
29 logError();
31 function fired(contentWindow) {
32 numberOfBeforeUnloadInSubframes++;
33 if (numberOfBeforeUnloadInSubframes == numberOfFrames) {
34 log.innerHTML = 'PASS';
35 if (window.testRunner)
36 testRunner.notifyDone();
38 else
39 logError();
40 contentWindow.frameElement.fired = true;
43 </script>
44 <iframe onload="test(this)" src="resources/before-unload-in-subframe-child.html"></iframe>
45 <iframe onload="test(this)" src="resources/before-unload-in-subframe-child.html"></iframe>
46 <iframe onload="test(this)" src="resources/before-unload-in-subframe-child.html"></iframe>
47 </body>
48 </html>