<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Verify that postmessage tasks can be properly tracked.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/task-ids.js"></script>
</head>
<body>
<script>
const generate_promise = (scriptId, channel) => {
return new Promise((resolve, reject) => {
channel.port1.onmessage = () => {
try {
assert_equals(scheduler.taskId, scriptId);
resolve();
} catch(e) {
reject(e);
}
}
});
}
promise_test(t => {
const scriptId = initializeTaskId();
const channel1 = new MessageChannel();
const channel2 = new MessageChannel();
const promise1 = generate_promise(scriptId, channel1);
const promise2 = generate_promise(scriptId, channel2);
channel1.port2.postMessage("hello");
channel2.port2.postMessage("hello");
return Promise.all([promise1, promise2]);
}, "Same document MessagePort postMessage task properly detects its parent.");
</script>
</body>
</html>