Skip to content

Instantly share code, notes, and snippets.

@Xanewok
Created November 20, 2017 22:18
Show Gist options
  • Select an option

  • Save Xanewok/cd65f70bde06c4bc2a43948f2ea224ab to your computer and use it in GitHub Desktop.

Select an option

Save Xanewok/cd65f70bde06c4bc2a43948f2ea224ab to your computer and use it in GitHub Desktop.
#[test]
fn sequence_rooter() {
let rt = Runtime_::new().unwrap();
let cx = rt.cx();
JS_SetGCZeal(rt, 2, 1);
unsafe {
rooted!(in(cx) let global =
JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(),
OnNewGlobalHookOption::FireOnNewGlobalHook,
&CompartmentOptions::default())
);
{
let mut rval = UndefinedValue();
let handle = unsafe {
MutableHandle::from_marked_location(&mut rval)
};
//rooted!(in(cx) let mut rval = UndefinedValue());
assert!(rt.evaluate_script(global.handle(), "new Uint8Array([0, 2, 4])",
"test", 1, handle).is_ok());
::std::thread::sleep_ms(15000) ;
assert!(!rval.is_undefined());
assert!(rval.is_object());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment