diff options
author | CYBAI <cyb.ai.815@gmail.com> | 2020-01-24 12:43:49 +0900 |
---|---|---|
committer | CYBAI <cyb.ai.815@gmail.com> | 2020-02-16 09:55:10 +0900 |
commit | 403ffcf1eb5c659626f70dec72f76aaf7782986d (patch) | |
tree | df2f2e06ed557fcaac17862791a6c1db1f8a7b57 /components/script/dom/testbinding.rs | |
parent | 795dab71fffe98434308732e4cb8ee682f28e465 (diff) | |
download | servo-403ffcf1eb5c659626f70dec72f76aaf7782986d.tar.gz servo-403ffcf1eb5c659626f70dec72f76aaf7782986d.zip |
Always pass InRealm to GlobalScope::from_context to avoid getting null global
Diffstat (limited to 'components/script/dom/testbinding.rs')
-rw-r--r-- | components/script/dom/testbinding.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index c77b7cd994d..f0dcd1b26c7 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -48,7 +48,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; use crate::dom::promisenativehandler::{Callback, PromiseNativeHandler}; use crate::dom::url::URL; -use crate::realms::InRealm; +use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; use crate::timers::OneshotTimerCallback; use dom_struct::dom_struct; @@ -1015,7 +1015,10 @@ impl TestBindingMethods for TestBinding { impl Callback for SimpleHandler { #[allow(unsafe_code)] fn callback(&self, cx: *mut JSContext, v: HandleValue) { - let global = unsafe { GlobalScope::from_context(cx) }; + let global = unsafe { + let in_realm_proof = AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx)); + GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof)) + }; let _ = self.handler.Call_(&*global, v, ExceptionHandling::Report); } } |