mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Check receiver response in actions.rs (#36928)
Extend `wait_for_script_response()` (https://github.com/servo/servo/pull/35024) for `actions.rs` Signed-off-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com> Co-authored-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
This commit is contained in:
parent
da1c49299b
commit
924fd06f14
1 changed files with 15 additions and 17 deletions
|
@ -16,9 +16,9 @@ use webdriver::actions::{
|
||||||
PointerDownAction, PointerMoveAction, PointerOrigin, PointerType, PointerUpAction, WheelAction,
|
PointerDownAction, PointerMoveAction, PointerOrigin, PointerType, PointerUpAction, WheelAction,
|
||||||
WheelActionItem, WheelScrollAction,
|
WheelActionItem, WheelScrollAction,
|
||||||
};
|
};
|
||||||
use webdriver::error::ErrorStatus;
|
use webdriver::error::{ErrorStatus, WebDriverError};
|
||||||
|
|
||||||
use crate::Handler;
|
use crate::{Handler, wait_for_script_response};
|
||||||
|
|
||||||
// Interval between wheelScroll and pointerMove increments in ms, based on common vsync
|
// Interval between wheelScroll and pointerMove increments in ms, based on common vsync
|
||||||
static POINTERMOVE_INTERVAL: u64 = 17;
|
static POINTERMOVE_INTERVAL: u64 = 17;
|
||||||
|
@ -399,8 +399,11 @@ impl Handler {
|
||||||
WebDriverScriptCommand::GetElementInViewCenterPoint(x.to_string(), sender),
|
WebDriverScriptCommand::GetElementInViewCenterPoint(x.to_string(), sender),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let response = match wait_for_script_response(receiver) {
|
||||||
let Some(point) = receiver.recv().unwrap()? else {
|
Ok(response) => response,
|
||||||
|
Err(WebDriverError { error, .. }) => return Err(error),
|
||||||
|
};
|
||||||
|
let Ok(Some(point)) = response else {
|
||||||
return Err(ErrorStatus::UnknownError);
|
return Err(ErrorStatus::UnknownError);
|
||||||
};
|
};
|
||||||
point
|
point
|
||||||
|
@ -645,19 +648,14 @@ impl Handler {
|
||||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
match receiver.recv() {
|
let viewport_size = match wait_for_script_response(receiver) {
|
||||||
Ok(viewport_size) => {
|
Ok(response) => response,
|
||||||
if x < 0 ||
|
Err(WebDriverError { error, .. }) => return Err(error),
|
||||||
x as f32 > viewport_size.width ||
|
};
|
||||||
y < 0 ||
|
if x < 0 || x as f32 > viewport_size.width || y < 0 || y as f32 > viewport_size.height {
|
||||||
y as f32 > viewport_size.height
|
|
||||||
{
|
|
||||||
Err(ErrorStatus::MoveTargetOutOfBounds)
|
Err(ErrorStatus::MoveTargetOutOfBounds)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(_) => Err(ErrorStatus::UnknownError),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue