blob: 2d641ef9028312ef47426c47e223304cc98c4c40 [file] [log] [blame]
<!DOCTYPE html><!-- webkit-test-runner [ JavaScriptCanOpenWindowsAutomatically=true ] -->
<html>
<body>
<p>This tests opening a new window during beforeunload event. The page load should succeed.</p>
<div id="log">FAIL</div>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var opened;
const frame = document.createElement('iframe');
document.body.appendChild(frame);
frame.contentDocument.open();
frame.contentDocument.write(`<script> window.onbeforeunload = () => top.opened = window.open('resources/message-opener.html'); </` + `script>`);
frame.contentDocument.close();
frame.src = 'about:blank';
window.onmessage = (event) => {
if (event.data == 'load') {
document.getElementById('log').textContent = 'PASS';
endTest();
}
}
function endTest() {
if (opened)
opened.close();
if (window.testRunner)
testRunner.notifyDone();
}
setTimeout(endTest, 1000);
</script>
</body>
</html>