1
0
Fork 0
firefox/dom/tests/mochitest/whatwg/postMessage_override_helper.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

37 lines
932 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>Overriding postMessage and dispatchEvent bindings</title>
<script type="application/javascript">
window.postMessage = function (evt) {
window.parent.postMessage("FAIL overridden postMessage called", "*");
};
var count = 0;
function receiveMessage(evt) {
count++;
if (count == 2) {
window.dispatchEvent = function(evt) {
window.parent.postMessage("FAIL", "*");
throw "dispatchEvent threw";
};
}
window.parent.postMessage(evt.data, "http://mochi.test:8888");
}
function setup() {
var target = document.getElementById("location");
target.textContent = location.hostname + ":" + (location.port || 80);
}
window.addEventListener("message", receiveMessage);
window.addEventListener("load", setup);
</script>
</head>
<body>
<h1 id="location">No location!</h1>
</body>
</html>