ChannelWrapper does not trace redirects unless a WebRequest listener is present
Categories
(WebExtensions :: Request Handling, task, P3)
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).
Comment 1•3 years ago
|
||
I'm not surprised. CW was originally written primarily as a performance improvement for WebRequest, not as a general channel api for other internals.
Comment 2•3 years ago
|
||
This is not a bug for us, but we should document it for others.
Description
•