implement related sw interface and register method

This commit is contained in:
Rahul Sharma 2016-04-15 17:40:45 +05:30
parent 0594d58bc8
commit 15a2064c0d
33 changed files with 1285 additions and 217 deletions

View file

@ -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()))
}
}