blob: 5dc58ec95fcf4b83b2e4bdf9efc65650684c6f41 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<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>
<pre id="log"></pre>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.dumpChildFramesAsText();
testRunner.waitUntilDone();
}
var log = document.getElementById('log');
var numberOfBeforeUnloadInSubframes = 0;
var numberOfFrames = 3;
function test(iframe) {
if (iframe.done) {
if (numberOfBeforeUnloadInSubframes == numberOfFrames)
testRunner.notifyDone();
return;
}
iframe.done = true;
iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-destination.html';
}
function logError() {
log.innerHTML = 'FAIL: ' + numberOfBeforeUnloadInSubframes + ' beforeunload events are fired but expected ' + numberOfFrames + ' events';
}
logError();
function fired(contentWindow) {
numberOfBeforeUnloadInSubframes++;
if (numberOfBeforeUnloadInSubframes == numberOfFrames)
log.innerHTML = 'PASS 1/2\n';
else
logError();
contentWindow.frameElement.fired = true;
}
</script>
<iframe onload="test(this)" src="resources/before-unload-with-subframes-parent.html"></iframe>
</body>
</html>