4 <p>This test ensures beforeunload event fires in all subframes when a parent frame is navigated. You should see PASS
1/
2 and PASS
2/
2 below:
</p>
8 if (window
.testRunner
) {
9 testRunner
.dumpAsText();
10 testRunner
.dumpChildFramesAsText();
11 testRunner
.waitUntilDone();
14 var log
= document
.getElementById('log');
15 var numberOfBeforeUnloadInSubframes
= 0;
16 var numberOfFrames
= 3;
18 function test(iframe
) {
20 if (numberOfBeforeUnloadInSubframes
== numberOfFrames
)
21 testRunner
.notifyDone();
25 iframe
.contentWindow
.location
.href
= 'resources/before-unload-in-subframe-destination.html';
29 log
.innerHTML
= 'FAIL: ' + numberOfBeforeUnloadInSubframes
+ ' beforeunload events are fired but expected ' + numberOfFrames
+ ' events';
34 function fired(contentWindow
) {
35 numberOfBeforeUnloadInSubframes
++;
36 if (numberOfBeforeUnloadInSubframes
== numberOfFrames
)
37 log
.innerHTML
= 'PASS 1/2\n';
40 contentWindow
.frameElement
.fired
= true;
44 <iframe onload=
"test(this)" src=
"resources/before-unload-with-subframes-parent.html"></iframe>