diff --git a/components/script/dom/serviceworkerregistration.rs b/components/script/dom/serviceworkerregistration.rs index e274e5a6e51..c3a08e514e4 100644 --- a/components/script/dom/serviceworkerregistration.rs +++ b/components/script/dom/serviceworkerregistration.rs @@ -4,7 +4,6 @@ use dom::bindings::codegen::Bindings::ServiceWorkerBinding::ServiceWorkerState; use dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::{ServiceWorkerRegistrationMethods, Wrap}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::USVString; @@ -50,17 +49,16 @@ impl ServiceWorkerRegistration { self.active.as_ref().unwrap() } - pub fn create_scope_things(global: GlobalRef, script_url: Url) -> ScopeThings { - let global_scope = global.as_global_scope(); + pub fn create_scope_things(global: &GlobalScope, script_url: Url) -> ScopeThings { let worker_load_origin = WorkerScriptLoadOrigin { referrer_url: None, referrer_policy: None, - pipeline_id: Some(global_scope.pipeline_id()) + pipeline_id: Some(global.pipeline_id()) }; - let worker_id = global_scope.get_next_worker_id(); - let devtools_chan = global_scope.devtools_chan().cloned(); - let init = prepare_workerscope_init(global_scope, None); + let worker_id = global.get_next_worker_id(); + let devtools_chan = global.devtools_chan().cloned(); + let init = prepare_workerscope_init(global, None); ScopeThings { script_url: script_url, init: init, diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 8699a56742b..582ebfdb153 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1449,10 +1449,9 @@ impl ScriptThread { None => return }; if let Some(context) = self.root_browsing_context().find(pipeline_id) { - let window = context.active_window(); - let global_ref = GlobalRef::Window(window.r()); let script_url = maybe_registration.get_installed().get_script_url(); - let scope_things = ServiceWorkerRegistration::create_scope_things(global_ref, script_url); + let scope_things = ServiceWorkerRegistration::create_scope_things( + context.active_window().upcast(), script_url); let _ = self.constellation_chan.send(ConstellationMsg::RegisterServiceWorker(scope_things, scope)); } else { warn!("Registration failed for {}", scope);