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