mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fix already borrowed error in webdriver
This commit is contained in:
parent
347d8bdf72
commit
1dda774518
2 changed files with 46 additions and 41 deletions
|
@ -23,6 +23,7 @@ use crate::dom::htmliframeelement::HTMLIFrameElement;
|
|||
use crate::dom::htmlinputelement::HTMLInputElement;
|
||||
use crate::dom::htmloptionelement::HTMLOptionElement;
|
||||
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_thread::Documents;
|
||||
use cookie::Cookie;
|
||||
use euclid::{Point2D, Rect, Size2D};
|
||||
|
@ -87,53 +88,51 @@ pub unsafe fn jsval_to_webdriver(cx: *mut JSContext, val: HandleValue) -> WebDri
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn handle_execute_script(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
window: Option<DomRoot<Window>>,
|
||||
eval: String,
|
||||
reply: IpcSender<WebDriverJSResult>,
|
||||
) {
|
||||
let window = match documents.find_window(pipeline) {
|
||||
Some(window) => window,
|
||||
match window {
|
||||
Some(window) => {
|
||||
let result = unsafe {
|
||||
let cx = window.get_cx();
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
window
|
||||
.upcast::<GlobalScope>()
|
||||
.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
jsval_to_webdriver(cx, rval.handle())
|
||||
};
|
||||
|
||||
reply.send(result).unwrap();
|
||||
},
|
||||
None => {
|
||||
return reply
|
||||
reply
|
||||
.send(Err(WebDriverJSError::BrowsingContextNotFound))
|
||||
.unwrap();
|
||||
},
|
||||
};
|
||||
|
||||
let result = unsafe {
|
||||
let cx = window.get_cx();
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
window
|
||||
.upcast::<GlobalScope>()
|
||||
.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(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
window: Option<DomRoot<Window>>,
|
||||
eval: String,
|
||||
reply: IpcSender<WebDriverJSResult>,
|
||||
) {
|
||||
let window = match documents.find_window(pipeline) {
|
||||
Some(window) => window,
|
||||
match window {
|
||||
Some(window) => {
|
||||
let cx = window.get_cx();
|
||||
window.set_webdriver_script_chan(Some(reply));
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
window
|
||||
.upcast::<GlobalScope>()
|
||||
.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
},
|
||||
None => {
|
||||
return reply
|
||||
reply
|
||||
.send(Err(WebDriverJSError::BrowsingContextNotFound))
|
||||
.unwrap();
|
||||
},
|
||||
};
|
||||
|
||||
let cx = window.get_cx();
|
||||
window.set_webdriver_script_chan(Some(reply));
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
window
|
||||
.upcast::<GlobalScope>()
|
||||
.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_get_browsing_context_id(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue