Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / serviceworker / registration-service-worker-attributes.html
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script>
5 <script>
6 async_test(function(t) {
7     var scope = 'scope/installing-waiting-active-after-registration';
8     var worker_url = 'resources/empty-worker.js';
9     var expected_url = normalizeURL(worker_url);
10
11     service_worker_unregister_and_register(t, worker_url, scope)
12       .then(function(r) {
13           registration = r;
14           assert_equals(registration.installing.scriptURL, expected_url,
15                         'installing before updatefound');
16           assert_equals(registration.waiting, null,
17                         'waiting before updatefound');
18           assert_equals(registration.active, null,
19                         'active before updatefound');
20           return wait_for_update(t, registration);
21         })
22       .then(function(worker) {
23           assert_equals(registration.installing.scriptURL, expected_url,
24                         'installing after updatefound');
25           assert_equals(registration.waiting, null,
26                         'waiting after updatefound');
27           assert_equals(registration.active, null,
28                         'active after updatefound');
29           return wait_for_state(t, registration.installing, 'installed');
30         })
31       .then(function() {
32           assert_equals(registration.installing, null,
33                         'installing after installed');
34           assert_equals(registration.waiting.scriptURL, expected_url,
35                         'waiting after installed');
36           assert_equals(registration.active, null,
37                         'active after installed');
38           return wait_for_state(t, registration.waiting, 'activated');
39         })
40       .then(function() {
41           assert_equals(registration.installing, null,
42                         'installing after activated');
43           assert_equals(registration.waiting, null,
44                         'waiting after activated');
45           assert_equals(registration.active.scriptURL, expected_url,
46                         'active after activated');
47           return Promise.all([
48               wait_for_state(t, registration.active, 'redundant'),
49               registration.unregister()
50             ]);
51         })
52       .then(function() {
53           assert_equals(registration.installing, null,
54                         'installing after redundant');
55           assert_equals(registration.waiting, null,
56                         'waiting after redundant');
57           assert_equals(registration.active.scriptURL, expected_url,
58                         'active after redundant');
59           t.done();
60         })
61       .catch(unreached_rejection(t));
62   }, 'installing/waiting/active after registration');
63 </script>