Auto merge of #26943 - jdm:promise-incumbent, r=Manishearth

Fix panic on vimeo.com

The only time we end up enqueuing a promise reaction job with a null incumbent global argument is when SpiderMonkey does some weird stuff behind the scenes for its JS Debugger support (based on https://searchfox.org/mozilla-central/rev/2c1092dc68c63f7bad6da6a03c5883a5ab5ff2ca/js/src/builtin/Promise.cpp#3168). This commit works around that case and adds a regression test so we don't forget about that in the future.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #26930
- [x] There are tests for these changes
This commit is contained in:
bors-servo 2020-06-16 20:03:28 -04:00 committed by GitHub
commit 6d9b2eef29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View file

@ -205,7 +205,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