[WebDriver: Dispatch Action] Check if browsing context still open for each tick action (#37393)

As titled. This is what
[spec](https://w3c.github.io/webdriver/#dfn-dispatch-actions-inner)
requires. The motivation is that the previous action might have changed
the browsing context.

Testing: `./mach test-wpt -r --log-raw "D:\servo test log\all.txt"
.\tests\wpt\tests\webdriver\tests\classic\ --product servodriver`

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-06-11 17:53:06 +08:00 committed by GitHub
parent 048d4a2a5a
commit 5f1452f9d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 10 deletions

View file

@ -1543,14 +1543,15 @@ impl Handler {
&mut self,
parameters: ActionsParameters,
) -> WebDriverResult<WebDriverResponse> {
let browsing_context = self.session()?.browsing_context_id;
// Step 1. If session's current browsing context is no longer open,
// return error with error code no such window.
self.verify_browsing_context_is_open(self.session()?.browsing_context_id)?;
self.verify_browsing_context_is_open(browsing_context)?;
// Step 5. Let actions by tick be the result of trying to extract an action sequence
let actions_by_tick = self.extract_an_action_sequence(parameters);
// Step 6. Dispatch actions
match self.dispatch_actions(actions_by_tick) {
// Step 6. Dispatch actions with current browsing context
match self.dispatch_actions(actions_by_tick, browsing_context) {
Ok(_) => Ok(WebDriverResponse::Void),
Err(error) => Err(WebDriverError::new(error, "")),
}
@ -1782,9 +1783,11 @@ impl Handler {
},
};
// Step 8.16. Dispatch a list of actions with session's current browsing context
let actions_by_tick = self.actions_by_tick_from_sequence(vec![action_sequence]);
if let Err(e) = self.dispatch_actions(actions_by_tick) {
if let Err(e) =
self.dispatch_actions(actions_by_tick, self.session()?.browsing_context_id)
{
log::error!("handle_element_click: dispatch_actions failed: {:?}", e);
}