Commit d3021b64 authored by Janka Uryga's avatar Janka Uryga Committed by Zack Tanner

update playwright interface

partial cherry-pick from #64604, needed for #67734
parent 5e6f511e
export type Event = 'request' export type Event = 'request' | 'response'
/** /**
* This is the base Browser interface all browser * This is the base Browser interface all browser
......
...@@ -49,6 +49,7 @@ export class Playwright extends BrowserInterface { ...@@ -49,6 +49,7 @@ export class Playwright extends BrowserInterface {
private activeTrace?: string private activeTrace?: string
private eventCallbacks: Record<Event, Set<(...args: any[]) => void>> = { private eventCallbacks: Record<Event, Set<(...args: any[]) => void>> = {
request: new Set(), request: new Set(),
response: new Set(),
} }
private async initContextTracing(url: string, context: BrowserContext) { private async initContextTracing(url: string, context: BrowserContext) {
if (!tracePlaywright) { if (!tracePlaywright) {
...@@ -233,6 +234,9 @@ export class Playwright extends BrowserInterface { ...@@ -233,6 +234,9 @@ export class Playwright extends BrowserInterface {
page.on('request', (req) => { page.on('request', (req) => {
this.eventCallbacks.request.forEach((cb) => cb(req)) this.eventCallbacks.request.forEach((cb) => cb(req))
}) })
page.on('response', (res) => {
this.eventCallbacks.response.forEach((cb) => cb(res))
})
if (opts?.disableCache) { if (opts?.disableCache) {
// TODO: this doesn't seem to work (dev tools does not check the box as expected) // TODO: this doesn't seem to work (dev tools does not check the box as expected)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment