wpt / html / user-activation / traverse-to-sameorigin.https.html?no-store

Open test on wpt.live | wpt.fyi

Runs: Chrome 160.0.8195.0 (wpt@1ab8957e4, 2026-12-01) | Firefox 163.0a1 (wpt@1ab8957e4, 2026-12-01) | Safari 257 preview (wpt@1ab8957e4, 2026-12-01) | Ladybird 1.0-fe766 (wpt@c2d91acbf, 2026-12-02) | Servo Servo 0.8 (wpt@75c11f957, 2026-12-01) | Blitz af350c0af (wpt@705f393a6, 2026-12-02)

ChromeFirefoxSafariLadybirdServoBlitz
Total1/10/10/10/10/1NOT RUN
SubtestChromeFirefoxSafariLadybirdServoBlitz
User activation propagation across a traversal to a same-origin documentPASSFAILFAILFAILFAIL—

/html/user-activation/traverse-to-sameorigin.https.html

<!DOCTYPE html>
<meta name="variant" content="?store">
<meta name="variant" content="?no-store">
<title>User activation propagation across a traversal to a same-origin document</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#apply-the-history-step">
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="/common/utils.js"></script>
<script src="/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="resources/utils.js"></script>

<body>
  <p>Non-zero-sized body to allow clicks.</p>
</body>

<script>
  'use strict';

  let uuid1 = token();
  let uuid2 = token();

  // The "no-store" variant keeps the first document out of the back/forward
  // cache, so that the traversal back to it has to create a new one. Both
  // variants are worth running: the carry-over has to reach a document that is
  // reactivated as well as one that is populated from scratch.
  const noStore = location.search === "?no-store";
  let opened = executorPath + uuid1 +
               (noStore ? "&pipe=header(Cache-Control,no-store)" : "");
  let navigated_to = executorPath + uuid2;

  promise_test(async test => {
    // Open a new window that we will navigate away from and then traverse back
    // to, observing the document the traversal ends up on.
    let w;
    document.body.onclick = () => {
      w = window.open(opened);
    };

    await test_driver.click(document.body);
    assert_true(!!w, "A window is opened");
    // Close the window at the end of the test, so that a later test in the same
    // session cannot click a window this one left behind.
    test.add_cleanup(() => w && w.close());

    const first = new RemoteContext(uuid1);
    const second = new RemoteContext(uuid2);

    // Check that the new window does not have user activation initially.
    {
      const result = await first.execute_script(getUserActivationStateWhenShown);
      assertUserActivationState(result, false, false, "after window opened");
    }

    // Navigate the window to a second same-origin document.
    await first.execute_script(url => {
      prepareNavigation(() => {
        location.href = url;
      });
    }, [navigated_to]);

    // Check that the second document has nothing carried over.
    {
      const result = await second.execute_script(getUserActivationStateWhenShown);
      assertUserActivationState(result, false, false,
            "after window navigated, with nothing to carry over");
    }

    // Confirm that the second document gets user activation after a click.
    await test_driver.click(w.document.documentElement);
    {
      const result = await second.execute_script(getUserActivationState);
      assertUserActivationState(result, true, true, "after window clicked");
    }

    // Traverse back to the first document.
    await second.execute_script(() => {
      prepareNavigation(() => {
        history.back();
      });
    });

    // Confirm that the first document got the sticky user activation carried
    // over. The two documents are same origin and neither the entry nor its
    // document records anything that blocks the carry-over.
    const result = await first.execute_script(getUserActivationStateWhenShown);

    if (noStore) {
      await assert_not_bfcached(first);
    } else {
      await assert_bfcached(first);
    }

    assertUserActivationState(result, false, true, "after traversing back");
}, "User activation propagation across a traversal to a same-origin document");
</script>