Open Bug 1799118 Opened 2 years ago Updated 2 years ago

ChannelWrapper does not trace redirects unless a WebRequest listener is present

Categories

(WebExtensions :: Request Handling, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

Details

ChannelWrapper is not guaranteed to reflect the state of a request after a redirect but the pre-redirect request, because redirect-awareness of ChannelWrapper is handled via the channel.channel assignment in onChannelReplaced, which is called by an asyncOnChannelRedirect handler, which in turn is only registered when any webRequest.onBeforeRedirect listener is present in Firefox.

Presently, there is a built-in extension with such a listener, but we should not be relying on that as it is very brittle. This extension is not present on mobile for example.

I ran into this issue while writing a unit test that confirms that a ChannelWrapper's URL (instantiated at http-on-modify-request) is showing the URL after a redirect. The test was failing because ChannelWrapper.get(httpChannel).finalURL reflected the initial pre-redirect URL.

While webRequest had a similar bug before (bug 1429556), it is not affected because of the fix that sets up the redirect tracking when there is a webRequest listener, at https://hg.mozilla.org/mozilla-central/rev/5c9c6f5a4ca3#l2.30 (bug 1448599).

I'm not surprised. CW was originally written primarily as a performance improvement for WebRequest, not as a general channel api for other internals.

This is not a bug for us, but we should document it for others.

Severity: -- → N/A
Type: defect → task
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.