blob: a21c6e5e764284f783f5266f80a0ac6f60af4c59 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
description("Tests that an exception is thrown when the value returned in the beforeunload callback cannot be converted to a String");
window.jsTestIsAsync = true;
var testMessage;
var alreadyTested = false;
function test(frame) {
if (alreadyTested)
alreadyTested = true;
frame.contentWindow.onbeforeunload = function(event) {
return {toString: function() { throw "Exception in toString()"; }};
frame.contentWindow.onerror = function(msg) {
testMessage = msg;
testPassed("Exception was thrown");
shouldBeEqualToString("testMessage", "Uncaught Exception in toString()");
return true;
frame.contentWindow.location.href = "resources/does-not-exist.html";
setTimeout(function() {
}, 0);
<iframe onload="test(this)" src="resources/onclick.html"></iframe>