diff options
author | Josh Matthews <josh@joshmatthews.net> | 2020-06-16 17:21:18 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2020-06-16 17:21:18 -0400 |
commit | 2e4cee99710a5745adf2bd1df185adcd36e5104f (patch) | |
tree | ff2450e029913e86956f8188915591ea98dbbeb0 /components/script/script_runtime.rs | |
parent | a34d1573b6d79211f0efeafcc3ae4b505280cb54 (diff) | |
download | servo-2e4cee99710a5745adf2bd1df185adcd36e5104f.tar.gz servo-2e4cee99710a5745adf2bd1df185adcd36e5104f.zip |
dom: Avoid panic when SpiderMonkey enqueues dummy promise jobs.
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 4cf2055c649..a0a771941b2 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -206,7 +206,12 @@ unsafe extern "C" fn enqueue_promise_job( let mut result = false; wrap_panic(&mut || { let microtask_queue = &*(extra as *const MicrotaskQueue); - let global = GlobalScope::from_object(incumbent_global.get()); + let global = if !incumbent_global.is_null() { + GlobalScope::from_object(incumbent_global.get()) + } else { + let realm = AlreadyInRealm::assert_for_cx(cx); + GlobalScope::from_context(*cx, InRealm::in_realm(&realm)) + }; let pipeline = global.pipeline_id(); let interaction = if promise.get().is_null() { PromiseUserInputEventHandlingState::DontCare |