From cf47a164991bf5588fd2b41ce244f55d900c1167 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Tue, 10 Nov 2026 19:17:57 +0200 Subject: extension: snapshot sandboxed pages over CDP, never return empty text On a page served with CSP `sandbox` and no allow-scripts, such as raw.githubusercontent.com, chrome.scripting.executeScript runs nothing and resolves with a null result instead of throwing. The access-denied CDP fallback never ran, page.snapshot returned undefined, and chrome_snapshot answered with {type: "text"} and no text, because JSON.stringify(undefined) is undefined. Pi saved that block in the session, and every later turn failed in token estimation with "Cannot read properties of undefined (reading 'length')", whatever the provider. When scripting resolves without an envelope, snapshot and inspect now redo the injection and the call over CDP Runtime.evaluate, which such pages still allow, and raise an error if that also returns nothing. On the pi side, safeJson always returns a string, and an empty snapshot or inspect result is a tool error rather than a text block without text. sandboxed-snapshot.test.mjs drives page.snapshot and page.inspect through a page that runs no extension script. It fails on b8b63ea. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package.json') diff --git a/package.json b/package.json index cc7ef4c..7f7e204 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pi-chrome", "version": "0.15.57", "scripts": { - "test": "node test-suite/unit/csp-eval.test.mjs && node test-suite/unit/automation-target.test.mjs && node test-suite/unit/session-cleanup.test.mjs && node test-suite/unit/background-policy.test.mjs && node test-suite/unit/input-reliability.test.mjs && node test-suite/unit/chrome-command.test.mjs && node test-suite/unit/bridge-resilience.test.mjs && node test-suite/unit/cdp-passthrough.test.mjs && node test-suite/unit/type-evidence.test.mjs && node test-suite/unit/hidden-input.test.mjs && node test-suite/unit/console-capture.test.mjs && node test-suite/unit/prompt-section.test.mjs && node test-suite/unit/upload-guard.test.mjs && node test-suite/unit/grant-scope.test.mjs && node test-suite/unit/leave-site-prompt.test.mjs && node test-suite/unit/shared-window.test.mjs && node test-suite/unit/overlay.test.mjs", + "test": "node test-suite/unit/csp-eval.test.mjs && node test-suite/unit/automation-target.test.mjs && node test-suite/unit/session-cleanup.test.mjs && node test-suite/unit/background-policy.test.mjs && node test-suite/unit/input-reliability.test.mjs && node test-suite/unit/chrome-command.test.mjs && node test-suite/unit/bridge-resilience.test.mjs && node test-suite/unit/cdp-passthrough.test.mjs && node test-suite/unit/type-evidence.test.mjs && node test-suite/unit/hidden-input.test.mjs && node test-suite/unit/console-capture.test.mjs && node test-suite/unit/prompt-section.test.mjs && node test-suite/unit/upload-guard.test.mjs && node test-suite/unit/grant-scope.test.mjs && node test-suite/unit/leave-site-prompt.test.mjs && node test-suite/unit/shared-window.test.mjs && node test-suite/unit/overlay.test.mjs && node test-suite/unit/sandboxed-snapshot.test.mjs", "version": "node scripts/sync-manifest-version.js", "prepublishOnly": "node scripts/sync-manifest-version.js" }, -- cgit v1.2.3