Open Bug 1809622 Opened 3 years ago Updated 4 hours ago

document referrer is always empty if page is served from SW

Categories

(Core :: DOM: Service Workers, defect, P3)

Firefox 108
defect

Tracking

()

ASSIGNED

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:

  1. Open https://17ggvi.csb.app/foo/index.html page
  2. Reload page in order to activate SW (ServiceWorker)
  3. Click to "5. away" link
  4. Click to "1. foo" link
  5. 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

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.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → DOM: Service Workers

Thank you for providing a reproduction! Notes for future investigation to start from:

if (aInit.IsAnyMemberPresent()) {
  request->SetReferrer(
      NS_LITERAL_STRING_FROM_CSTRING(kFETCH_CLIENT_REFERRER_STR));
  request->SetReferrerPolicy(ReferrerPolicy::_empty);
}
Severity: -- → S3
Priority: -- → P3
See Also: → 1626192, 1628363, 1626616
Status: UNCONFIRMED → NEW
Ever confirmed: true

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.

Flags: needinfo?(smaug)
Flags: needinfo?(smaug) → needinfo?(bugmail)
Flags: needinfo?(bugmail)
Duplicate of this bug: 1626192
Blocks: 1973047

Hi Eden, please take this, thank you!

Flags: needinfo?(echuang)
User Story: (updated)

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.

Assignee: nobody → echuang
Attachment #9507853 - Attachment description: WIP: Bug 1809622 - Propagating the referrerInfo back to child channel if the redirection is caused by ServiceWorker interception. → Bug 1809622 - Propagating the referrerInfo back to child channel if the redirection is caused by ServiceWorker interception. r=#dom-worker-reviewers
Status: NEW → ASSIGNED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: