mirror of
https://github.com/servo/servo
synced 2026-05-12 09:56:50 +02:00
JavaScript Number does not have Integer type, except for recently added `BigInt`. That's why we removed `Int` variant from `JSValue` earlier in #38748. However, the Serde deserialization is strict: when it expects `u64`, it cannot deserialize "3.0". But when it expects `f64`, it can still deserialize "3". Now, we serialize as i64 if the JS Number has no fractional part. This not only fixes regression, but also improves the case where we have an integer not representable by i32 and previously would be parsed as f64 again. Testing: `./mach test-wpt -r /infrastructure/testdriver/actions/eventOrder.html --headless --product servodriver` no longer fails when deserializing HTTP request. Fixes: #39181 Signed-off-by: Euclid Ye <euclid.ye@huawei.com>