fix(cdp): serialize integral box-model coords as JSON integers (#576) - #674
Open
ousamabenyounes wants to merge 1 commit into
Open
fix(cdp): serialize integral box-model coords as JSON integers (#576)#674ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DOM.getBoxModel(issue #576) serialized every coordinate throughjson!(f64), so an integral value like256.0was written as"256.0". Strict CDP clients (Hermes Agent) deserialize box-model coordinates asi64and 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/infvalues 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):GREEN (with the fix):
Closes #576