fix(browser): preserve body API provenance through script export
Label new captured response bytes as Playwright body API results and retain the possibility of a credentialed follow-up load. Preserve legacy representations and source limitations through export without treating body-origin uncertainty as missing event coverage. Validated source and filesystem boundary tests plus real Chrome CLI and MCP network workflows covering binary, compressed, empty, unfinished, and same-URL responses and profile cleanup.
This commit is contained in:
@@ -72,7 +72,7 @@ export const captureNetworkHeaders = async (
|
||||
}
|
||||
};
|
||||
|
||||
/** Retain only bytes exposed by the browser; no fetch or wire-byte reconstruction occurs. */
|
||||
/** Retain bytes returned by Playwright's body API, after declared-secret redaction. */
|
||||
export const captureNetworkBody = async (
|
||||
read: () => Promise<Buffer | null>,
|
||||
phase: "request" | "response",
|
||||
@@ -94,7 +94,7 @@ export const captureNetworkBody = async (
|
||||
representation:
|
||||
phase === "request"
|
||||
? "browser-exposed-request-bytes"
|
||||
: "browser-decoded-response-bytes",
|
||||
: "playwright-response-body-bytes",
|
||||
encoding: "base64",
|
||||
content: retained.toString("base64"),
|
||||
bytes: retained.length,
|
||||
|
||||
@@ -178,6 +178,9 @@ it("associates out-of-order same-URL responses by request identity", async () =>
|
||||
(event) =>
|
||||
event.phase === "response" && bodyText(event) === `reply:${marker}`,
|
||||
);
|
||||
expect(response).toMatchObject({
|
||||
body: { representation: "playwright-response-body-bytes" },
|
||||
});
|
||||
expect(request?.transaction_id).toBe(response?.transaction_id);
|
||||
expect(request?.source_event_sequence).not.toBe(
|
||||
response?.source_event_sequence,
|
||||
|
||||
@@ -128,7 +128,7 @@ export class PlaywrightScenarioNetwork {
|
||||
transaction.response = { source: response, sequence };
|
||||
}
|
||||
|
||||
/** Record completion and read the original completed response, never a later refetch. */
|
||||
/** Record completion and read selected content through the response API. */
|
||||
finished(request: ScenarioNetworkRequest): void {
|
||||
if (!this.accepting) return;
|
||||
const transaction = this.transaction(request);
|
||||
|
||||
Reference in New Issue
Block a user