mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add support for the Get URL WebDriver command.
This commit is contained in:
parent
2f4bdc6ad6
commit
9eade19897
3 changed files with 21 additions and 0 deletions
|
@ -917,6 +917,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
self.webdriver.load_channel = Some((id, reply));
|
||||
}
|
||||
},
|
||||
WebDriverCommandMsg::GetUrl(pipeline_id, reply) => {
|
||||
let pipeline = self.pipeline(pipeline_id);
|
||||
reply.send(pipeline.url.clone()).unwrap();
|
||||
}
|
||||
WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd) => {
|
||||
let pipeline = self.pipeline(pipeline_id);
|
||||
let control_msg = ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, cmd);
|
||||
|
|
|
@ -336,6 +336,7 @@ impl MozBrowserEvent {
|
|||
#[derive(Deserialize, Serialize)]
|
||||
pub enum WebDriverCommandMsg {
|
||||
LoadUrl(PipelineId, LoadData, IpcSender<LoadStatus>),
|
||||
GetUrl(PipelineId, IpcSender<Url>),
|
||||
ScriptCommand(PipelineId, WebDriverScriptCommand),
|
||||
TakeScreenshot(PipelineId, IpcSender<Option<Image>>)
|
||||
}
|
||||
|
|
|
@ -191,6 +191,21 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_get_current_url(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let pipeline_id = try!(self.get_root_pipeline());
|
||||
|
||||
let (sender, reciever) = channel();
|
||||
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
let cmd_msg = WebDriverCommandMsg::GetUrl(pipeline_id, sender);
|
||||
const_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
||||
|
||||
//Wait to get a load event
|
||||
let url = reciever.recv().unwrap();
|
||||
|
||||
Ok(WebDriverResponse::Generic(ValueResponse::new(url.serialize().to_json())))
|
||||
}
|
||||
|
||||
fn handle_go_back(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
const_chan.send(ConstellationMsg::Navigate(None, NavigationDirection::Back)).unwrap();
|
||||
|
@ -489,6 +504,7 @@ impl WebDriverHandler for Handler {
|
|||
match msg.command {
|
||||
WebDriverCommand::NewSession => self.handle_new_session(),
|
||||
WebDriverCommand::Get(ref parameters) => self.handle_get(parameters),
|
||||
WebDriverCommand::GetCurrentUrl => self.handle_get_current_url(),
|
||||
WebDriverCommand::GoBack => self.handle_go_back(),
|
||||
WebDriverCommand::GoForward => self.handle_go_forward(),
|
||||
WebDriverCommand::GetTitle => self.handle_get_title(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue