Open Bug 1626831 Opened 5 years ago Updated 3 years ago

requests intercepted by services workers do not complete the request flow

Categories

(WebExtensions :: Request Handling, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: mixedpuppy, Unassigned)

References

Details

While fixing the stream filter in Bug 1595197, I noticed that after a redirect by a service worker, we no longer receive further events.

Using dom/serviceworkers/test/test_streamfilter.html

Add webrequest listeners for the whole flow. Once you see the onBeforeRedirect event, you'll get another onBeforeRequest event (as expected) but you will not see any response events (e.g. onHeadersReceived, onCompleted)

would you mind to test if this works with "dom.serviceWorkers.parent_intercept" set to true and only broken when it is set to false?

Flags: needinfo?(mixedpuppy)

Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is -- (Backlog,) indicating it has has not been previously triaged, the bug's Severity is being updated to -- (default, untriaged.)

Severity: normal → --
Flags: needinfo?(mixedpuppy)
Summary: requests intercepted by services workers to not complete the request flow → requests intercepted by services workers do not complete the request flow
Severity: -- → S3
Priority: -- → P3
Flags: needinfo?(mixedpuppy)

dom.serviceWorkers.parent_intercept makes no difference. In the existing test you'll note that filter.onerror is not fired for service worker intercepts, which means we do not see the redirect happen. More importantly, we do not see any further events like webRequest.onCompleted. The request becomes invisible to extensions.

Bug 1576769 seems to be the opposite of this issue.

Maybe asuth has a thought on this.

Flags: needinfo?(mixedpuppy) → needinfo?(bugmail)

Essentially, we don't get the response part of the request if a service worker does:

onfetch = e => {
    e.respondWith(new Response(String("hi")));
};

The general synthesized response situation for parent intercept is:

I think I started to understand the stream filter a bit during the previous work Perry was doing, but it's fallen out of my head and I can't find any high level implementation documentation in https://searchfox.org/mozilla-central/source/toolkit/components/extensions/webrequest or linked from there to quickly get context. Presumably the change to use new stream filters on redirect rather than trying to propagate the stream filter forward on redirect is dependent on an observer notification that is never fired for the successor channel that's an InterceptedHttpChannel? (I may be confused about the change too...)

Flags: needinfo?(bugmail)

This doesn't have anything to do with the streamfilter, which may also be a (separate) issue.

This is about the http-on-* notifications that httpChannel issues, nsIHttpActivityObserver (for webRequest.onErrorOccurred) and nsIChannelEventSink (for webRequest.onBeforeRedirect). I think that onBeforeRedirect is working, it's the flow after that which is going to largely be the http-on-examine-* notifications.

There isn't necessarily a one-to-one translation for these, but you can see the setup[1] and handling [2] of the notifications.

[1] https://searchfox.org/mozilla-central/rev/ea7f70dac1c5fd18400f6d2a92679777d4b21492/toolkit/components/extensions/webrequest/WebRequest.jsm#551-595
[2] https://searchfox.org/mozilla-central/rev/ea7f70dac1c5fd18400f6d2a92679777d4b21492/toolkit/components/extensions/webrequest/WebRequest.jsm#631-648

You need to log in before you can comment on or make changes to this bug.