OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <title>Service Workers: navigator.serviceWorker</title> |
| 4 <head> |
| 5 <link rel="help" href="https://w3c.github.io/ServiceWorker/#navigator-se
rvice-worker"> |
| 6 <script src="/resources/testharness.js"></script> |
| 7 <script src="/resources/testharnessreport.js"></script> |
| 8 |
| 9 <script src=/resources/WebIDLParser.js></script> |
| 10 <script src=/resources/idlharness.js></script> |
| 11 |
| 12 </head> |
| 13 <body> |
| 14 |
| 15 <!-- |
| 16 The `serviceWorker` attribute of the [Navigator][1] interface must return an |
| 17 instance of the `ServiceWorkerContainer` interface, which provides access to |
| 18 registration, removal, upgrade, and communication with Service Workers that are |
| 19 (or will become) active for the current document. Communication with these |
| 20 workers is provided via standard [HTML5 messaging APIs][2], and [messaging |
| 21 occurs as per usual with Web Workers][3]. |
| 22 --> |
| 23 <script type=text/plain id="idl_0"> |
| 24 partial interface Navigator { |
| 25 readonly attribute ServiceWorkerContainer serviceWorker; |
| 26 }; |
| 27 |
| 28 interface ServiceWorkerContainer : EventTarget { |
| 29 [Unforgeable] readonly attribute ServiceWorker? installing; |
| 30 [Unforgeable] readonly attribute ServiceWorker? waiting; |
| 31 [Unforgeable] readonly attribute ServiceWorker? active; |
| 32 [Unforgeable] readonly attribute ServiceWorker? controller; |
| 33 readonly attribute Promise<ServiceWorker> ready; |
| 34 |
| 35 Promise<sequence<ServiceWorker>?> getAll(); |
| 36 Promise<ServiceWorker> register(DOMString url, optional RegistrationOptionList
options); |
| 37 Promise<any> unregister(DOMString? scope); |
| 38 |
| 39 // events |
| 40 attribute EventHandler onupdatefound; |
| 41 attribute EventHandler oncontrollerchange; |
| 42 attribute EventHandler onreloadpage; |
| 43 attribute EventHandler onerror; |
| 44 }; |
| 45 |
| 46 dictionary RegistrationOptionList { |
| 47 DOMString scope = "/*"; |
| 48 }; |
| 49 |
| 50 interface ReloadPageEvent : Event { |
| 51 void waitUntil(Promise<any> f); |
| 52 }; |
| 53 </script> |
| 54 |
| 55 <!-- |
| 56 [1]: http://goo.gl/I7WAhg |
| 57 [2]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.h
tml |
| 58 [3]: http://www.w3.org/TR/workers/#dom-worker-postmessage |
| 59 --> |
| 60 |
| 61 |
| 62 <script type=text/plain id="untested_idls"> |
| 63 interface ServiceWorker {}; |
| 64 interface EventHandler {}; |
| 65 interface EventTarget {}; |
| 66 interface Event {}; |
| 67 </pre> |
| 68 |
| 69 <script> |
| 70 var idl_array = new IdlArray(); |
| 71 idl_array.add_untested_idls(document.getElementById("untested_idls").tex
tContent); |
| 72 idl_array.add_idls(document.getElementById("idl_0").textContent); |
| 73 idl_array.add_objects({ |
| 74 Navigator: ["throw new Error ('No object defined for the Navigator i
nterface')"], |
| 75 ServiceWorkerContainer: ["throw new Error ('No object defined for th
e ServiceWorkerContainer interface')"], |
| 76 RegistrationOptionList: ["throw new Error ('No object defined for th
e RegistrationOptionList dictionary')"], |
| 77 ReloadPageEvent: ["throw new Error ('No object defined for the Reloa
dPageEvent interface')"] |
| 78 }); |
| 79 idl_array.test(); |
| 80 </script> |
| 81 |
| 82 </body> |
| 83 </html> |
| 84 |
OLD | NEW |