fix(browser): retain the null console argument in selected console text (#3479)

This commit is contained in:
The one -Niu
2026-10-22 04:07:37 +08:00
committed by GitHub
parent 0da36910dc
commit 1dcaa77693
4 changed files with 21 additions and 1 deletions
+6
View File
@@ -243,6 +243,12 @@ export const consolePrimitive = (
: undefined;
case "undefined":
return { type, text: "undefined" };
case "object":
// The protocol delivers `null` as an object with a `null` subtype. Its
// sentinel is already in the event, unlike an unexpanded remote object.
return cdpStringValue(value.subtype) === "null"
? { type, text: "null" }
: undefined;
default:
return undefined;
}
@@ -224,6 +224,7 @@ describe("CdpBrowserProvider: explicitly requested text and payload shapes", ()
const browser = await startFakeCdpBrowser({
sensitiveShapes: true,
binaryWebSocketEvent: true,
nullConsoleArgument: true,
eventsBeforeReply: ["Network.enable"],
});
trackBrowser(browser);
@@ -240,6 +241,12 @@ describe("CdpBrowserProvider: explicitly requested text and payload shapes", ()
);
if (!result.ok) throw result.error;
expect(result.value.console.events[0]?.argument_types).toEqual([
"string",
"number",
"object",
"object",
]);
expect(result.value.console.events[0]?.text_capture).toEqual({
status: "included",
values: [
@@ -249,10 +256,12 @@ describe("CdpBrowserProvider: explicitly requested text and payload shapes", ()
text: "authorization=Bearer console-secret",
},
{ argument_index: 1, type: "number", text: "42" },
{ argument_index: 3, type: "object", text: "null" },
],
retained_bytes:
Buffer.byteLength("authorization=Bearer console-secret") +
Buffer.byteLength("42"),
Buffer.byteLength("42") +
Buffer.byteLength("null"),
});
expect(result.value.network.requests[0]?.body_shapes).toMatchObject({
status: "included",
+3
View File
@@ -674,6 +674,9 @@ const emitRuntimeEvents = (
},
]
: []),
...(options.nullConsoleArgument === true
? [{ type: "object", subtype: "null", value: null }]
: []),
],
stackTrace: {
callFrames: [
+2
View File
@@ -98,6 +98,8 @@ export interface FakeOptions {
readonly sessionRedirectResourceType?: "Document" | "Fetch" | "Script";
readonly closeAfterMethod?: string;
readonly sensitiveShapes?: boolean;
/** Deliver a console argument the protocol spells as `{ type: "object", subtype: "null" }`. */
readonly nullConsoleArgument?: boolean;
readonly cachedResponseBody?: string;
readonly invalidResponseBodyBase64?: boolean;
readonly webMcpTools?: boolean;