mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Various fixes for webdriver conformance tests (#35737)
* servodriver: Ensure capabilities is always a non-empty value. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Serialize arguments object like an array. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Ensure script body is always valid JS. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Use current browsing context when getting element center point. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Propagate errors received from getting element center point. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Ensure opening a new window records a unique window handle. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Don't panic if script execution fails. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Do not update the current browsing context after closing a window. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * webdriver: Use more precise check for arguments exotic object. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
bc4ee8b56a
commit
21ecfdd088
6 changed files with 46 additions and 32 deletions
|
@ -897,14 +897,13 @@ impl Handler {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
let webview_id = self.focus_webview_id()?;
|
||||
let browsing_context_id = BrowsingContextId::from(webview_id);
|
||||
let session = self.session_mut().unwrap();
|
||||
session.webview_id = webview_id;
|
||||
session.browsing_context_id = browsing_context_id;
|
||||
|
||||
Ok(WebDriverResponse::CloseWindow(CloseWindowResponse(
|
||||
session.window_handles.values().cloned().collect(),
|
||||
self.session()
|
||||
.unwrap()
|
||||
.window_handles
|
||||
.values()
|
||||
.cloned()
|
||||
.collect(),
|
||||
)))
|
||||
}
|
||||
|
||||
|
@ -924,17 +923,18 @@ impl Handler {
|
|||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
let mut handle = self.session.as_ref().unwrap().id.to_string();
|
||||
if let Ok(new_webview_id) = receiver.recv() {
|
||||
let session = self.session_mut().unwrap();
|
||||
session.webview_id = new_webview_id;
|
||||
session.browsing_context_id = BrowsingContextId::from(new_webview_id);
|
||||
let new_handle = Uuid::new_v4().to_string();
|
||||
handle = new_handle.clone();
|
||||
session.window_handles.insert(new_webview_id, new_handle);
|
||||
}
|
||||
|
||||
let _ = self.wait_for_load();
|
||||
|
||||
let handle = self.session.as_ref().unwrap().id.to_string();
|
||||
Ok(WebDriverResponse::NewWindow(NewWindowResponse {
|
||||
handle,
|
||||
typ: "tab".to_string(),
|
||||
|
@ -1458,7 +1458,7 @@ impl Handler {
|
|||
// new Function() and then takes the resulting function and executes
|
||||
// it with a vec of arguments.
|
||||
let script = format!(
|
||||
"(function() {{ {} }})({})",
|
||||
"(function() {{ {}\n }})({})",
|
||||
func_body,
|
||||
args_string.join(", ")
|
||||
);
|
||||
|
@ -1467,7 +1467,9 @@ impl Handler {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let command = WebDriverScriptCommand::ExecuteScript(script, sender);
|
||||
self.browsing_context_script_command(command)?;
|
||||
let result = receiver.recv().unwrap();
|
||||
let result = receiver
|
||||
.recv()
|
||||
.unwrap_or(Err(WebDriverJSError::BrowsingContextNotFound));
|
||||
self.postprocess_js_result(result)
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1493,7 @@ impl Handler {
|
|||
"".into()
|
||||
};
|
||||
let script = format!(
|
||||
"{} (function() {{ {} }})({})",
|
||||
"{} (function() {{ {}\n }})({})",
|
||||
timeout_script,
|
||||
func_body,
|
||||
args_string.join(", "),
|
||||
|
@ -1501,7 +1503,9 @@ impl Handler {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let command = WebDriverScriptCommand::ExecuteAsyncScript(script, sender);
|
||||
self.browsing_context_script_command(command)?;
|
||||
let result = receiver.recv().unwrap();
|
||||
let result = receiver
|
||||
.recv()
|
||||
.unwrap_or(Err(WebDriverJSError::BrowsingContextNotFound));
|
||||
self.postprocess_js_result(result)
|
||||
}
|
||||
|
||||
|
@ -1514,7 +1518,7 @@ impl Handler {
|
|||
serde_json::to_value(SendableWebDriverJSValue(value))?,
|
||||
))),
|
||||
Err(WebDriverJSError::BrowsingContextNotFound) => Err(WebDriverError::new(
|
||||
ErrorStatus::JavascriptError,
|
||||
ErrorStatus::NoSuchWindow,
|
||||
"Pipeline id not found in browsing context",
|
||||
)),
|
||||
Err(WebDriverJSError::JSError) => Err(WebDriverError::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue