Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(webkit): roll WebKit to 1286 - interception (#2601)
Pavel Feldman277d50e39cd9
diff --git a/browsers.json b/browsers.jsonindex 8d0d97074b..a3d003911e 100644--- a/browsers.json+++ b/browsers.json@@ -10,7 +10,7 @@},{"name": "webkit",- "revision": "1280"+ "revision": "1286"}]}diff --git a/src/webkit/wkInterceptableRequest.ts b/src/webkit/wkInterceptableRequest.tsindex 98e75984cc..37a727d6b4 100644--- a/src/webkit/wkInterceptableRequest.ts+++ b/src/webkit/wkInterceptableRequest.ts@@ -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,diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.tsindex d656b7344e..16048e0409 100644--- a/src/webkit/wkPage.ts+++ b/src/webkit/wkPage.ts@@ -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() {