playwright-core
Advanced tools
Comparing version 0.11.1-next.1583863091474 to 0.11.1-next.1583871165271
@@ -36,3 +36,3 @@ /** | ||
constructor(client: CRSession, page: Page); | ||
instrumentNetworkEvents(session: CRSession): RegisteredListener[]; | ||
instrumentNetworkEvents(session: CRSession, workerFrame?: frames.Frame): RegisteredListener[]; | ||
initialize(): Promise<void>; | ||
@@ -44,6 +44,6 @@ dispose(): void; | ||
_updateProtocolRequestInterception(): Promise<void>; | ||
_onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload): void; | ||
_onRequestWillBeSent(workerFrame: frames.Frame | undefined, event: Protocol.Network.requestWillBeSentPayload): void; | ||
_onAuthRequired(event: Protocol.Fetch.authRequiredPayload): void; | ||
_onRequestPaused(event: Protocol.Fetch.requestPausedPayload): void; | ||
_onRequest(event: Protocol.Network.requestWillBeSentPayload, interceptionId: string | null): void; | ||
_onRequestPaused(workerFrame: frames.Frame | undefined, event: Protocol.Fetch.requestPausedPayload): void; | ||
_onRequest(workerFrame: frames.Frame | undefined, event: Protocol.Network.requestWillBeSentPayload, interceptionId: string | null): void; | ||
_createResponse(request: InterceptableRequest, responsePayload: Protocol.Network.Response): network.Response; | ||
@@ -61,3 +61,3 @@ _handleRequestRedirect(request: InterceptableRequest, responsePayload: Protocol.Network.Response): void; | ||
private _client; | ||
constructor(client: CRSession, frame: frames.Frame | null, interceptionId: string | null, documentId: string | undefined, allowInterception: boolean, event: Protocol.Network.requestWillBeSentPayload, redirectChain: network.Request[]); | ||
constructor(client: CRSession, frame: frames.Frame, interceptionId: string | null, documentId: string | undefined, allowInterception: boolean, event: Protocol.Network.requestWillBeSentPayload, redirectChain: network.Request[]); | ||
continue(overrides?: { | ||
@@ -64,0 +64,0 @@ method?: string; |
@@ -35,7 +35,7 @@ "use strict"; | ||
} | ||
instrumentNetworkEvents(session) { | ||
instrumentNetworkEvents(session, workerFrame) { | ||
return [ | ||
helper_1.helper.addEventListener(session, 'Fetch.requestPaused', this._onRequestPaused.bind(this)), | ||
helper_1.helper.addEventListener(session, 'Fetch.requestPaused', this._onRequestPaused.bind(this, workerFrame)), | ||
helper_1.helper.addEventListener(session, 'Fetch.authRequired', this._onAuthRequired.bind(this)), | ||
helper_1.helper.addEventListener(session, 'Network.requestWillBeSent', this._onRequestWillBeSent.bind(this)), | ||
helper_1.helper.addEventListener(session, 'Network.requestWillBeSent', this._onRequestWillBeSent.bind(this, workerFrame)), | ||
helper_1.helper.addEventListener(session, 'Network.responseReceived', this._onResponseReceived.bind(this)), | ||
@@ -90,3 +90,3 @@ helper_1.helper.addEventListener(session, 'Network.loadingFinished', this._onLoadingFinished.bind(this)), | ||
} | ||
_onRequestWillBeSent(event) { | ||
_onRequestWillBeSent(workerFrame, event) { | ||
// Request interception doesn't happen for data URLs with Network Service. | ||
@@ -97,3 +97,3 @@ if (this._protocolRequestInterceptionEnabled && !event.request.url.startsWith('data:')) { | ||
if (interceptionId) { | ||
this._onRequest(event, interceptionId); | ||
this._onRequest(workerFrame, event, interceptionId); | ||
this._requestIdToInterceptionId.delete(requestId); | ||
@@ -106,3 +106,3 @@ } | ||
} | ||
this._onRequest(event, null); | ||
this._onRequest(workerFrame, event, null); | ||
} | ||
@@ -124,3 +124,3 @@ _onAuthRequired(event) { | ||
} | ||
_onRequestPaused(event) { | ||
_onRequestPaused(workerFrame, event) { | ||
if (!this._userRequestInterceptionEnabled && this._protocolRequestInterceptionEnabled) { | ||
@@ -137,3 +137,3 @@ this._client.send('Fetch.continueRequest', { | ||
if (requestWillBeSentEvent) { | ||
this._onRequest(requestWillBeSentEvent, interceptionId); | ||
this._onRequest(workerFrame, requestWillBeSentEvent, interceptionId); | ||
this._requestIdToRequestWillBeSentEvent.delete(requestId); | ||
@@ -145,3 +145,3 @@ } | ||
} | ||
_onRequest(event, interceptionId) { | ||
_onRequest(workerFrame, event, interceptionId) { | ||
if (event.request.url.startsWith('data:')) | ||
@@ -158,4 +158,8 @@ return; | ||
} | ||
// TODO: how can frame be null here? | ||
const frame = event.frameId ? this._page._frameManager.frame(event.frameId) : null; | ||
const frame = event.frameId ? this._page._frameManager.frame(event.frameId) : workerFrame; | ||
if (!frame) { | ||
if (interceptionId) | ||
this._client.send('Fetch.continueRequest', { requestId: interceptionId }).catch(helper_1.debugError); | ||
return; | ||
} | ||
const isNavigationRequest = event.requestId === event.loaderId && event.type === 'Document'; | ||
@@ -162,0 +166,0 @@ const documentId = isNavigationRequest ? event.loaderId : undefined; |
@@ -218,3 +218,4 @@ "use strict"; | ||
session.on('Runtime.exceptionThrown', exception => this._page.emit(events_1.Events.Page.PageError, crProtocolHelper_1.exceptionToError(exception.exceptionDetails))); | ||
this._networkManager.instrumentNetworkEvents(session); | ||
// TODO: attribute workers to the right frame. | ||
this._networkManager.instrumentNetworkEvents(session, this._page.mainFrame()); | ||
} | ||
@@ -221,0 +222,0 @@ _onDetachedFromTarget(event) { |
@@ -175,7 +175,4 @@ "use strict"; | ||
this._inflightRequestStarted(request); | ||
const frame = request.frame(); | ||
if (frame) { | ||
for (const watcher of frame._requestWatchers) | ||
watcher(request); | ||
} | ||
for (const watcher of request.frame()._requestWatchers) | ||
watcher(request); | ||
if (!request._isFavicon) | ||
@@ -195,5 +192,4 @@ this._page._requestStarted(request); | ||
this._inflightRequestFinished(request); | ||
const frame = request.frame(); | ||
if (request._documentId && frame) { | ||
const isCurrentDocument = frame._lastDocumentId === request._documentId; | ||
if (request._documentId) { | ||
const isCurrentDocument = request.frame()._lastDocumentId === request._documentId; | ||
if (!isCurrentDocument) { | ||
@@ -203,3 +199,3 @@ let errorText = request.failure().errorText; | ||
errorText += '; maybe frame was detached?'; | ||
for (const watcher of frame._documentWatchers) | ||
for (const watcher of request.frame()._documentWatchers) | ||
watcher(request._documentId, new Error(errorText)); | ||
@@ -224,3 +220,3 @@ } | ||
const frame = request.frame(); | ||
if (!frame || request._isFavicon) | ||
if (request._isFavicon) | ||
return; | ||
@@ -237,3 +233,3 @@ if (!frame._inflightRequests.has(request)) | ||
const frame = request.frame(); | ||
if (!frame || request._isFavicon) | ||
if (request._isFavicon) | ||
return; | ||
@@ -240,0 +236,0 @@ frame._inflightRequests.add(request); |
@@ -64,3 +64,3 @@ /** | ||
private _interceptionHandled; | ||
constructor(delegate: RequestDelegate | null, frame: frames.Frame | null, redirectChain: Request[], documentId: string | undefined, url: string, resourceType: string, method: string, postData: string | undefined, headers: Headers); | ||
constructor(delegate: RequestDelegate | null, frame: frames.Frame, redirectChain: Request[], documentId: string | undefined, url: string, resourceType: string, method: string, postData: string | undefined, headers: Headers); | ||
_setFailureText(failureText: string): void; | ||
@@ -78,3 +78,3 @@ url(): string; | ||
_setResponse(response: Response): void; | ||
frame(): frames.Frame | null; | ||
frame(): frames.Frame; | ||
isNavigationRequest(): boolean; | ||
@@ -119,3 +119,3 @@ redirectChain(): Request[]; | ||
request(): Request; | ||
frame(): frames.Frame | null; | ||
frame(): frames.Frame; | ||
} | ||
@@ -122,0 +122,0 @@ export declare type FulfillResponse = { |
@@ -27,3 +27,3 @@ /** | ||
private _interceptedPromise; | ||
constructor(session: WKSession, allowInterception: boolean, frame: frames.Frame | null, event: Protocol.Network.requestWillBeSentPayload, redirectChain: network.Request[], documentId: string | undefined); | ||
constructor(session: WKSession, allowInterception: boolean, frame: frames.Frame, event: Protocol.Network.requestWillBeSentPayload, redirectChain: network.Request[], documentId: string | undefined); | ||
abort(errorCode: string): Promise<void>; | ||
@@ -30,0 +30,0 @@ fulfill(response: network.FulfillResponse): Promise<void>; |
{ | ||
"name": "playwright-core", | ||
"version": "0.11.1-next.1583863091474", | ||
"version": "0.11.1-next.1583871165271", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -5,0 +5,0 @@ "repository": "github:Microsoft/playwright", |
Sorry, the diff of this file is too big to display
2443702
57263