wpt / html / user-activation / navigate-to-crossorigin-redirect.html?same-site

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@13099faa1, 2026-12-02) | Ladybird 1.0-ba2af (wpt@8c85502e4, 2026-12-02) | Servo Servo 0.8 (wpt@75c11f957, 2026-12-01) | Blitz 1b7ee406b (wpt@705f393a6, 2026-12-02)

ChromeFirefoxSafariLadybirdServoBlitz
Total0/11/11/11/11/1NOT RUN
SubtestChromeFirefoxSafariLadybirdServoBlitz
User activation propagation across a cross-origin redirectionFAILPASSPASSPASSPASS—

/html/user-activation/navigate-to-crossorigin-redirect.html

<!DOCTYPE html>
<meta name="variant" content="?same-site">
<meta name="variant" content="?cross-site">
<title>User activation propagation across a cross-origin redirection</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/get-host-info.sub.js"></script>
<script src="/common/utils.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();

  // What the entry records is that a redirect crossed an origin, with no note
  // of whether it also left the site, so the two variants are expected to block
  // the carry-over alike. The "same-site" hop only changes the host label; the
  // "cross-site" one changes the registrable domain as well.
  let origin = get_host_info().HTTP_ORIGIN;
  let remote_origin = location.search === "?cross-site"
        ? get_host_info().HTTP_NOTSAMESITE_ORIGIN
        : get_host_info().HTTP_REMOTE_ORIGIN;
  let clicked_link =
        `${remote_origin}/common/redirect.py?location=` +
        `${origin}/common/dispatcher/remote-executor.html?uuid=${uuid2}`;

  promise_test(async test => {
    // Open a new window that we will navigate away and observe.
    let w;
    document.body.onclick = () => {
      w = window.open(`/common/dispatcher/remote-executor.html?uuid=${uuid1}`);
    };

    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());

    // Give the window a link, to click for the navigation below.
    {
      const context = new RemoteContext(uuid1);
      await context.execute_script(link => {
        let elem = document.createElement("a");
        elem.textContent = "Link to click to navigate the window";
        elem.href = link;

        document.body.appendChild(elem);
      }, [clicked_link]);
    }

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

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

    // Click on the link to navigate away.
    await test_driver.click(w.document.body.lastElementChild);

    // Confirm that the new window does not have user activation.
    {
      const context = new RemoteContext(uuid2);
      const result = await context.execute_script(getUserActivationState);
      assertUserActivationState(result, false, false,
            "after window navigated and redirected");
    }
}, "User activation propagation across a cross-origin redirection");
</script>