aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/webdriver_handlers.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-11-09 16:55:58 +0100
committerMs2ger <Ms2ger@gmail.com>2015-11-12 10:48:58 +0100
commit6d2ae85c1fc1c31c2dff9b9f9309943ed503e8c1 (patch)
tree0433f0f8a3a3ba8489108e0711c0e86ce443b0e0 /components/script/webdriver_handlers.rs
parentacb24e80b87d043173e2e8b2a31ef3fdb610767b (diff)
downloadservo-6d2ae85c1fc1c31c2dff9b9f9309943ed503e8c1.tar.gz
servo-6d2ae85c1fc1c31c2dff9b9f9309943ed503e8c1.zip
Use the conversion traits from js.
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r--components/script/webdriver_handlers.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index 3fcd6ef1d0c..9f095fab309 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -40,7 +40,8 @@ fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String
None
}
-pub fn jsval_to_webdriver(cx: *mut JSContext, val: HandleValue) -> WebDriverJSResult {
+#[allow(unsafe_code)]
+pub unsafe fn jsval_to_webdriver(cx: *mut JSContext, val: HandleValue) -> WebDriverJSResult {
if val.get().is_undefined() {
Ok(WebDriverJSValue::Undefined)
} else if val.get().is_boolean() {
@@ -58,17 +59,20 @@ pub fn jsval_to_webdriver(cx: *mut JSContext, val: HandleValue) -> WebDriverJSRe
}
}
+#[allow(unsafe_code)]
pub fn handle_execute_script(page: &Rc<Page>,
pipeline: PipelineId,
eval: String,
reply: IpcSender<WebDriverJSResult>) {
let page = get_page(&*page, pipeline);
let window = page.window();
- let cx = window.get_cx();
- let mut rval = RootedValue::new(cx, UndefinedValue());
- window.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
-
- reply.send(jsval_to_webdriver(cx, rval.handle())).unwrap();
+ let result = unsafe {
+ let cx = window.get_cx();
+ let mut rval = RootedValue::new(cx, UndefinedValue());
+ window.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
+ jsval_to_webdriver(cx, rval.handle())
+ };
+ reply.send(result).unwrap();
}
pub fn handle_execute_async_script(page: &Rc<Page>,