blob: d7a9087a1c2956939bf9e8eda612ab6f0e57d6c6 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description("Tests that window.event is set on the right global when an error event is fired.");
let dispatchedRecursiveEvent = false;
const otherWindow = document.body.appendChild(document.createElement("iframe")).contentWindow;
otherWindow.onerror = (e) => {
passedEvent = e;
shouldBeUndefined("otherWindow.event");
shouldBe("passedEvent", "window.event");
if (!dispatchedRecursiveEvent) {
dispatchedRecursiveEvent = true;
debug("Dispatching recursive error event");
otherWindow.dispatchEvent(new Event("error"));
passedEvent = e;
shouldBeUndefined("otherWindow.event");
shouldBe("passedEvent", "window.event");
}
}
shouldBeUndefined("otherWindow.event");
shouldBeUndefined("window.event");
debug("Dispatching error event");
otherWindow.dispatchEvent(new Event("error"));
shouldBeUndefined("otherWindow.event");
shouldBeUndefined("window.event");
</script>
</body>
</html>