servo/components/script
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
..
docs
dom script: Support keyCode, charCode in KeyboardEvent constructor (#39590) 2025-10-01 14:45:33 +00:00
layout_dom layout: Ensure IFC for abspos with inline-level original display (#39041) 2025-09-02 03:43:55 +00:00
resources tidy: Add a rule ensuring that // comments are followed by a space in Rust (#38698) 2025-08-18 12:09:09 +00:00
animation_timeline.rs
animations.rs script: Integrate animated image updates into ScriptThread event loop (#38941) 2025-08-26 17:24:12 +00:00
body.rs crown: Check closure bodies for unrooted types and fix root TransmitBodyPromise* (#39534) 2025-09-29 08:57:23 +00:00
build.rs
Cargo.toml Move XPath implementation into its own crate (#39546) 2025-09-30 19:55:10 +00:00
clipboard_provider.rs Add direct script to embedder channel (#39039) 2025-09-02 06:33:44 +00:00
conversions.rs
devtools.rs Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504) 2025-09-27 01:48:24 +00:00
document_collection.rs Replace Hash Algorithm in HashMap/Set with FxHashMap/Set for simple types (#39166) 2025-09-09 08:33:46 +00:00
document_loader.rs net: Remove CoreResourceThread from FetchThread state (#38422) 2025-08-13 17:40:10 +00:00
drag_data_store.rs Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481) 2025-09-25 12:27:42 +00:00
fetch.rs Abort fetch controller when signal is aborted (#39374) 2025-09-21 12:33:03 +00:00
iframe_collection.rs Removed FnvHash and transformed the rest to FxHashmap (#39233) 2025-09-10 13:34:54 +00:00
image_animation.rs Switch the majority of fxhash uses to rustc_hash which is maintained (#39168) 2025-09-06 05:19:47 +00:00
indexed_db.rs storage: Move storage related backend threads to their own crate (#39418) 2025-09-28 08:00:20 +00:00
init.rs
layout_image.rs
lib.rs Move XPath implementation into its own crate (#39546) 2025-09-30 19:55:10 +00:00
links.rs Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481) 2025-09-25 12:27:42 +00:00
messaging.rs libservo: Add a WebView::take_screenshot() API and use it for reftests (#39583) 2025-09-30 11:39:47 +00:00
microtask.rs Combine some access to the thread local variable for script thread. (#38752) 2025-09-11 09:40:32 +00:00
mime.rs build(deps): bump data-url from 0.3.1 to 0.3.2 (#38862) 2025-08-27 03:22:13 +00:00
navigation.rs
network_listener.rs
realms.rs
routed_promise.rs
script_module.rs script: Add line number argument to module script compilation functions (#39544) 2025-09-30 05:42:32 +00:00
script_mutation_observers.rs script: Empty pending mutation observers when notifying mutation observers (#39456) 2025-09-29 14:15:07 +00:00
script_runtime.rs script: Use conditional_malloc_size_of for Rc types on Window (#39589) 2025-09-30 16:03:34 +00:00
script_thread.rs libservo: Add a WebView::take_screenshot() API and use it for reftests (#39583) 2025-09-30 11:39:47 +00:00
script_window_proxies.rs Split WindowProxies in script to own struct and allow to get an Rc to it. (#39274) 2025-09-29 09:46:49 +00:00
security_manager.rs
serviceworker_manager.rs script: Migrate swmanager to GenericChannel (#39076) 2025-09-01 19:23:16 +00:00
stylesheet_loader.rs script: Make stylesheets loaded via <link> elements block the rendering (#39536) 2025-09-27 13:32:26 +00:00
stylesheet_set.rs
task.rs script: Measure heap usage of various ignored fields (#38791) 2025-08-20 08:43:58 +00:00
task_manager.rs script: Enable crypto task source at task manager (#39453) 2025-09-24 16:21:03 +00:00
task_queue.rs Replace Hash Algorithm in HashMap/Set with FxHashMap/Set for simple types (#39166) 2025-09-09 08:33:46 +00:00
task_source.rs script: Enable crypto task source at task manager (#39453) 2025-09-24 16:21:03 +00:00
test.rs script: Move HTML DOM interfaces to script/dom/html/ (#39046) 2025-08-31 01:00:09 +00:00
textinput.rs Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504) 2025-09-27 01:48:24 +00:00
timers.rs Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481) 2025-09-25 12:27:42 +00:00
unminify.rs
webdriver_handlers.rs storage: Move shared functionality to base (#39419) 2025-09-22 13:59:36 +00:00
window_named_properties.rs script: Move operations in window_named_properties::get_own_property_descriptor & webdriver_handlers::clone_an_object into unsafe blocks (#38951) 2025-08-26 21:48:25 +00:00
xpath.rs Move XPath implementation into its own crate (#39546) 2025-09-30 19:55:10 +00:00