Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /webmessaging/postMessage-to-target-not-fully-active-on-reload.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>postMessage() to a target window that is no longer fully active on reload</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/web-messaging.html#dom-window-postmessage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
'use strict';
async_test(t => {
// This field is set by grandchild, if postMessage task ultimately ran.
window.postMessageTaskRan = false;
const subParent = document.createElement('iframe');
subParent.src = 'support/postMessage-reload-parent.html';
let loadCount = 0;
subParent.addEventListener('load', t.step_func(() => {
loadCount++;
if (loadCount === 1) {
subParent.contentWindow.location.reload();
} else {
// Give us some time to stabilize by ping-ponging message with child. It responds
// and then we run final assertions in message handler.
subParent.contentWindow.postMessage("reloaded");
}
}));
window.addEventListener("message", t.step_func_done((msg) => {
assert_false(window.postMessageTaskRan,
'The message posted to the no-longer-fully-active child must not be ' +
'delivered.');
}));
document.body.appendChild(subParent);
}, 'postMessage() to a target whose document is no longer fully active (after ' +
'a reload) is not delivered');
</script>
</body>
</html>