mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use the conversion traits from js.
This commit is contained in:
parent
acb24e80b8
commit
6d2ae85c1f
15 changed files with 285 additions and 647 deletions
|
@ -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>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue