blob: c6ae7cafbf04724bf5540a0e03139e3961ec463d [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<p>This tests beforeunload event in multiple subframes. You should see PASS below:</p>
<pre id="log"></pre>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var log = document.getElementById('log');
function test(iframe) {
if (iframe.done)
return;
iframe.done = true;
iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-child.html';
}
var numberOfBeforeUnloadInSubframes = 0;
var numberOfFrames = 3;
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';
if (window.testRunner)
testRunner.notifyDone();
}
else
logError();
contentWindow.frameElement.fired = true;
}
</script>
<iframe onload="test(this)" src="resources/before-unload-in-subframe-child.html"></iframe>
<iframe onload="test(this)" src="resources/before-unload-in-subframe-child.html"></iframe>
<iframe onload="test(this)" src="resources/before-unload-in-subframe-child.html"></iframe>
</body>
</html>