import type { Page } from 'playwright'; /** * A request held before it leaves, whichever way it was held. * * What to refuse, what to read and what to serve instead is decided once, in * `network.ts`, over this; the two ways of holding a request below cannot drift * apart in what they record because neither decides anything. Only the holding * differs, and with it whether the browser's HTTP cache stays on. */ export interface Paused { readonly url: string; /** Playwright's vocabulary: `image`, `font`, `media`, `script`, … */ readonly resourceType: string; /** Lower-cased names. */ readonly headers: Readonly>; abort(): Promise; continue(): Promise; /** * Let it go and hold its answer, or `null` when there is nothing to read: the * answer is a redirect the browser follows, or the frame or worker that asked * is gone, and with it every reason to read the request. */ fetch(): Promise; /** Answer it with these bytes instead of letting it go. */ serve(contentType: string, body: Uint8Array): Promise; } export interface Answered { readonly body: Buffer; /** Lower-cased names. */ readonly headers: Readonly>; /** Hand the page these bytes under the answer's status and headers. */ fulfill(body: Uint8Array): Promise; /** * Hand the page the answer as it arrived. Kept apart from `fulfill` because * the browser caches an answer it let through and never one it was handed. */ pass(): Promise; } /** Stop holding requests. */ export type Unpause = () => Promise; /** Which frame or worker could not be held, and why, said as a sentence; it runs unheld. */ export type Unreached = (message: string) => void; /** Hold every request through Playwright's routing, which turns the HTTP cache off. */ export declare function pauseByRoute(page: Page, handle: (request: Paused) => Promise): Promise; /** * Hold every request through the DevTools protocol, with the HTTP cache left on. * * A request is paused once before it leaves, and a read one again when its * answer arrives — from the server or from the cache, both pass. A request * cancelled while its answer is awaited never pauses a second time, so the wait * also ends on the network's own word that it failed. * * A frame another site serves can run in a process of its own, and the * page's session hears none of its requests. So every such frame is attached as * it appears, held before its first request, given the same interception, and * only then let go; a target inside it is reached the same way. * * A dedicated worker's requests pause in the interception of the frame that * started it, but the network's word on them — that one failed — comes only * from the worker's own target. So a worker is attached and held the same way, * and listened to with no interception of its own, as Playwright's routing * listens to it. * * One that cannot be held still runs, and `unreached` names it. One that goes * away ends every wait on its requests at once, since no answer to them is * coming and nothing will show them. * * Chromium only. */ export declare function pauseByProtocol(page: Page, handle: (request: Paused) => Promise, unreached?: Unreached): Promise; //# sourceMappingURL=pause.d.ts.map