2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharnessreport.js"></script>
4 <script src=
"resources/test-helpers.js"></script>
6 async_test(function(t
) {
7 var scope
= 'resources/scope/installing-waiting-active-after-registration';
8 var worker_url
= 'resources/empty-worker.js';
9 var expected_url
= normalizeURL(worker_url
);
11 service_worker_unregister_and_register(t
, worker_url
, scope
)
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
);
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');
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');
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');
48 wait_for_state(t
, registration
.active
, 'redundant'),
49 registration
.unregister()
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');
61 .catch(unreached_rejection(t
));
62 }, 'installing/waiting/active after registration');