mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Ensure we get the post-redirect url
This commit is contained in:
parent
2a701cc339
commit
f44470ef52
6 changed files with 14 additions and 7 deletions
|
@ -914,10 +914,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
WebDriverCommandMsg::LoadUrl(pipeline_id, load_data, reply) => {
|
||||
self.load_url_for_webdriver(pipeline_id, load_data, reply);
|
||||
},
|
||||
WebDriverCommandMsg::GetUrl(pipeline_id, reply) => {
|
||||
let pipeline = self.pipeline(pipeline_id);
|
||||
reply.send(pipeline.url.clone()).unwrap();
|
||||
},
|
||||
WebDriverCommandMsg::Refresh(pipeline_id, reply) => {
|
||||
let load_data = {
|
||||
let pipeline = self.pipeline(pipeline_id);
|
||||
|
|
|
@ -336,7 +336,6 @@ impl MozBrowserEvent {
|
|||
#[derive(Deserialize, Serialize)]
|
||||
pub enum WebDriverCommandMsg {
|
||||
LoadUrl(PipelineId, LoadData, IpcSender<LoadStatus>),
|
||||
GetUrl(PipelineId, IpcSender<Url>),
|
||||
Refresh(PipelineId, IpcSender<LoadStatus>),
|
||||
ScriptCommand(PipelineId, WebDriverScriptCommand),
|
||||
TakeScreenshot(PipelineId, IpcSender<Option<Image>>)
|
||||
|
|
|
@ -6,6 +6,7 @@ use constellation_msg::{PipelineId, SubpageId};
|
|||
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use rustc_serialize::json::{Json, ToJson};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum WebDriverScriptCommand {
|
||||
|
@ -17,6 +18,7 @@ pub enum WebDriverScriptCommand {
|
|||
GetElementTagName(String, IpcSender<Result<String, ()>>),
|
||||
GetElementText(String, IpcSender<Result<String, ()>>),
|
||||
GetFrameId(WebDriverFrameId, IpcSender<Result<Option<(PipelineId, SubpageId)>, ()>>),
|
||||
GetUrl(IpcSender<Url>),
|
||||
GetTitle(IpcSender<String>)
|
||||
}
|
||||
|
||||
|
|
|
@ -873,6 +873,8 @@ impl ScriptTask {
|
|||
webdriver_handlers::handle_get_text(&page, pipeline_id, node_id, reply),
|
||||
WebDriverScriptCommand::GetFrameId(frame_id, reply) =>
|
||||
webdriver_handlers::handle_get_frame_id(&page, pipeline_id, frame_id, reply),
|
||||
WebDriverScriptCommand::GetUrl(reply) =>
|
||||
webdriver_handlers::handle_get_url(&page, pipeline_id, reply),
|
||||
WebDriverScriptCommand::GetTitle(reply) =>
|
||||
webdriver_handlers::handle_get_title(&page, pipeline_id, reply),
|
||||
WebDriverScriptCommand::ExecuteAsyncScript(script, reply) =>
|
||||
|
|
|
@ -24,6 +24,7 @@ use js::jsval::UndefinedValue;
|
|||
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use std::rc::Rc;
|
||||
use url::Url;
|
||||
|
||||
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Root<Node>> {
|
||||
let page = get_page(&*page, pipeline);
|
||||
|
@ -179,3 +180,10 @@ pub fn handle_get_name(page: &Rc<Page>,
|
|||
None => Err(())
|
||||
}).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_url(page: &Rc<Page>,
|
||||
_pipeline: PipelineId,
|
||||
reply: IpcSender<Url>) {
|
||||
let url = page.document().r().url();
|
||||
reply.send(url).unwrap();
|
||||
}
|
||||
|
|
|
@ -206,10 +206,10 @@ impl Handler {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
let ConstellationChan(ref const_chan) = self.constellation_chan;
|
||||
let cmd_msg = WebDriverCommandMsg::GetUrl(pipeline_id, sender);
|
||||
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id,
|
||||
WebDriverScriptCommand::GetUrl(sender));
|
||||
const_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
||||
|
||||
//Wait to get a load event
|
||||
let url = receiver.recv().unwrap();
|
||||
|
||||
Ok(WebDriverResponse::Generic(ValueResponse::new(url.serialize().to_json())))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue