aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2017-05-22 09:40:17 -0500
committerAlan Jeffrey <ajeffrey@mozilla.com>2017-05-25 17:14:28 -0500
commit79743b5358c989da23c11c025509dd2c46dba48b (patch)
treef8a05416245fb9d5b56fbc6ac73fe56b20fddb4f /components/script
parent3c267d7fddd036f6bcc9ebf000ed37665cf7496d (diff)
downloadservo-79743b5358c989da23c11c025509dd2c46dba48b.tar.gz
servo-79743b5358c989da23c11c025509dd2c46dba48b.zip
Webdriver uses browsing context ids rather than pipeline ids.
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/history.rs16
-rw-r--r--components/script/dom/htmliframeelement.rs16
-rw-r--r--components/script/script_thread.rs4
-rw-r--r--components/script/webdriver_handlers.rs15
4 files changed, 24 insertions, 27 deletions
diff --git a/components/script/dom/history.rs b/components/script/dom/history.rs
index 5488d02d9bf..b9601d2ca1c 100644
--- a/components/script/dom/history.rs
+++ b/components/script/dom/history.rs
@@ -44,10 +44,9 @@ impl History {
if !self.window.Document().is_fully_active() {
return Err(Error::Security);
}
- let global_scope = self.window.upcast::<GlobalScope>();
- let pipeline = global_scope.pipeline_id();
- let msg = ConstellationMsg::TraverseHistory(Some(pipeline), direction);
- let _ = global_scope.constellation_chan().send(msg);
+ let top_level_browsing_context_id = self.window.window_proxy().top_level_browsing_context_id();
+ let msg = ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction);
+ let _ = self.window.upcast::<GlobalScope>().constellation_chan().send(msg);
Ok(())
}
}
@@ -58,13 +57,12 @@ impl HistoryMethods for History {
if !self.window.Document().is_fully_active() {
return Err(Error::Security);
}
- let global_scope = self.window.upcast::<GlobalScope>();
- let pipeline = global_scope.pipeline_id();
+ let top_level_browsing_context_id = self.window.window_proxy().top_level_browsing_context_id();
let (sender, recv) = ipc::channel().expect("Failed to create channel to send jsh length.");
- let msg = ConstellationMsg::JointSessionHistoryLength(pipeline, sender);
- let _ = global_scope.constellation_chan().send(msg);
+ let msg = ConstellationMsg::JointSessionHistoryLength(top_level_browsing_context_id, sender);
+ let _ = self.window.upcast::<GlobalScope>().constellation_chan().send(msg);
Ok(recv.recv().unwrap())
- }
+}
// https://html.spec.whatwg.org/multipage/#dom-history-go
fn Go(&self, delta: i32) -> ErrorResult {
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 00755213c75..3621bf3f4f9 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -498,7 +498,7 @@ unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
}
MozBrowserEvent::LocationChange(url, can_go_back, can_go_forward) => {
BrowserElementLocationChangeEventDetail {
- url: Some(DOMString::from(url)),
+ url: Some(DOMString::from(url.as_str())),
canGoBack: Some(can_go_back),
canGoForward: Some(can_go_forward),
}.to_jsval(cx, rval);
@@ -540,18 +540,16 @@ unsafe fn build_mozbrowser_event_detail(event: MozBrowserEvent,
pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> ErrorResult {
if iframe.Mozbrowser() {
- if iframe.upcast::<Node>().is_in_doc_with_browsing_context() {
+ if let Some(top_level_browsing_context_id) = iframe.top_level_browsing_context_id() {
let window = window_from_node(iframe);
- let msg = ConstellationMsg::TraverseHistory(iframe.pipeline_id(), direction);
+ let msg = ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction);
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
+ return Ok(());
}
-
- Ok(())
- } else {
- debug!(concat!("this frame is not mozbrowser: mozbrowser attribute missing, or not a top",
- "level window, or mozbrowser preference not set (use --pref dom.mozbrowser.enabled)"));
- Err(Error::NotSupported)
}
+ debug!(concat!("this frame is not mozbrowser: mozbrowser attribute missing, or not a top",
+ "level window, or mozbrowser preference not set (use --pref dom.mozbrowser.enabled)"));
+ Err(Error::NotSupported)
}
impl HTMLIFrameElementMethods for HTMLIFrameElement {
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index d66baaeda81..405616fedec 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1280,8 +1280,8 @@ impl ScriptThread {
webdriver_handlers::handle_get_rect(&*documents, pipeline_id, node_id, reply),
WebDriverScriptCommand::GetElementText(node_id, reply) =>
webdriver_handlers::handle_get_text(&*documents, pipeline_id, node_id, reply),
- WebDriverScriptCommand::GetPipelineId(browsing_context_id, reply) =>
- webdriver_handlers::handle_get_pipeline_id(&*documents, pipeline_id, browsing_context_id, reply),
+ WebDriverScriptCommand::GetBrowsingContextId(webdriver_frame_id, reply) =>
+ webdriver_handlers::handle_get_browsing_context_id(&*documents, pipeline_id, webdriver_frame_id, reply),
WebDriverScriptCommand::GetUrl(reply) =>
webdriver_handlers::handle_get_url(&*documents, pipeline_id, reply),
WebDriverScriptCommand::IsEnabled(element_id, reply) =>
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index 7bc31263c25..1aa2ad05dab 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -29,6 +29,7 @@ use hyper_serde::Serde;
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{HandleValue, JSContext};
use js::jsval::UndefinedValue;
+use msg::constellation_msg::BrowsingContextId;
use msg::constellation_msg::PipelineId;
use net_traits::CookieSource::{HTTP, NonHTTP};
use net_traits::CoreResourceMsg::{GetCookiesDataForUrl, SetCookieForUrl};
@@ -109,23 +110,23 @@ pub fn handle_execute_async_script(documents: &Documents,
window.upcast::<GlobalScope>().evaluate_js_on_global_with_result(&eval, rval.handle_mut());
}
-pub fn handle_get_pipeline_id(documents: &Documents,
- pipeline: PipelineId,
- webdriver_frame_id: WebDriverFrameId,
- reply: IpcSender<Result<Option<PipelineId>, ()>>) {
+pub fn handle_get_browsing_context_id(documents: &Documents,
+ pipeline: PipelineId,
+ webdriver_frame_id: WebDriverFrameId,
+ reply: IpcSender<Result<BrowsingContextId, ()>>) {
let result = match webdriver_frame_id {
WebDriverFrameId::Short(_) => {
// This isn't supported yet
- Ok(None)
+ Err(())
},
WebDriverFrameId::Element(x) => {
find_node_by_unique_id(documents, pipeline, x)
- .and_then(|node| node.downcast::<HTMLIFrameElement>().map(|elem| elem.pipeline_id()))
+ .and_then(|node| node.downcast::<HTMLIFrameElement>().and_then(|elem| elem.browsing_context_id()))
.ok_or(())
},
WebDriverFrameId::Parent => {
documents.find_window(pipeline)
- .map(|window| window.parent_info().map(|(parent_id, _)| parent_id))
+ .and_then(|window| window.window_proxy().parent().map(|parent| parent.browsing_context_id()))
.ok_or(())
}
};