Skip to content

Commit

Permalink
feat(chromium)!: roll to Chromium 97.0.4692.0 (r938248)
Browse files Browse the repository at this point in the history
Issues: #7458
  • Loading branch information
OrKoN committed Nov 23, 2021
1 parent 4c3caaa commit ac162c5
Show file tree
Hide file tree
Showing 13 changed files with 794 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -59,7 +59,7 @@
"license": "Apache-2.0",
"dependencies": {
"debug": "4.3.2",
"devtools-protocol": "0.0.901419",
"devtools-protocol": "0.0.937139",
"extract-zip": "2.0.1",
"https-proxy-agent": "5.0.0",
"node-fetch": "2.6.5",
Expand Down
4 changes: 2 additions & 2 deletions src/common/FrameManager.ts
Expand Up @@ -199,7 +199,7 @@ export class FrameManager extends EventEmitter {
}
watcher.dispose();
if (error) throw error;
return watcher.navigationResponse();
return await watcher.navigationResponse();

async function navigate(
client: CDPSession,
Expand Down Expand Up @@ -243,7 +243,7 @@ export class FrameManager extends EventEmitter {
]);
watcher.dispose();
if (error) throw error;
return watcher.navigationResponse();
return await watcher.navigationResponse();
}

private async _onAttachedToTarget(
Expand Down
11 changes: 10 additions & 1 deletion src/common/HTTPRequest.ts
Expand Up @@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CDPSession } from './Connection.js';
import { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';

import { EventEmitter } from './EventEmitter.js';
import { Frame } from './FrameManager.js';
import { HTTPResponse } from './HTTPResponse.js';
import { assert } from './assert.js';
Expand Down Expand Up @@ -56,6 +58,13 @@ export interface ResponseForRequest {
*/
export type ResourceType = Lowercase<Protocol.Network.ResourceType>;

interface CDPSession extends EventEmitter {
send<T extends keyof ProtocolMapping.Commands>(
method: T,
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']>;
}

/**
*
* Represents an HTTP request sent by a page.
Expand Down
24 changes: 19 additions & 5 deletions src/common/HTTPResponse.ts
Expand Up @@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CDPSession } from './Connection.js';
import { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';

import { EventEmitter } from './EventEmitter.js';
import { Frame } from './FrameManager.js';
import { HTTPRequest } from './HTTPRequest.js';
import { SecurityDetails } from './SecurityDetails.js';
Expand All @@ -28,6 +30,13 @@ export interface RemoteAddress {
port: number;
}

interface CDPSession extends EventEmitter {
send<T extends keyof ProtocolMapping.Commands>(
method: T,
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']>;
}

/**
* The HTTPResponse class represents responses which are received by the
* {@link Page} class.
Expand Down Expand Up @@ -55,7 +64,8 @@ export class HTTPResponse {
constructor(
client: CDPSession,
request: HTTPRequest,
responsePayload: Protocol.Network.Response
responsePayload: Protocol.Network.Response,
extraInfo: Protocol.Network.ResponseReceivedExtraInfoEvent | null
) {
this._client = client;
this._request = request;
Expand All @@ -68,13 +78,17 @@ export class HTTPResponse {
ip: responsePayload.remoteIPAddress,
port: responsePayload.remotePort,
};
this._status = responsePayload.status;
// TODO extract statusText from extraInfo.headersText instead if present
this._statusText = responsePayload.statusText;
this._url = request.url();
this._fromDiskCache = !!responsePayload.fromDiskCache;
this._fromServiceWorker = !!responsePayload.fromServiceWorker;
for (const key of Object.keys(responsePayload.headers))
this._headers[key.toLowerCase()] = responsePayload.headers[key];

this._status = extraInfo ? extraInfo.statusCode : responsePayload.status;
const headers = extraInfo ? extraInfo.headers : responsePayload.headers;
for (const key of Object.keys(headers))
this._headers[key.toLowerCase()] = headers[key];

this._securityDetails = responsePayload.securityDetails
? new SecurityDetails(responsePayload.securityDetails)
: null;
Expand Down
3 changes: 2 additions & 1 deletion src/common/LifecycleWatcher.ts
Expand Up @@ -171,7 +171,8 @@ export class LifecycleWatcher {
this._checkLifecycleComplete();
}

navigationResponse(): HTTPResponse | null {
async navigationResponse(): Promise<HTTPResponse | null> {
// We may need to wait for ExtraInfo events before the request is complete.
return this._navigationRequest ? this._navigationRequest.response() : null;
}

Expand Down

0 comments on commit ac162c5

Please sign in to comment.