blob: b0520ef2fc82da6141e410ce2ed74d68904698ef [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
if (window.testRunner)
testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true);
function test(iframe) {
iframe.contentWindow.location.href = "resources/does-not-exist.html";
}
</script>
</head>
<body>
<iframe id="testIframe" onload="test(this)" src="resources/onclick.html"></iframe>
<script>
description("Tests the returnValue attribute of the BeforeUnloadEvent.");
self.jsTestIsAsync = true;
var testIframe = document.getElementById("testIframe");
var testEvent;
testIframe.contentWindow.onbeforeunload = function(event) {
if (testIframe.done) {
finishJSTest();
return;
}
testIframe.done = true;
testEvent = event;
shouldBe("testEvent.__proto__", "testIframe.contentWindow.BeforeUnloadEvent.prototype");
shouldBeEqualToString("testEvent.returnValue", "");
event.returnValue = "This is beforeunload from the top level frame.";
shouldBeEqualToString("testEvent.returnValue", "This is beforeunload from the top level frame.");
setTimeout(function() {
if (window.testRunner)
testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(false);
testIframe.contentWindow.location.href = "resources/does-not-exist.html";
}, 0);
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>