mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Set proper button value in WebDriver - ElementClick command (#36871)
Fix ElementClick: `ElementClick` should use `MouseButton::Left` to create `action`. Testing: No pass test now. Tests still fail because of other issues. For: https://github.com/servo/servo/issues/36658 cc: @xiaochengh , @yezhizhen , @PotatoCP Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
eaf9224799
commit
b2e51820e4
3 changed files with 20 additions and 18 deletions
|
@ -61,15 +61,16 @@ pub enum MouseButton {
|
|||
Other(u16),
|
||||
}
|
||||
|
||||
impl From<u16> for MouseButton {
|
||||
fn from(value: u16) -> Self {
|
||||
impl<T: Into<u64>> From<T> for MouseButton {
|
||||
fn from(value: T) -> Self {
|
||||
let value = value.into();
|
||||
match value {
|
||||
0 => MouseButton::Left,
|
||||
1 => MouseButton::Middle,
|
||||
2 => MouseButton::Right,
|
||||
3 => MouseButton::Back,
|
||||
4 => MouseButton::Forward,
|
||||
_ => MouseButton::Other(value),
|
||||
_ => MouseButton::Other(value as u16),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,11 +305,10 @@ impl Handler {
|
|||
},
|
||||
});
|
||||
|
||||
let button = (action.button as u16).into();
|
||||
let cmd_msg = WebDriverCommandMsg::MouseButtonAction(
|
||||
session.webview_id,
|
||||
MouseButtonAction::Down,
|
||||
button,
|
||||
action.button.into(),
|
||||
pointer_input_state.x as f32,
|
||||
pointer_input_state.y as f32,
|
||||
);
|
||||
|
@ -351,11 +350,10 @@ impl Handler {
|
|||
},
|
||||
});
|
||||
|
||||
let button = (action.button as u16).into();
|
||||
let cmd_msg = WebDriverCommandMsg::MouseButtonAction(
|
||||
session.webview_id,
|
||||
MouseButtonAction::Up,
|
||||
button,
|
||||
action.button.into(),
|
||||
pointer_input_state.x as f32,
|
||||
pointer_input_state.y as f32,
|
||||
);
|
||||
|
|
|
@ -23,7 +23,7 @@ use constellation_traits::{EmbedderToConstellationMessage, TraversalDirection};
|
|||
use cookie::{CookieBuilder, Expiration};
|
||||
use crossbeam_channel::{Receiver, Sender, after, select, unbounded};
|
||||
use embedder_traits::{
|
||||
WebDriverCommandMsg, WebDriverCookieError, WebDriverFrameId, WebDriverJSError,
|
||||
MouseButton, WebDriverCommandMsg, WebDriverCookieError, WebDriverFrameId, WebDriverJSError,
|
||||
WebDriverJSResult, WebDriverJSValue, WebDriverLoadStatus, WebDriverScriptCommand,
|
||||
};
|
||||
use euclid::{Rect, Size2D};
|
||||
|
@ -1619,7 +1619,10 @@ impl Handler {
|
|||
InputSourceState::Pointer(PointerInputState::new(&PointerType::Mouse)),
|
||||
);
|
||||
|
||||
// Steps 8.3 - 8.6
|
||||
// Step 8.7. Construct a pointer move action.
|
||||
// Step 8.8. Set a property x to 0 on pointer move action.
|
||||
// Step 8.9. Set a property y to 0 on pointer move action.
|
||||
// Step 8.10. Set a property origin to element on pointer move action.
|
||||
let pointer_move_action = PointerMoveAction {
|
||||
duration: None,
|
||||
origin: PointerOrigin::Element(WebElement(element_id)),
|
||||
|
@ -1628,32 +1631,32 @@ impl Handler {
|
|||
..Default::default()
|
||||
};
|
||||
|
||||
// Steps 8.7 - 8.8
|
||||
// Step 8.11. Construct pointer down action.
|
||||
// Step 8.12. Set a property button to 0 on pointer down action.
|
||||
let pointer_down_action = PointerDownAction {
|
||||
button: 1,
|
||||
button: i16::from(MouseButton::Left) as u64,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Steps 8.9 - 8.10
|
||||
// Step 8.13. Construct pointer up action.
|
||||
// Step 8.14. Set a property button to 0 on pointer up action.
|
||||
let pointer_up_action = PointerUpAction {
|
||||
button: 1,
|
||||
button: i16::from(MouseButton::Left) as u64,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Step 8.11
|
||||
// Step 8.16 Dispatch a list of actions with input state,
|
||||
// actions, session's current browsing context, and actions options.
|
||||
if let Err(error) =
|
||||
self.dispatch_pointermove_action(&id, &pointer_move_action, 0)
|
||||
{
|
||||
return Err(WebDriverError::new(error, ""));
|
||||
}
|
||||
|
||||
// Steps 8.12
|
||||
self.dispatch_pointerdown_action(&id, &pointer_down_action);
|
||||
|
||||
// Steps 8.13
|
||||
self.dispatch_pointerup_action(&id, &pointer_up_action);
|
||||
|
||||
// Step 8.14
|
||||
// Step 8.17 Remove an input source with input state and input id.
|
||||
self.session_mut()?.input_state_table.remove(&id);
|
||||
|
||||
// Step 13
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue