chromium/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue/resources/promise-job-incumbent-incumbent.html

<!DOCTYPE html>
<meta charset="utf-8">
<title>Incumbent page used as a test helper</title>

<iframe src="relevant/relevant.html" id="r"></iframe>
<iframe src="current/current.html" id="c"></iframe>

<script>
  const relevant = document.querySelector("#r");
  const current = document.querySelector("#c");

  window.runWindowPostMessageVeryIndirectly = (...args) => {
    return current.contentWindow.postMessage.call(relevant.contentWindow, ...args);
  };

  // This tests the backup incumbent settings object stack scenario, by avoiding putting user code on the stack.
  window.runWindowPostMessageVeryIndirectlyWithNoUserCode = (promise, promiseMethod, ...args) => {
    const runWindowPostMessage = current.contentWindow.postMessage.bind(relevant.contentWindow, ...args);
    promise[promiseMethod](runWindowPostMessage);
  };

  window.resolveThenableThatRunsWindowPostMessageVeryIndirectlyWithNoUserCode = (...args) => {
    Promise.resolve({
      then: current.contentWindow.postMessage.bind(relevant.contentWindow, ...args)
    });
  };
</script>