mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
[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:
parent
048d4a2a5a
commit
5f1452f9d3
3 changed files with 20 additions and 10 deletions
|
@ -6,6 +6,7 @@ use std::collections::{HashMap, HashSet};
|
|||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use base::id::BrowsingContextId;
|
||||
use constellation_traits::EmbedderToConstellationMessage;
|
||||
use embedder_traits::{MouseButtonAction, WebDriverCommandMsg, WebDriverScriptCommand};
|
||||
use ipc_channel::ipc;
|
||||
|
@ -114,6 +115,7 @@ impl Handler {
|
|||
pub(crate) fn dispatch_actions(
|
||||
&self,
|
||||
actions_by_tick: ActionsByTick,
|
||||
browsing_context: BrowsingContextId,
|
||||
) -> Result<(), ErrorStatus> {
|
||||
// Step 1. Wait for an action queue token with input state.
|
||||
let new_token = self.id_generator.next();
|
||||
|
@ -121,7 +123,7 @@ impl Handler {
|
|||
self.current_action_id.set(Some(new_token));
|
||||
|
||||
// Step 2. Let actions result be the result of dispatch actions inner.
|
||||
let res = self.dispatch_actions_inner(actions_by_tick);
|
||||
let res = self.dispatch_actions_inner(actions_by_tick, browsing_context);
|
||||
|
||||
// Step 3. Dequeue input state's actions queue.
|
||||
self.current_action_id.set(None);
|
||||
|
@ -131,9 +133,17 @@ impl Handler {
|
|||
}
|
||||
|
||||
/// <https://w3c.github.io/webdriver/#dfn-dispatch-actions-inner>
|
||||
fn dispatch_actions_inner(&self, actions_by_tick: ActionsByTick) -> Result<(), ErrorStatus> {
|
||||
fn dispatch_actions_inner(
|
||||
&self,
|
||||
actions_by_tick: ActionsByTick,
|
||||
browsing_context: BrowsingContextId,
|
||||
) -> Result<(), ErrorStatus> {
|
||||
// Step 1. For each item tick actions in actions by tick
|
||||
for tick_actions in actions_by_tick.iter() {
|
||||
// Step 1.1. If browsing context is no longer open,
|
||||
// return error with error code no such window.
|
||||
self.verify_browsing_context_is_open(browsing_context)
|
||||
.map_err(|e| e.error)?;
|
||||
// Step 1.2. Let tick duration be the result of
|
||||
// computing the tick duration with argument tick actions.
|
||||
let tick_duration = compute_tick_duration(tick_actions);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
[refresh.py]
|
||||
[test_no_top_browsing_context]
|
||||
expected: FAIL
|
||||
|
||||
[test_no_browsing_context]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue