mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
webdriver: Move navigation commands to servoshell (#37665)
- Move webdriver `GetViewportSize`, `LoadURL` and `Refresh` to servoshell. - Add `GoBack` and `GoFoward` commands. Testing: Need to finish moving webdriver to servoshell then evaluate again Fixes: https://github.com/servo/servo/issues/37370 Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
0346a62214
commit
62a009399f
5 changed files with 61 additions and 98 deletions
|
@ -20,7 +20,7 @@ use std::{env, fmt, process, thread};
|
|||
use base::id::{BrowsingContextId, WebViewId};
|
||||
use base64::Engine;
|
||||
use capabilities::ServoCapabilities;
|
||||
use constellation_traits::{EmbedderToConstellationMessage, TraversalDirection};
|
||||
use constellation_traits::EmbedderToConstellationMessage;
|
||||
use cookie::{CookieBuilder, Expiration};
|
||||
use crossbeam_channel::{Receiver, Sender, after, select, unbounded};
|
||||
use embedder_traits::{
|
||||
|
@ -767,9 +767,7 @@ impl Handler {
|
|||
|
||||
let cmd_msg =
|
||||
WebDriverCommandMsg::LoadUrl(webview_id, url, self.load_status_sender.clone());
|
||||
self.constellation_chan
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
self.send_message_to_embedder(cmd_msg)?;
|
||||
|
||||
self.wait_for_load()
|
||||
}
|
||||
|
@ -902,9 +900,8 @@ impl Handler {
|
|||
// Step 1. If session's current top-level browsing context is no longer open,
|
||||
// return error with error code no such window.
|
||||
self.verify_top_level_browsing_context_is_open(webview_id)?;
|
||||
let direction = TraversalDirection::Back(1);
|
||||
let msg = EmbedderToConstellationMessage::TraverseHistory(webview_id, direction);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
|
||||
self.send_message_to_embedder(WebDriverCommandMsg::GoBack(webview_id))?;
|
||||
Ok(WebDriverResponse::Void)
|
||||
}
|
||||
|
||||
|
@ -913,9 +910,8 @@ impl Handler {
|
|||
// Step 1. If session's current top-level browsing context is no longer open,
|
||||
// return error with error code no such window.
|
||||
self.verify_top_level_browsing_context_is_open(webview_id)?;
|
||||
let direction = TraversalDirection::Forward(1);
|
||||
let msg = EmbedderToConstellationMessage::TraverseHistory(webview_id, direction);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
|
||||
self.send_message_to_embedder(WebDriverCommandMsg::GoForward(webview_id))?;
|
||||
Ok(WebDriverResponse::Void)
|
||||
}
|
||||
|
||||
|
@ -926,9 +922,7 @@ impl Handler {
|
|||
self.verify_top_level_browsing_context_is_open(webview_id)?;
|
||||
|
||||
let cmd_msg = WebDriverCommandMsg::Refresh(webview_id, self.load_status_sender.clone());
|
||||
self.constellation_chan
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
self.send_message_to_embedder(cmd_msg)?;
|
||||
|
||||
self.wait_for_load()
|
||||
}
|
||||
|
@ -2354,6 +2348,8 @@ fn webdriver_value_to_js_argument(v: &Value) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: This waits for not only the script response
|
||||
// need to make another name
|
||||
fn wait_for_script_response<T>(receiver: IpcReceiver<T>) -> Result<T, WebDriverError>
|
||||
where
|
||||
T: for<'de> Deserialize<'de> + Serialize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue