diff options
author | Rahul Sharma <rsconceptx@gmail.com> | 2016-04-15 17:40:45 +0530 |
---|---|---|
committer | Rahul Sharma <rsconceptx@gmail.com> | 2016-06-02 04:09:39 +0530 |
commit | 15a2064c0d7b468724b43d1cb6157d506ad19093 (patch) | |
tree | 5592c36fe2e7e0deb372117b1396d6e9603e111e /components/script/dom/navigator.rs | |
parent | 0594d58bc8e074facacb26b6d8d3fab2083771d0 (diff) | |
download | servo-15a2064c0d7b468724b43d1cb6157d506ad19093.tar.gz servo-15a2064c0d7b468724b43d1cb6157d506ad19093.zip |
implement related sw interface and register method
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())) + } } |