mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Always pass InRealm to GlobalScope::from_context to avoid getting null global
This commit is contained in:
parent
795dab71ff
commit
403ffcf1eb
16 changed files with 79 additions and 61 deletions
|
@ -22,7 +22,7 @@ use crate::dom::messageevent::MessageEvent;
|
|||
use crate::dom::worker::TrustedWorkerAddress;
|
||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||
use crate::fetch::load_whole_resource;
|
||||
use crate::realms::enter_realm;
|
||||
use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
|
||||
use crate::script_runtime::{
|
||||
new_rt_and_cx, CommonScriptMsg, JSContext as SafeJSContext, Runtime, ScriptChan,
|
||||
};
|
||||
|
@ -447,8 +447,10 @@ impl ServiceWorkerGlobalScope {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
|
||||
let worker = DomRoot::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
|
||||
.expect("global is not a worker scope");
|
||||
let in_realm_proof = AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx));
|
||||
let global = GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof));
|
||||
let worker =
|
||||
DomRoot::downcast::<WorkerGlobalScope>(global).expect("global is not a worker scope");
|
||||
assert!(worker.is::<ServiceWorkerGlobalScope>());
|
||||
|
||||
// A false response causes the script to terminate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue