Skip to content

Test that location.reload() reuses the original referrer - #65536

Open
dbContext wants to merge 2 commits into
web-platform-tests:masterfrom
dbContext:location-reload-referrer
Open

dbContext wants to merge 2 commits into
web-platform-tests:masterfrom
dbContext:location-reload-referrer

Conversation

@dbContext

@dbContext dbContext commented Nov 20, 2026 •

Copy link
Copy Markdown

After an A -> B navigation, location.reload() on B should reuse the referrer stored in B's document state by that navigation, not compute a new one from B's own URL.

Spec: reload reuses the document state's request referrer (whatwg/html#6315).

Why a new test

html/browsers/browsing-the-web/history-traversal/document-state.https.html has a location.reload() case that checks the referrer, but it asserts Sec-Fetch-Site first. Engines that fail that assertion never report the referrer result, so the referrer behaviour isn't visible on wpt.fyi for them. This test checks the referrer only.

Coverage

html/browsers/history/the-location-interface/location_reload-referrer.https.html, four subtests:

Navigation Checks
cross-site (HTTPS_NOTSAMESITE_ORIGIN) Referer request header
cross-site document.referrer
same-origin Referer request header
same-origin document.referrer

It uses RemoteContextHelper, the same harness as document-state.https.html. Each subtest asserts the referrer on the original A -> B navigation as a precondition before reloading, so a failure points at the reload rather than the setup.

It uses a long timeout because it opens and reloads a window for each scenario, which took about 12s on Firefox Nightly in CI.

Results

From this PR's CI runs:

Browser Result
Firefox Nightly 163 4/4 PASS
Chrome Dev 160 4/4 FAIL
Safari Technology Preview 257 4/4 FAIL

In Chrome and Safari the preconditions pass, and the reload reports B's own URL as the referrer.

./wpt lint is clean.

Related bugs

The reload case in document-state.https.html asserts Sec-Fetch-Site before the referrer, so engines failing that check never report the referrer result. This adds referrer-only coverage for cross-site and same-origin navigations, checking both the Referer header and document.referrer.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants