fix(browser): scope workers and binary frame sizes
This commit is contained in:
@@ -242,11 +242,15 @@ export class CdpCaptureEvents {
|
||||
}
|
||||
const response = recordValue(params.response);
|
||||
const payload = stringValue(response?.payloadData) ?? "";
|
||||
const opcode = Math.max(0, Math.trunc(numberValue(response?.opcode) ?? 0));
|
||||
this.websockets.push({
|
||||
request_id: requestId,
|
||||
direction,
|
||||
opcode: Math.max(0, Math.trunc(numberValue(response?.opcode) ?? 0)),
|
||||
payload_bytes: Buffer.byteLength(payload),
|
||||
opcode,
|
||||
payload_bytes:
|
||||
opcode === 1
|
||||
? Buffer.byteLength(payload)
|
||||
: Buffer.from(payload, "base64").byteLength,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ const captureAuthorizedPage = async (
|
||||
const workerCapture = await captureWorkers(
|
||||
context,
|
||||
allowedOrigins,
|
||||
new Set(frames.map((frame) => frame.frame_id)),
|
||||
limitations,
|
||||
);
|
||||
if (workerCapture.total > workerCapture.items.length)
|
||||
@@ -384,6 +385,7 @@ const captureScripts = async (
|
||||
const captureWorkers = async (
|
||||
context: CaptureContext,
|
||||
allowedOrigins: ReadonlySet<string>,
|
||||
frameIds: ReadonlySet<string>,
|
||||
limitations: string[],
|
||||
): Promise<{
|
||||
readonly total: number;
|
||||
@@ -400,7 +402,12 @@ const captureWorkers = async (
|
||||
for (const target of recordsValue(recordValue(result)?.targetInfos)) {
|
||||
const type = stringValue(target.type) ?? "";
|
||||
const url = allowedSanitizedUrl(target.url, allowedOrigins);
|
||||
if (!type.includes("worker") || url === undefined) continue;
|
||||
const relatedToPage =
|
||||
stringValue(target.openerId) === context.target.id ||
|
||||
(stringValue(target.parentFrameId) !== undefined &&
|
||||
frameIds.has(stringValue(target.parentFrameId) ?? ""));
|
||||
if (!type.includes("worker") || url === undefined || !relatedToPage)
|
||||
continue;
|
||||
total += 1;
|
||||
if (items.length >= context.input.limits.max_workers) continue;
|
||||
items.push({
|
||||
|
||||
Reference in New Issue
Block a user