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",
|
"name": "webkit",
|
||||||
"revision": "1280"
|
"revision": "1286"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import * as network from '../network';
|
|||||||
import { Protocol } from './protocol';
|
import { Protocol } from './protocol';
|
||||||
import { WKSession } from './wkConnection';
|
import { WKSession } from './wkConnection';
|
||||||
|
|
||||||
const errorReasons: { [reason: string]: string } = {
|
const errorReasons: { [reason: string]: Protocol.Network.ResourceErrorType } = {
|
||||||
'aborted': 'Cancellation',
|
'aborted': 'Cancellation',
|
||||||
'accessdenied': 'AccessControl',
|
'accessdenied': 'AccessControl',
|
||||||
'addressunreachable': 'General',
|
'addressunreachable': 'General',
|
||||||
@ -55,12 +55,12 @@ export class WKInterceptableRequest implements network.RouteDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async abort(errorCode: string) {
|
async abort(errorCode: string) {
|
||||||
const reason = errorReasons[errorCode];
|
const errorType = errorReasons[errorCode];
|
||||||
assert(reason, 'Unknown error code: ' + errorCode);
|
assert(errorType, 'Unknown error code: ' + errorCode);
|
||||||
await this._interceptedPromise;
|
await this._interceptedPromise;
|
||||||
// In certain cases, protocol will return error if the request was already canceled
|
// In certain cases, protocol will return error if the request was already canceled
|
||||||
// or the page was closed. We should tolerate these errors.
|
// 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) {
|
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
|
// In certain cases, protocol will return error if the request was already canceled
|
||||||
// or the page was closed. We should tolerate these errors.
|
// 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,
|
requestId: this._requestId,
|
||||||
status: response.status || 200,
|
status: response.status || 200,
|
||||||
statusText: network.STATUS_TEXTS[String(response.status || 200)],
|
statusText: network.STATUS_TEXTS[String(response.status || 200)],
|
||||||
@ -103,7 +103,7 @@ export class WKInterceptableRequest implements network.RouteDelegate {
|
|||||||
await this._interceptedPromise;
|
await this._interceptedPromise;
|
||||||
// In certain cases, protocol will return error if the request was already canceled
|
// In certain cases, protocol will return error if the request was already canceled
|
||||||
// or the page was closed. We should tolerate these errors.
|
// 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,
|
requestId: this._requestId,
|
||||||
method: overrides.method,
|
method: overrides.method,
|
||||||
headers: overrides.headers,
|
headers: overrides.headers,
|
||||||
|
|||||||
@ -154,8 +154,10 @@ export class WKPage implements PageDelegate {
|
|||||||
session.send('Network.enable'),
|
session.send('Network.enable'),
|
||||||
this._workers.initializeSession(session)
|
this._workers.initializeSession(session)
|
||||||
];
|
];
|
||||||
if (this._page._needsRequestInterception())
|
if (this._page._needsRequestInterception()) {
|
||||||
promises.push(session.send('Network.setInterceptionEnabled', { enabled: true, interceptRequests: true }));
|
promises.push(session.send('Network.setInterceptionEnabled', { enabled: true }));
|
||||||
|
promises.push(session.send('Network.addInterception', { url: '.*', stage: 'request', isRegex: true }));
|
||||||
|
}
|
||||||
|
|
||||||
const contextOptions = this._browserContext._options;
|
const contextOptions = this._browserContext._options;
|
||||||
if (contextOptions.userAgent)
|
if (contextOptions.userAgent)
|
||||||
@ -597,7 +599,10 @@ export class WKPage implements PageDelegate {
|
|||||||
|
|
||||||
async updateRequestInterception(): Promise<void> {
|
async updateRequestInterception(): Promise<void> {
|
||||||
const enabled = this._page._needsRequestInterception();
|
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() {
|
async updateOffline() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user