aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/webdriver_handlers.rs
diff options
context:
space:
mode:
authorDavid Raifaizen <d-raif@hotmail.com>2016-07-25 20:34:47 -0400
committerDavid Raifaizen <d-raif@hotmail.com>2016-07-25 22:28:04 -0400
commit2475dc1d21343e7cdda8b77be87be4484ee0f15a (patch)
treeb1a1230b9bfd48d1e85598286061c0d48ed4e755 /components/script/webdriver_handlers.rs
parent4b78b9adab916cc4fdde6248e785030b79f406da (diff)
downloadservo-2475dc1d21343e7cdda8b77be87be4484ee0f15a.tar.gz
servo-2475dc1d21343e7cdda8b77be87be4484ee0f15a.zip
Removed some sources of panic from script thread and devtools, using Option values instead to indicate when a pipeline context is missing where appropriate. Additionally, removed erroneous method get_browsing_context.
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r--components/script/webdriver_handlers.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index 2711cfb1225..74a754c36ce 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -34,7 +34,6 @@ use msg::constellation_msg::PipelineId;
use net_traits::CookieSource::{HTTP, NonHTTP};
use net_traits::CoreResourceMsg::{GetCookiesDataForUrl, SetCookiesForUrlWithData};
use net_traits::IpcSend;
-use script_thread::get_browsing_context;
use script_traits::webdriver_msg::WebDriverCookieError;
use script_traits::webdriver_msg::{WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue};
use url::Url;
@@ -43,7 +42,11 @@ fn find_node_by_unique_id(context: &BrowsingContext,
pipeline: PipelineId,
node_id: String)
-> Option<Root<Node>> {
- let context = get_browsing_context(&context, pipeline);
+ let context = match context.find(pipeline) {
+ Some(context) => context,
+ None => return None
+ };
+
let document = context.active_document();
document.upcast::<Node>().traverse_preorder().find(|candidate| candidate.unique_id() == node_id)
}
@@ -72,7 +75,11 @@ pub fn handle_execute_script(context: &BrowsingContext,
pipeline: PipelineId,
eval: String,
reply: IpcSender<WebDriverJSResult>) {
- let context = get_browsing_context(&context, pipeline);
+ let context = match context.find(pipeline) {
+ Some(context) => context,
+ None => return reply.send(Err(WebDriverJSError::BrowsingContextNotFound)).unwrap()
+ };
+
let window = context.active_window();
let result = unsafe {
let cx = window.get_cx();
@@ -87,7 +94,11 @@ pub fn handle_execute_async_script(context: &BrowsingContext,
pipeline: PipelineId,
eval: String,
reply: IpcSender<WebDriverJSResult>) {
- let context = get_browsing_context(&context, pipeline);
+ let context = match context.find(pipeline) {
+ Some(context) => context,
+ None => return reply.send(Err(WebDriverJSError::BrowsingContextNotFound)).unwrap()
+ };
+
let window = context.active_window();
let cx = window.get_cx();
window.set_webdriver_script_chan(Some(reply));