Add a permanent root to WebIDL callbacks, ensuring they are always safe to store.

This commit is contained in:
Josh Matthews 2017-01-12 18:05:54 -05:00
parent 550df86ac8
commit 3f35c3eee2
4 changed files with 75 additions and 28 deletions

View file

@ -176,7 +176,7 @@ impl PromiseJobQueue {
/// promise job queue, and enqueues a runnable to perform a microtask checkpoint if one
/// is not already pending.
#[allow(unsafe_code)]
unsafe extern "C" fn enqueue_job(_cx: *mut JSContext,
unsafe extern "C" fn enqueue_job(cx: *mut JSContext,
job: HandleObject,
_allocation_site: HandleObject,
_data: *mut c_void) -> bool {
@ -184,7 +184,7 @@ unsafe extern "C" fn enqueue_job(_cx: *mut JSContext,
let global = GlobalScope::from_object(job.get());
let pipeline = global.pipeline_id();
global.enqueue_promise_job(EnqueuedPromiseCallback {
callback: PromiseJobCallback::new(job.get()),
callback: PromiseJobCallback::new(cx, job.get()),
pipeline: pipeline,
});
true