browser(firefox): fix proxy auth redirect + resource redirect handling (#10854)

This was breaking a vital invariant in our firefox network code - see
comments.

References #10095
This commit is contained in:
Andrey Lushnikov 2021-12-10 13:11:58 -08:00 коммит произвёл GitHub
Родитель 3c633f58f9
Коммит 2d386ee8e7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 30 добавлений и 6 удалений

Просмотреть файл

@ -1,2 +1,2 @@
1307
Changed: lushnikov@chromium.org Mon Dec 6 15:17:29 PST 2021
1308
Changed: lushnikov@chromium.org Fri Dec 10 02:42:14 PST 2021

Просмотреть файл

@ -104,7 +104,6 @@ class NetworkRequest {
constructor(networkObserver, httpChannel, redirectedFrom) {
this._networkObserver = networkObserver;
this.httpChannel = httpChannel;
this._networkObserver._channelToRequest.set(this.httpChannel, this);
const loadInfo = this.httpChannel.loadInfo;
let browsingContext = loadInfo?.frameBrowsingContext || loadInfo?.browsingContext;
@ -133,6 +132,19 @@ class NetworkRequest {
// use onStopRequest, but that will only happen after the last redirect has finished.
redirectedFrom._sendOnRequestFinished();
}
// In case of proxy auth, we get two requests with the same channel:
// - one is pre-auth
// - second is with auth header.
//
// In this case, we create this NetworkRequest object with a `redirectedFrom`
// object, and they both share the same httpChannel.
//
// Since we want to maintain _channelToRequest map without clashes,
// we must call `_sendOnRequestFinished` **before** we update it with a new object
// here.
if (this._networkObserver._channelToRequest.has(this.httpChannel))
throw new Error(`Internal Error: invariant is broken for _channelToRequest map`);
this._networkObserver._channelToRequest.set(this.httpChannel, this);
this._pageNetwork = redirectedFrom ? redirectedFrom._pageNetwork : networkObserver._findPageNetwork(httpChannel);
this._expectingInterception = false;

Просмотреть файл

@ -1,2 +1,2 @@
1308
Changed: lushnikov@chromium.org Tue Dec 7 11:51:20 PST 2021
1309
Changed: lushnikov@chromium.org Fri Dec 10 02:42:14 PST 2021

Просмотреть файл

@ -104,7 +104,6 @@ class NetworkRequest {
constructor(networkObserver, httpChannel, redirectedFrom) {
this._networkObserver = networkObserver;
this.httpChannel = httpChannel;
this._networkObserver._channelToRequest.set(this.httpChannel, this);
const loadInfo = this.httpChannel.loadInfo;
let browsingContext = loadInfo?.frameBrowsingContext || loadInfo?.browsingContext;
@ -133,6 +132,19 @@ class NetworkRequest {
// use onStopRequest, but that will only happen after the last redirect has finished.
redirectedFrom._sendOnRequestFinished();
}
// In case of proxy auth, we get two requests with the same channel:
// - one is pre-auth
// - second is with auth header.
//
// In this case, we create this NetworkRequest object with a `redirectedFrom`
// object, and they both share the same httpChannel.
//
// Since we want to maintain _channelToRequest map without clashes,
// we must call `_sendOnRequestFinished` **before** we update it with a new object
// here.
if (this._networkObserver._channelToRequest.has(this.httpChannel))
throw new Error(`Internal Error: invariant is broken for _channelToRequest map`);
this._networkObserver._channelToRequest.set(this.httpChannel, this);
this._pageNetwork = redirectedFrom ? redirectedFrom._pageNetwork : networkObserver._findPageNetwork(httpChannel);
this._expectingInterception = false;