Make workers' interrupt_callback use GlobalScope

This commit is contained in:
Anthony Ramine 2016-10-05 10:07:53 +02:00
parent 907781eb75
commit 00e66a777a
2 changed files with 8 additions and 12 deletions

View file

@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::{ErrorInfo, ErrorResult};
use dom::bindings::global::{GlobalRef, global_root_from_context};
use dom::bindings::global::global_scope_from_context;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable;
@ -342,11 +342,9 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)]
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
let global = global_root_from_context(cx);
let worker = match global.r() {
GlobalRef::Worker(w) => w,
_ => panic!("global for worker is not a worker scope")
};
let worker =
Root::downcast::<WorkerGlobalScope>(global_scope_from_context(cx))
.expect("global is not a worker scope");
assert!(worker.is::<DedicatedWorkerGlobalScope>());
// A false response causes the script to terminate

View file

@ -8,7 +8,7 @@ use dom::abstractworker::WorkerScriptMsg;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods;
use dom::bindings::global::{GlobalRef, global_root_from_context};
use dom::bindings::global::global_scope_from_context;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable;
@ -310,11 +310,9 @@ impl ServiceWorkerGlobalScope {
#[allow(unsafe_code)]
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
let global = global_root_from_context(cx);
let worker = match global.r() {
GlobalRef::Worker(w) => w,
_ => panic!("global for worker is not a worker scope")
};
let worker =
Root::downcast::<WorkerGlobalScope>(global_scope_from_context(cx))
.expect("global is not a worker scope");
assert!(worker.is::<ServiceWorkerGlobalScope>());
// A false response causes the script to terminate