chromium/third_party/blink/web_tests/wpt_internal/scheduler/post-task-with-detached-callback.html

<!doctype html>
<title>Scheduler: Scheduling a Detached Callback</title>
<link rel="author" title="Scott Haseley" href="mailto:[email protected]">
<link rel="help" href="https://github.com/WICG/scheduling-apis">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
'use strict';

window.didRun = false;

promise_test(async t => {
  await new Promise((resolve) => {
    window.addEventListener('load', resolve);
  });

  const frame = document.createElement('iframe');
  frame.srcdoc = `<script>
    const myParent = window.parent;
    function childCallback() {
      myParent.didRun = true;
    }
    <\/script>`

  await new Promise((resolve) => {
    frame.addEventListener('load', resolve);
    document.body.appendChild(frame);
  })

  scheduler.postTask(frame.contentWindow.childCallback);
  document.body.removeChild(frame);
  await scheduler.postTask(() => {});
  assert_false(didRun, 'The task should not have run.');
}, 'Internal test for testing that scheduling a callback from a detached frame does not run');

</script>