blob: 93ade28334608c7c7bb98391d3f7ca3e4c82c9a8 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<p>This test ensures navigation is forbidden while beforeunload event is being fired. You should see PASS 1/2 and PASS 2/2 below:</p>
<pre id="log">FAIL</pre>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.dumpChildFramesAsText();
testRunner.waitUntilDone();
}
var log = document.getElementById('log');
var didFireBeforeUnloadEvent = false;
function test(iframe) {
if (iframe.done) {
if (iframe.halfPassed) {
iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-destination.html';
iframe.halfPassed = false;
}
return;
}
iframe.done = true;
iframe.contentWindow.location.href = 'resources/before-unload-in-subframe-child.html';
}
function navigateByClickingHyperlink(contentWindow, url) {
var link = contentWindow.document.createElement('a');
link.href = url;
link.click();
}
function fired(contentWindow) {
if (didFireBeforeUnloadEvent)
return;
didFireBeforeUnloadEvent = true;
location.href = 'resources/before-unload-in-subframe-fail.html';
contentWindow.location.href = 'resources/before-unload-in-subframe-fail.html';
navigateByClickingHyperlink(contentWindow, 'resources/before-unload-in-subframe-fail.html');
navigateByClickingHyperlink(window, 'resources/before-unload-in-subframe-fail.html');
log.innerHTML = 'PASS 1/2';
contentWindow.frameElement.halfPassed = true;
}
</script>
<iframe onload="test(this);" src="resources/before-unload-in-subframe-child.html"></iframe>
</body>
</html>