chromium/third_party/blink/web_tests/wpt_internal/prerender/resources/unload-on-prerender-same-origin-subframe-navigation.html

<!DOCTYPE html>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/speculation-rules/prerender/resources/utils.js"></script>
<script src="unload-utils.js"></script>

<body>
  <script type="module">
    const params = new URLSearchParams(location.search);
    const state = params.get('state') || 'start';
    const uid = params.get('uid');

    // Test steps:
    //   1. `start` page starts prerendering `prerendering` page.
    //   2. `prerendering` page adds `same-origin-frame1`.
    //   3. `same-origin-frame1` navigates to `same-origin-frame2`.
    //   4. `pagehide` and `unload` events are handled.
    sendChannelMessage('load ' + state, uid);
    if (state === 'start') {
      startPrerendering(createTestUrl('prerendering', uid));
    } else if (state === 'prerendering') {
      addFrame(createTestUrl('same-origin-frame1', uid));
    } else if (state === 'same-origin-frame1') {
      // unload handler should be triggered after the frame navigation.
      const eventPromise = addEventListeners('same-origin-frame1', uid);

      // Run a same-origin navigation.
      document.location = createTestUrl('same-origin-frame2', uid);

      // Wait for events fired during activation (e.g., unload).
      await eventPromise;
    } else if (state === 'same-origin-frame2') {
      window.close();
    }

  </script>
</body>