You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenWindow lacks either sourceDocument or userInvolvement argument when running Navigate algorithm #1776
It doesn't pass source document here so it becomes the default value null, nor the user involvement argument which becomes "none". And the step 5 of the navigate algorithm:
There's no document to pass (as this is a service worker function), so it seems the only way to make it happy is to pass the user involvement argument, but not sure "browser UI" fits here because the caller is certainly the script here. Thoughts?
I agree that the two specifications seem to be misaligned.
Specifically, the Navigate algorithm in the HTML specification does not appear to take ServiceWorker.openWindow() into account. It feels like it lacks consideration for navigations initiated by a ServiceWorker.
I believe the HTML specification should be updated to properly handle these ServiceWorker-initiated navigations. user navigation involvement may also need to have the ServiceWorker initiated case instead of using "browser UI".
Where does the navigate algorithm affect the referrer? That was actually the reason to look at this and to me it looks like it never sets referrer. It's a complex algorithm so perhaps I'm just reading it wrong.
if "has transient activation" is for user-initiated, I also think it reasonable to set it false for ServiceWorkers.
I'm not sure I understand this point; openWindow requires transient user activation to be called, so presumably it should be set to true here? Although the spec currently phrases this as any window in the origin having transient user activation, I thought one use case that originally was supposed to be supported by openWindow was opening new windows as a response to a notification click event; I'm not sure how that is supposed to work with how the spec if phrased though. But either way, openWindow is only supposed to be able to be used to open new windows when user-initiated.
Where does the navigate algorithm affect the referrer? That was actually the reason to look at this and to me it looks like it never sets referrer. It's a complex algorithm so perhaps I'm just reading it wrong.
Activity
yoshisatoyanagisawa commentedon Jun 4, 2025
I agree that the two specifications seem to be misaligned.
Specifically, the Navigate algorithm in the HTML specification does not appear to take
ServiceWorker.openWindow()into account. It feels like it lacks consideration for navigations initiated by a ServiceWorker.I believe the HTML specification should be updated to properly handle these ServiceWorker-initiated navigations. user navigation involvement may also need to have the ServiceWorker initiated case instead of using "browser UI".
@domenic @annevk What do you think?
domenic commentedon Jun 5, 2025
Yeah, this is a recent change, and I agree we didn't think there were any other cases where navigation happened without a source document.
Here is an audit of the places that in HTML depend on the assumption no sourceDocument <-> "browser UI":
openWindow("javascript:...")from a service worker? Should we carry over the origin or not?openWindow()? E.g. do we send a referrer header?I think @annevk might have similar considerations for declarative web push?
yoshisatoyanagisawa commentedon Jun 5, 2025
I know Chromium implement
openWindow()as an open new tab.https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/service_worker/service_worker_clients.cc;l=195;drc=4b816ad8489fde220430098454f287d900486e7e
domenic commentedon Jun 5, 2025
Do you have thoughts on the fetch client? I'm not sure how much it affects beyond the referrer, but I am still unsure on that point.
saschanaz commentedon Jun 5, 2025
Where does the navigate algorithm affect the referrer? That was actually the reason to look at this and to me it looks like it never sets referrer. It's a complex algorithm so perhaps I'm just reading it wrong.
mkruisselbrink commentedon Jun 5, 2025
I'm not sure I understand this point; openWindow requires transient user activation to be called, so presumably it should be set to true here? Although the spec currently phrases this as any window in the origin having transient user activation, I thought one use case that originally was supposed to be supported by openWindow was opening new windows as a response to a notification click event; I'm not sure how that is supposed to work with how the spec if phrased though. But either way, openWindow is only supposed to be able to be used to open new windows when user-initiated.
domenic commentedon Jun 6, 2025
Step 12 of create and initialize a
Documentobject sets the referrer from navigationParams's request's referrer.The fetch algorithm is generally responsible for setting a given request's referrer, in https://fetch.spec.whatwg.org/#concept-main-fetch step 9.
The algorithm it uses, https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer, is highly dependent on the fetch client. It seems to crash if the client is null. (Fix PR: w3c/webappsec-referrer-policy#175.)
Thanks, I didn't read enough about openWindow to know that it required user activation.
What the source snapshot params "has transient activation" impacts:
Sec-Fetch-UserI wonder what browsers currently send for
Sec-Fetch-Userwhen doingopenWindow().