webdriver: Element Send keys use dispatch actions for KeyboardEvent (#38444)

Previously we immediately passed the KeyboardEvent to embedder. Now we
make element send keys go through the dispatch action which required by
spec. CompositionEvent still immediately passed through embedder

Testing: Should make
`./tests/wpt/tests/webdriver/tests/classic/element_send_keys/` more
stable.
Fixes: https://github.com/servo/servo/issues/38354
Fixes: https://github.com/servo/servo/issues/38442

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Co-authored-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Kenzie Raditya Tirtarahardja 2025-08-22 13:20:54 +08:00 committed by GitHub
parent 56ce19511c
commit cae8d22823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 138 additions and 137 deletions

View file

@ -16,7 +16,6 @@ use constellation_traits::EmbedderToConstellationMessage;
use crossbeam_channel::unbounded;
use euclid::{Point2D, Vector2D};
use ipc_channel::ipc;
use keyboard_types::webdriver::Event as WebDriverInputEvent;
use log::{info, trace, warn};
use net::protocols::ProtocolRegistry;
use servo::config::opts::Opts;
@ -486,24 +485,11 @@ impl App {
}
},
// Key events don't need hit test so can be forwarded to constellation for now
WebDriverCommandMsg::SendKeys(webview_id, webdriver_input_events) => {
let Some(webview) = running_state.webview_by_id(webview_id) else {
continue;
};
for event in webdriver_input_events {
match event {
WebDriverInputEvent::Keyboard(event) => {
webview.notify_input_event(InputEvent::Keyboard(
KeyboardEvent::new(event),
));
},
WebDriverInputEvent::Composition(event) => {
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
event,
)));
},
}
WebDriverCommandMsg::DispatchComposition(webview_id, composition_event) => {
if let Some(webview) = running_state.webview_by_id(webview_id) {
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
composition_event,
)));
}
},
WebDriverCommandMsg::KeyboardAction(webview_id, key_event, msg_id) => {