mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Wait enough time for tick duration in webdriver dispatch actions (#37423)
Add step `wait at least tick duration milliseconds have passed` https://w3c.github.io/webdriver/#dfn-dispatch-actions-inner Testing: Fix intermittent timeout in: `/tests/wpt/tests/webdriver/tests/classic/perform_actions/pointer_dblclick.py` cc: @xiaochengh , @jdm Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
4c598037a5
commit
6818d5c600
1 changed files with 9 additions and 2 deletions
|
@ -31,6 +31,7 @@ static WHEELSCROLL_INTERVAL: u64 = 17;
|
|||
// In the spec, `action item` refers to a plain JSON object.
|
||||
// However, we use the name ActionItem here
|
||||
// to be consistent with type names from webdriver crate.
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum ActionItem {
|
||||
Null(NullActionItem),
|
||||
Key(KeyActionItem),
|
||||
|
@ -148,6 +149,7 @@ impl Handler {
|
|||
// 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);
|
||||
let now = Instant::now();
|
||||
|
||||
// Step 1.3. Try to dispatch tick actions
|
||||
self.dispatch_tick_actions(tick_actions, tick_duration)?;
|
||||
|
@ -156,6 +158,12 @@ impl Handler {
|
|||
// The user agent event loop has spun enough times to process the DOM events
|
||||
// generated by the last invocation of the dispatch tick actions steps.
|
||||
self.wait_for_user_agent_handling_complete(tick_actions)?;
|
||||
// At least tick duration milliseconds have passed.
|
||||
let elapsed = now.elapsed();
|
||||
if elapsed.as_millis() < tick_duration as u128 {
|
||||
let sleep_duration = tick_duration - elapsed.as_millis() as u64;
|
||||
thread::sleep(Duration::from_millis(sleep_duration));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2. Return success with data null.
|
||||
|
@ -288,6 +296,7 @@ impl Handler {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/webdriver/#dfn-dispatch-a-pause-action>
|
||||
fn dispatch_general_action(&self, source_id: &str) {
|
||||
self.session()
|
||||
.unwrap()
|
||||
|
@ -295,8 +304,6 @@ impl Handler {
|
|||
.borrow_mut()
|
||||
.entry(source_id.to_string())
|
||||
.or_insert(InputSourceState::Null);
|
||||
// https://w3c.github.io/webdriver/#dfn-dispatch-a-pause-action
|
||||
// Nothing to be done
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/webdriver/#dfn-dispatch-a-keydown-action>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue