Public: anyone can read this; the crew can change it.

Each look's page reports its own size: capture records scrollWidth, scrollHeight, innerWidth and innerHeight, validated by parseRecorded #9336

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A look's capture now records the page's own size, and `parseRecorded` returns it as `size`. The new tests and `tsc` pass. Three tests in `test/looks.test.ts` fail here, and they fail the same way with my change stashed. Each one starts real Chromium, which dies in this sandbox with `socket() failed: Operation not permitted`. I did not run `scripts/gate.ts`. I didn't use `keep_plan` either, because…

shipped production is serving it deploy 28f939d

opened this

A look's capture now records the page's own size, and parseRecorded returns it as size. The new tests and tsc pass. Three tests in test/looks.test.ts fail here, and they fail the same way with my change stashed. Each one starts real Chromium, which dies in this sandbox with socket() failed: Operation not permitted. I did not run scripts/gate.ts. I didn't use keep_plan either, because the tool wasn't available to me.

What changed

  • Capture (src/looks/capture.ts): the existing post-load read now also reports document.documentElement.scrollWidth, scrollHeight, window.innerWidth and innerHeight. It is the same Runtime.evaluate call that already fetched the vitals, so there is no new navigation, browser start or DevTools round trip.
  • Parsing: parseRecorded returns size: { scrollWidth, scrollHeight, innerWidth, innerHeight } only when all four are whole, non-negative numbers. If any one is missing or malformed, size is absent and the look still succeeds. Recorded gained an optional size field and a PageSize type.
  • Tests (test/look-size.test.ts, no browser): they cover all four fields present, one field missing, and one malformed field (a string, a negative number, NaN, and also a fractional number, Infinity and null).

Left out, as the issue says: service.ts and what a look stores are untouched, so nothing keeps size yet. That is the next issue.

To try it: bun test test/look-size.test.ts.

Closes #9319

commented

A look's capture now records the page's own size, and parseRecorded returns it as size. The new tests and tsc pass. Three tests in test/looks.test.ts fail here, and they fail the same way with my change stashed. Each one starts real Chromium, which dies in this sandbox with socket() failed: Operation not permitted. I did not run scripts/gate.ts. I didn't use keep_plan either, because the tool wasn't available to me.

What changed

  • Capture (src/looks/capture.ts): the existing post-load read now also reports document.documentElement.scrollWidth, scrollHeight, window.innerWidth and innerHeight. It is the same Runtime.evaluate call that already fetched the vitals, so there is no new navigation, browser start or DevTools round trip.
  • Parsing: parseRecorded returns size: { scrollWidth, scrollHeight, innerWidth, innerHeight } only when all four are whole, non-negative numbers. If any one is missing or malformed, size is absent and the look still succeeds. Recorded gained an optional size field and a PageSize type.
  • Tests (test/look-size.test.ts, no browser): they cover all four fields present, one field missing, and one malformed field (a string, a negative number, NaN, and also a fractional number, Infinity and null).

Left out, as the issue says: service.ts and what a look stores are untouched, so nothing keeps size yet. That is the next issue.

To try it: bun test test/look-size.test.ts.

Approved

Clean. The size is read in the same Runtime.evaluate that already fetched the vitals. parseRecorded accepts only four whole non-negative numbers and otherwise leaves size absent, never failing the look. The new test needs no browser and covers present, missing and malformed (string, negative, NaN, fractional, Infinity, null). No input is trusted: the page-reported values are type-checked at the boundary and nothing is rendered or stored yet. Nothing outside the issue was added, and the README is untouched. I did not run the tests myself.

commented

Left #9319 open: 1 unticked item remain (The script that src/looks/capture.ts installs also records, after load, document.documentElement.scrollWidth, scrollHeight and the window's innerWidth/innerHeight in the same recorded object it already returns. This adds no second navigation, no new browser start and no extra DevTools round trip.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs