Skip to content

Commit

Permalink
chore: fix BiDi redirects (#10929)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Sep 19, 2023
1 parent 04384ae commit 825dd17
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
7 changes: 2 additions & 5 deletions packages/puppeteer-core/src/bidi/NetworkManager.ts
Expand Up @@ -93,12 +93,10 @@ export class BidiNetworkManager extends EventEmitter<BidiNetworkManagerEvents> {
return;
}
const request = this.#requestMap.get(event.request.request);

let upsertRequest: BidiHTTPRequest;
if (request) {
const requestChain = request._redirectChain;

upsertRequest = new BidiHTTPRequest(event, frame, requestChain);
request._redirectChain.push(request);
upsertRequest = new BidiHTTPRequest(event, frame, request._redirectChain);
} else {
upsertRequest = new BidiHTTPRequest(event, frame, []);
}
Expand All @@ -123,7 +121,6 @@ export class BidiNetworkManager extends EventEmitter<BidiNetworkManagerEvents> {
}
this.emit(NetworkManagerEvent.Response, response);
this.emit(NetworkManagerEvent.RequestFinished, request);
this.#requestMap.delete(event.request.request);
}

#onFetchError(event: Bidi.Network.FetchErrorParameters) {
Expand Down
7 changes: 1 addition & 6 deletions packages/puppeteer-core/src/cdp/HTTPRequest.ts
Expand Up @@ -37,12 +37,7 @@ import {assert} from '../util/assert.js';
* @internal
*/
export class CdpHTTPRequest extends HTTPRequest {
override _requestId: string;
override _interceptionId: string | undefined;
override _failureText: string | null = null;
override _response: HTTPResponse | null = null;
override _fromMemoryCache = false;
override _redirectChain: CdpHTTPRequest[];
declare _redirectChain: CdpHTTPRequest[];

#client: CDPSession;
#isNavigationRequest: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/puppeteer-core/src/cdp/HTTPResponse.ts
Expand Up @@ -57,7 +57,7 @@ export class CdpHTTPResponse extends HTTPResponse {
port: responsePayload.remotePort,
};
this.#statusText =
this.#parseStatusTextFromExtrInfo(extraInfo) ||
this.#parseStatusTextFromExtraInfo(extraInfo) ||
responsePayload.statusText;
this.#url = request.url();
this.#fromDiskCache = !!responsePayload.fromDiskCache;
Expand All @@ -75,7 +75,7 @@ export class CdpHTTPResponse extends HTTPResponse {
this.#timing = responsePayload.timing || null;
}

#parseStatusTextFromExtrInfo(
#parseStatusTextFromExtraInfo(
extraInfo: Protocol.Network.ResponseReceivedExtraInfoEvent | null
): string | undefined {
if (!extraInfo || !extraInfo.headersText) {
Expand Down
6 changes: 0 additions & 6 deletions test/TestExpectations.json
Expand Up @@ -2597,12 +2597,6 @@
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should return last response in redirect chain",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox", "webDriverBiDi"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should return response when page changes its URL after load",
"platforms": ["darwin", "linux", "win32"],
Expand Down

0 comments on commit 825dd17

Please sign in to comment.