mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Use JSautoCompartment in devtools handle_evaluate_js to avoid segfault
fixes #11457
This commit is contained in:
parent
48257ef282
commit
283fc8dd25
1 changed files with 3 additions and 1 deletions
|
@ -21,7 +21,7 @@ use dom::element::Element;
|
|||
use dom::node::Node;
|
||||
use dom::window::Window;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{ObjectClassName, RootedObject, RootedValue};
|
||||
use js::jsapi::{JSAutoCompartment, ObjectClassName, RootedObject, RootedValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_thread::get_browsing_context;
|
||||
|
@ -35,6 +35,8 @@ pub fn handle_evaluate_js(global: &GlobalRef, eval: String, reply: IpcSender<Eva
|
|||
// global.get_cx() returns a valid `JSContext` pointer, so this is safe.
|
||||
let result = unsafe {
|
||||
let cx = global.get_cx();
|
||||
let globalhandle = global.reflector().get_jsobject();
|
||||
let _ac = JSAutoCompartment::new(cx, globalhandle.get());
|
||||
let mut rval = RootedValue::new(cx, UndefinedValue());
|
||||
global.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue