mirror of
https://github.com/servo/servo
synced 2026-05-10 09:02:30 +02:00
Support `keyCode` and `charCode` fields in KeyboardEventInit for Speedometer 3.0 Speedometer 3.0 fails because Servo's KeyboardEvent constructor ignores keyCode and charCode parameters, hardcoding them to 0. This breaks frameworks that check `event.keyCode === 13` for Enter key detection. This is how [Speedometer 3.0 dispatches key events](8d67f28d02/resources/benchmark-runner.mjs (L166)) vs [Speedometer 2.0 triggerEnter](491acc2d64/resources/tests.mjs (L60)). Speedometer 3.0 uses the modern KeyboardEvent constructor but passes [legacy fields like keyCode and charCode](https://w3c.github.io/uievents/#legacy-dictionary-KeyboardEventInit) in the init dictionary for backwards compatibility with older frameworks(for example: backbone.js) This change uncomments the legacy KeyboardEventInit fields and updates the constructor to read them from the init dictionary instead of hardcoding to 0. Testing: No new tests added. Fixes: part of https://github.com/servo/servo/issues/16719 Servo running Speedometer3.0 successfully <img width="1136" height="880" alt="speedometer 3 0" src="https://github.com/user-attachments/assets/cf5199a5-d88d-4495-ae96-05fa6332b97e" /> --------- Signed-off-by: atbrakhi <atbrakhi@igalia.com>