blob: c3867a9abbd293c39aa7dfdde76bc6599a536d2c [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 event is fired.");
let dispatchedRecursiveEvent = false;
const otherWindow = document.body.appendChild(document.createElement("iframe")).contentWindow;
otherWindow.addEventListener("foo", (e) => {
passedEvent = e;
shouldBeUndefined("otherWindow.event");
shouldBe("passedEvent", "window.event");
if (!dispatchedRecursiveEvent) {
dispatchedRecursiveEvent = true;
debug("Dispatching recursive error event");
otherWindow.dispatchEvent(new Event("foo"));
passedEvent = e;
shouldBeUndefined("otherWindow.event");
shouldBe("passedEvent", "window.event");
}
});
shouldBeUndefined("otherWindow.event");
shouldBeUndefined("window.event");
debug("Dispatching error event");
otherWindow.dispatchEvent(new Event("foo"));
shouldBeUndefined("otherWindow.event");
shouldBeUndefined("window.event");
</script>
</body>
</html>