<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Verify that setTimeout 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>
promise_test(async t => {
// `initialId` should be propagated through the whole chain.
const initialId = initializeTaskId();
await scheduler.postTask(async () => {
assert_equals(scheduler.taskId, initialId);
await scheduler.postTask(() => {
assert_equals(scheduler.taskId, initialId);
});
assert_equals(scheduler.taskId, initialId);
});
}, "postTask chain.");
promise_test(async () => {
const initialId = initializeTaskId();
await scheduler.postTask(async () => {
assert_equals(scheduler.taskId, initialId,
"initialId is an ancestor of the currentTaskId");
await fetch("/resources/blank.html");
assert_equals(scheduler.taskId, initialId,
"initialId is ancestor of fetch continuation.");
});
}, "Single postTask with multiple internal awaited tasks");
</script>
</body>
</html>