[WebDriver: Release Action] Fix panic by work around buggy spec (#37624)

1. Narrow the lifetime of `input_cancel_list` to avoid Runtime multiple
BorrowMut error.
2. Work around the buggy spec by removing matching item in
`input_cancel_list` when dispatch `keyUp` and `mouseUp`. See
https://github.com/servo/servo/issues/37579#issuecomment-2990762713

Testing: All WebDriver WPT test.
Fixes: #37579

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-06-23 16:33:18 +08:00 committed by GitHub
parent 795367c751
commit 5e252d0ef6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 39 additions and 24 deletions

View file

@ -64,7 +64,7 @@ use webdriver::response::{
};
use webdriver::server::{self, Session, SessionTeardownKind, WebDriverHandler};
use crate::actions::{ActionItem, ActionsByTick, InputSourceState, PointerInputState};
use crate::actions::{ActionItem, InputSourceState, PointerInputState};
#[derive(Default)]
pub struct WebDriverMessageIdGenerator {
@ -1758,8 +1758,10 @@ impl Handler {
// only one command can run at a time, so this will never block."
// Step 6. Let undo actions be input cancel list in reverse order.
let mut input_cancel_list = session.input_cancel_list.borrow_mut();
let undo_actions: ActionsByTick = input_cancel_list
let undo_actions = session
.input_cancel_list
.borrow_mut()
.drain(..)
.rev()
.map(|(id, action_item)| HashMap::from([(id, action_item)]))