Skip to content

fix(cdp): serialize integral box-model coords as JSON integers (#576) - #674

Open
ousamabenyounes wants to merge 1 commit into
h4ckf0r0day:mainfrom
ousamabenyounes:fix/issue-576
Open

fix(cdp): serialize integral box-model coords as JSON integers (#576)#674
ousamabenyounes wants to merge 1 commit into
h4ckf0r0day:mainfrom
ousamabenyounes:fix/issue-576

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Problem

DOM.getBoxModel (issue #576) serialized every coordinate through json!(f64), so an integral value like 256.0 was written as "256.0". Strict CDP clients (Hermes Agent) deserialize box-model coordinates as i64 and reject the float, breaking every click-by-coordinate flow. Chrome itself emits integral coordinates as integers and only widens genuinely fractional ones.

Fix

coord_value() collapses an exactly-integral, i64-representable double to a JSON integer and leaves fractional / NaN / inf values untouched. Both box-model emission sites route through it.

Test verification (RED → GREEN)

Unit test box_model_integral_coordinates_serialize_as_integers (cargo test -p obscura-cdp --lib).

RED (fix logic reverted to json!(n), test kept):

test domains::dom::tests::box_model_integral_coordinates_serialize_as_integers ... FAILED
assertion `left == right` failed
  left: "256.0"
 right: "256"
test result: FAILED. 0 passed; 1 failed

GREEN (with the fix):

test domains::dom::tests::box_model_integral_coordinates_serialize_as_integers ... ok
test result: ok. 1 passed; 0 failed

Closes #576

…0r0day#576)

DOM.getBoxModel emitted every coordinate through json!(f64), so an integral
value like 256.0 serialized as "256.0". Strict CDP clients (Hermes Agent)
deserialize box-model coordinates as i64 and reject the float, breaking every
click-by-coordinate flow. Chrome only widens genuinely fractional coordinates,
so mirror that: coord_value() collapses an exactly-integral, i64-representable
double to a JSON integer and leaves fractional / NaN / inf values untouched.

Adds a unit test covering integral, fractional and mixed-quad serialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDP: DOM.getBoxModel returns float coords (256.0) — breaks strict clients expecting integers

1 participant