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 diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 47ba62031be..18daac8b040 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -14215,6 +14215,13 @@ {} ] ], + "promise-no-incumbent.html": [ + "a5458d096b5da8d6619ef5c553f232261887f45a", + [ + null, + {} + ] + ], "promise.html": [ "5925047287175f291c07ee88075359ed92a86e6a", [ diff --git a/tests/wpt/mozilla/tests/mozilla/promise-no-incumbent.html b/tests/wpt/mozilla/tests/mozilla/promise-no-incumbent.html new file mode 100644 index 00000000000..a5458d096b5 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/promise-no-incumbent.html @@ -0,0 +1,12 @@ + +
+ + +