Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<meta charset="utf-8">
<title>Resource Timing - initiatorUrl for a resource fetched in a MessagePort message handler for a message from an iframe</title>
<link rel="author" title="Microsoft" href="http://www.microsoft.com/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>
<script src="../../resources/loading-resource-lib.js"></script>
<div id="log"></div>
<script>
const channel = new MessageChannel();
const frame = document.createElement("iframe");
frame.addEventListener("load", () => {
frame.contentWindow.postMessage("port", "*", [channel.port2]);
});
frame.src = "../../resources/iframe-post-message.html";
document.body.appendChild(frame);
const img = document.createElement("img");
document.body.appendChild(img);
const label = "initiator_url_iframe_postmessage";
const resource = "/images/blue.png?" + label;
const expectedInitiatorUrl = getUrl(
"/resource-timing/tentative/initiator-url/iframe-post-message.html");
channel.port1.onmessage = e => {
load_image(label, img);
}
initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl from iframe postMessage()", resource + " timeout");
</script>