servo/components/script_bindings
atbrakhi 4ea363277e
script: Support keyCode, charCode in KeyboardEvent constructor (#39590)
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>
2025-10-01 14:45:33 +00:00
..
codegen html: Count <image> attributes state changes as the relevant mutations (#39483) 2025-09-29 09:00:51 +00:00
webidls script: Support keyCode, charCode in KeyboardEvent constructor (#39590) 2025-10-01 14:45:33 +00:00
build.rs Mergeruff.toml into pyproject.toml (#37741) 2025-07-04 12:21:48 +00:00
callback.rs script: Measure heap usage of various ignored fields (#38791) 2025-08-20 08:43:58 +00:00
Cargo.toml Cargo.toml cleanup (#39403) 2025-09-20 03:09:37 +00:00
constant.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
constructor.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
conversions.rs Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481) 2025-09-25 12:27:42 +00:00
error.rs script: Add message to InvalidStateError (#39535) 2025-09-27 19:23:05 +00:00
finalize.rs script_bindings Start wrapping unsafe code in unsafe {} (#38545) 2025-08-08 12:21:31 +00:00
guard.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
import.rs Make ImageData more spec compliant (#37620) 2025-06-25 16:48:58 +00:00
inheritance.rs More miscellaneous script splitting changes (#36220) 2025-03-30 11:06:30 +00:00
interface.rs script: Add support for creating globals in isolated compartments (#38236) 2025-07-23 11:34:37 +00:00
interfaces.rs codegen: use FromJSValConvertible trait for Promise (#36966) 2025-05-12 11:05:46 +00:00
iterable.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
lib.rs script_bindings: Assert that serializable/transferable types have accurate WebIDL annotations (#38615) 2025-08-13 08:36:04 +00:00
like.rs Move more bindings types to script_bindings (#35620) 2025-02-23 14:25:46 +00:00
lock.rs Miscellaneous script splitting preparation changes (#36216) 2025-03-29 08:11:27 +00:00
mem.rs script_bindings Start wrapping unsafe code in unsafe {} (#38545) 2025-08-08 12:21:31 +00:00
namespace.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
num.rs script: Implement QuotaExceededError WebIDL interface (#38507) 2025-08-14 17:58:50 +00:00
principals.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
proxyhandler.rs Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481) 2025-09-25 12:27:42 +00:00
realms.rs cargo: Bump rustc to 1.89 (#36818) 2025-08-19 11:07:53 +00:00
record.rs Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481) 2025-09-25 12:27:42 +00:00
reflector.rs cargo: Bump rustc to 1.89 (#36818) 2025-08-19 11:07:53 +00:00
root.rs script_bindings: Remove Cell wrapper from thread-local RootCollection. (#39043) 2025-08-30 19:47:26 +00:00
script_runtime.rs
settings_stack.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
str.rs Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504) 2025-09-27 01:48:24 +00:00
structuredclone.rs script_bindings: Assert that serializable/transferable types have accurate WebIDL annotations (#38615) 2025-08-13 08:36:04 +00:00
trace.rs cargo: Bump rustc to 1.89 (#36818) 2025-08-19 11:07:53 +00:00
utils.rs script: Make set_dictionary_property a safe function (#39191) 2025-09-07 11:56:20 +00:00
weakref.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00