OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: Interfaces</title> | 2 <title>Service Worker: Interfaces</title> |
3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="resources/interfaces.js"></script> | 5 <script src="resources/interfaces.js"></script> |
6 <script src="resources/test-helpers.js"></script> | 6 <script src="resources/test-helpers.js"></script> |
7 <script> | 7 <script> |
8 | 8 |
9 test(function() { | 9 test(function() { |
10 verify_interface( | 10 verify_interface( |
11 'ServiceWorkerContainer', navigator.serviceWorker, | 11 'ServiceWorkerContainer', navigator.serviceWorker, |
12 { | 12 { |
13 register: 'function', | 13 register: 'function', |
14 getRegistration: 'function' | 14 getRegistration: 'function' |
15 }); | 15 }); |
16 }, 'Interfaces and attributes of ServiceWorkerContainer'); | 16 }, 'Interfaces and attributes of ServiceWorkerContainer'); |
17 | 17 |
18 async_test(function(t) { | 18 async_test(function(t) { |
19 var EVENT_HANDLER = 'object'; | 19 var EVENT_HANDLER = 'object'; |
20 var scope = 'resources/scope/interfaces-and-attributes'; | 20 var scope = 'resources/scope/interfaces-and-attributes'; |
21 var registration; | |
22 | 21 |
23 service_worker_unregister_and_register( | 22 service_worker_unregister_and_register( |
24 t, 'resources/empty-worker.js', scope) | 23 t, 'resources/empty-worker.js', scope) |
25 .then(function(r) { | 24 .then(function(registration) { |
26 registration = r; | |
27 verify_interface( | 25 verify_interface( |
28 'ServiceWorkerRegistration', registration, | 26 'ServiceWorkerRegistration', registration, |
29 { | 27 { |
30 installing: 'object', | 28 installing: 'object', |
31 waiting: 'object', | 29 waiting: 'object', |
32 active: 'object', | 30 active: 'object', |
33 scope: 'string', | 31 scope: 'string', |
34 unregister: 'function', | 32 unregister: 'function', |
35 onupdatefound: EVENT_HANDLER | 33 onupdatefound: EVENT_HANDLER |
36 }); | 34 }); |
37 return wait_for_update(t, registration); | |
38 }) | |
39 .then(function(worker) { | |
40 verify_interface( | 35 verify_interface( |
41 'ServiceWorker', worker, | 36 'ServiceWorker', registration.installing, |
42 { | 37 { |
43 scriptURL: 'string', | 38 scriptURL: 'string', |
44 state: 'string', | 39 state: 'string', |
45 terminate: 'function', | 40 terminate: 'function', |
46 onstatechange: EVENT_HANDLER | 41 onstatechange: EVENT_HANDLER |
47 }); | 42 }); |
48 return registration.unregister(); | 43 return registration.unregister(); |
49 }) | 44 }) |
50 .then(function() { | 45 .then(function() { |
51 t.done(); | 46 t.done(); |
52 }) | 47 }) |
53 .catch(unreached_rejection(t)); | 48 .catch(unreached_rejection(t)); |
54 }, 'Interfaces and attributes of ServiceWorker'); | 49 }, 'Interfaces and attributes of ServiceWorker'); |
55 | 50 |
56 service_worker_test( | 51 service_worker_test( |
57 'resources/interfaces-worker.js', | 52 'resources/interfaces-worker.js', |
58 'Interfaces and attributes in ServiceWorkerGlobalScope'); | 53 'Interfaces and attributes in ServiceWorkerGlobalScope'); |
59 | 54 |
60 </script> | 55 </script> |
OLD | NEW |