chromium/third_party/blink/web_tests/wpt_internal/task-tracking/track-setinterval.html

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Verify that setInterval 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(() => {
  return new Promise(async (resolve, reject) => {
    const initialId = initializeTaskId();
    await new Promise(resolve => setInterval(resolve, 0));
    queueMicrotask(() => {
      try {
        assert_equals(scheduler.taskId, initialId);
        resolve();
      } catch {
        reject("Not an ancestor");
      }
    });
  });
}, "An immediate setInterval microtask is a descendant of the dispatching task");

promise_test(() => {
  return new Promise(async (resolve, reject) => {
    const initialId = initializeTaskId();
    await new Promise(resolve => setInterval(resolve, 100));
    queueMicrotask(() => {
      try {
        assert_equals(scheduler.taskId, initialId);
        resolve();
      } catch {
        reject("Not an ancestor");
      }
    });
  });
}, "A long setInterval microtask is a descendant of the dispatching task");

promise_test(() => {
  return new Promise(async (resolve, reject) => {
    const initialId = initializeTaskId();
    let counter = 0;
    await new Promise(resolve => setInterval(() => {
      ++counter;
      if (counter > 3) {
        resolve();
      }
    }, 100));
    queueMicrotask(() => {
      try {
        assert_equals(scheduler.taskId, initialId);
        resolve();
      } catch {
        reject("Not an ancestor");
      }
    });
  });
}, "A long setInterval that runs multiple times followed by a microtask is a descendant of the dispatching task");

</script>
</body>
</html>