document referrer is always empty if page is served from SW
Categories
(Core :: DOM: Service Workers, defect, P3)
Tracking
()
People
(Reporter: version.ru, Assigned: edenchuang, NeedInfo)
References
(Blocks 1 open bug)
Details
(Keywords: webcompat:platform-bug)
User Story
platform-scheduled:2025-09-30
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Steps to reproduce:
- Open https://17ggvi.csb.app/foo/index.html page
- Reload page in order to activate SW (ServiceWorker)
- Click to "5. away" link
- Click to "1. foo" link
- Evaluate "document.referrer" in the developer console. It will be empty.
Navigation request to page should be served via SW, it's important for reproducing this bug.
Actual results:
document.referrer is empty
Expected results:
document.referrer is not empty
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•3 years ago
|
Comment 3•3 years ago
|
||
Thank you for providing a reproduction! Notes for future investigation to start from:
- The ServiceWorker https://17ggvi.csb.app/bar/sw.js is using workbox
- In general it looks like workbox should be performing a pass-through fetch of the form
fetch(request, undefined)
but that was just the first use of fetch I found. - This matters because step 13.1 of the Request constructor will clobber the referrer if init is not empty and our code conforms to this behavior
if (aInit.IsAnyMemberPresent()) {
request->SetReferrer(
NS_LITERAL_STRING_FROM_CSTRING(kFETCH_CLIENT_REFERRER_STR));
request->SetReferrerPolicy(ReferrerPolicy::_empty);
}
Updated•3 years ago
|
Comment 4•2 years ago
|
||
I am writing to follow up on this open bug report as it continues to significantly impact our company’s work. Specifically, one of our customers relies on the document.referrer value to be set when navigating to subpages. However, when requests go through our service worker, this property is always empty, causing issues on our customer’s website.
We would greatly appreciate any assistance in resolving this issue as soon as possible.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 months ago
|
Updated•26 days ago
|
Assignee | ||
Comment 7•4 hours ago
|
||
Currently Firefox performs ServiceWorker interception by channel redirection.
It would cause a new channel for loading in the content process. However, ServiceWorker interception is different from the normal redirection, so the child channel lose the referrerInfo.
This patch tries to restore the content channel's referrerInfo by its coresponding InterceptedHttpChannel in parent.
When a ServiceWorker interception redirection happens, InterceptedHttpChannel's referrerInfo is propagated through RedirectToRealChannelArgs to the content process.
Updated•4 hours ago
|
Description
•