aboutsummaryrefslogtreecommitdiff
path: root/src/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.ts')
-rw-r--r--src/client.ts2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/client.ts b/src/client.ts
index 4d8c3a8..9808e59 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -256,7 +256,7 @@ export const createBrowserClient = (opts: BrowserClientOptions): BrowserClient =
const currentTid = session.current()?.targetId;
const cached = currentTid ? pageCaches.get(currentTid) : undefined;
if (cached && !dirty && Date.now() - cached.at < PAGE_INFO_TTL_MS) return ok(cached.info);
- const expr = safeJs`JSON.stringify({url:location.href,title:document.title,w:innerWidth,h:innerHeight,sx:scrollX,sy:scrollY,pw:document.documentElement.scrollWidth,ph:document.documentElement.scrollHeight})`;
+ const expr = safeJs`JSON.stringify((function(){var e=document.documentElement||{scrollWidth:0,scrollHeight:0};return {url:location.href,title:document.title,w:innerWidth,h:innerHeight,sx:scrollX,sy:scrollY,pw:e.scrollWidth,ph:e.scrollHeight};})())`;
const raw = await evaluateJs(expr);
if (!raw.success) return raw;
if (typeof raw.data !== "string") return err(cdpError("invalid_response", "page info evaluation did not return a string"));