mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(webkit): roll WebKit to 1286 - interception (#2601)
This commit is contained in:
parent
dab715b195
commit
277d50e39c
@ -10,7 +10,7 @@
|
||||
},
|
||||
{
|
||||
"name": "webkit",
|
||||
"revision": "1280"
|
||||
"revision": "1286"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import * as network from '../network';
|
||||
import { Protocol } from './protocol';
|
||||
import { WKSession } from './wkConnection';
|
||||
|
||||
const errorReasons: { [reason: string]: string } = {
|
||||
const errorReasons: { [reason: string]: Protocol.Network.ResourceErrorType } = {
|
||||
'aborted': 'Cancellation',
|
||||
'accessdenied': 'AccessControl',
|
||||
'addressunreachable': 'General',
|
||||
@ -55,12 +55,12 @@ export class WKInterceptableRequest implements network.RouteDelegate {
|
||||
}
|
||||
|
||||
async abort(errorCode: string) {
|
||||
const reason = errorReasons[errorCode];
|
||||
assert(reason, 'Unknown error code: ' + errorCode);
|
||||
const errorType = errorReasons[errorCode];
|
||||
assert(errorType, 'Unknown error code: ' + errorCode);
|
||||
await this._interceptedPromise;
|
||||
// In certain cases, protocol will return error if the request was already canceled
|
||||
// or the page was closed. We should tolerate these errors.
|
||||
await this._session.sendMayFail('Network.interceptAsError', { requestId: this._requestId, reason });
|
||||
await this._session.sendMayFail('Network.interceptRequestWithError', { requestId: this._requestId, errorType });
|
||||
}
|
||||
|
||||
async fulfill(response: network.FulfillResponse) {
|
||||
@ -88,7 +88,7 @@ export class WKInterceptableRequest implements network.RouteDelegate {
|
||||
|
||||
// In certain cases, protocol will return error if the request was already canceled
|
||||
// or the page was closed. We should tolerate these errors.
|
||||
await this._session.sendMayFail('Network.interceptWithResponse', {
|
||||
await this._session.sendMayFail('Network.interceptRequestWithResponse', {
|
||||
requestId: this._requestId,
|
||||
status: response.status || 200,
|
||||
statusText: network.STATUS_TEXTS[String(response.status || 200)],
|
||||
@ -103,7 +103,7 @@ export class WKInterceptableRequest implements network.RouteDelegate {
|
||||
await this._interceptedPromise;
|
||||
// In certain cases, protocol will return error if the request was already canceled
|
||||
// or the page was closed. We should tolerate these errors.
|
||||
await this._session.sendMayFail('Network.interceptContinue', {
|
||||
await this._session.sendMayFail('Network.interceptWithRequest', {
|
||||
requestId: this._requestId,
|
||||
method: overrides.method,
|
||||
headers: overrides.headers,
|
||||
|
||||
@ -154,8 +154,10 @@ export class WKPage implements PageDelegate {
|
||||
session.send('Network.enable'),
|
||||
this._workers.initializeSession(session)
|
||||
];
|
||||
if (this._page._needsRequestInterception())
|
||||
promises.push(session.send('Network.setInterceptionEnabled', { enabled: true, interceptRequests: true }));
|
||||
if (this._page._needsRequestInterception()) {
|
||||
promises.push(session.send('Network.setInterceptionEnabled', { enabled: true }));
|
||||
promises.push(session.send('Network.addInterception', { url: '.*', stage: 'request', isRegex: true }));
|
||||
}
|
||||
|
||||
const contextOptions = this._browserContext._options;
|
||||
if (contextOptions.userAgent)
|
||||
@ -597,7 +599,10 @@ export class WKPage implements PageDelegate {
|
||||
|
||||
async updateRequestInterception(): Promise<void> {
|
||||
const enabled = this._page._needsRequestInterception();
|
||||
await this._updateState('Network.setInterceptionEnabled', { enabled, interceptRequests: enabled });
|
||||
await Promise.all([
|
||||
this._updateState('Network.setInterceptionEnabled', { enabled }),
|
||||
this._updateState('Network.addInterception', { url: '.*', stage: 'request', isRegex: true })
|
||||
]);
|
||||
}
|
||||
|
||||
async updateOffline() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user