diff options
Diffstat (limited to 'components/script/dom/navigator.rs')
-rw-r--r-- | components/script/dom/navigator.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 8a17b2dbc17..75bd2c13c23 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -12,6 +12,7 @@ use dom::bluetooth::Bluetooth; use dom::mimetypearray::MimeTypeArray; use dom::navigatorinfo; use dom::pluginarray::PluginArray; +use dom::serviceworkercontainer::ServiceWorkerContainer; use dom::window::Window; #[dom_struct] @@ -20,6 +21,7 @@ pub struct Navigator { bluetooth: MutNullableHeap<JS<Bluetooth>>, plugins: MutNullableHeap<JS<PluginArray>>, mime_types: MutNullableHeap<JS<MimeTypeArray>>, + serviceWorker: MutNullableHeap<JS<ServiceWorkerContainer>>, } impl Navigator { @@ -29,6 +31,7 @@ impl Navigator { bluetooth: Default::default(), plugins: Default::default(), mime_types: Default::default(), + serviceWorker: Default::default(), } } @@ -99,4 +102,9 @@ impl NavigatorMethods for Navigator { fn JavaEnabled(&self) -> bool { false } + + // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#navigator-service-worker-attribute + fn ServiceWorker(&self) -> Root<ServiceWorkerContainer> { + self.serviceWorker.or_init(|| ServiceWorkerContainer::new(self.global().r())) + } } |