blob: 7d1f532e6fcaad2abaf02d63ac461d9a7597843f [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<p>This tests navigating a sibling iframe during beforeunload. The navigation should be prevented.</p>
<div id="log"></div>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
const log = document.getElementById('log');
const frame1 = document.createElement('iframe');
document.body.appendChild(frame1);
frame1.contentDocument.open();
frame1.contentDocument.write(`<script> window.onbeforeunload = () => top.startTest() </` + `script>`);
frame1.contentDocument.close();
const frame2 = document.createElement('iframe');
document.body.appendChild(frame2);
window.onmessage = (event) => {
if (event.data == 'load')
log.textContent = 'FAIL - the navigation succeeded';
}
function startTest() {
frame2.src = 'resources/message-top.html';
setTimeout(() => {
if (log.textContent == '')
log.textContent = 'PASS';
if (window.testRunner)
testRunner.notifyDone();
}, 1000);
}
frame1.src = 'about:blank';
</script>
</body>
</html>