OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: Skip waiting using registration</title> | 2 <title>Service Worker: Skip waiting using registration</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/testharness-helpers.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="resources/test-helpers.sub.js"></script> |
6 <script> | 7 <script> |
7 | 8 |
8 promise_test(function(t) { | 9 promise_test(function(t) { |
9 var scope = 'resources/blank.html'; | 10 var scope = 'resources/blank.html'; |
10 var url1 = 'resources/empty.js'; | 11 var url1 = 'resources/empty.js'; |
11 var url2 = 'resources/skip-waiting-worker.js'; | 12 var url2 = 'resources/skip-waiting-worker.js'; |
12 var frame, frame_sw, sw_registration, oncontrollerchanged; | 13 var frame, frame_sw, sw_registration, oncontrollerchanged; |
13 var saw_controllerchanged = new Promise(function(resolve) { | 14 var saw_controllerchanged = new Promise(function(resolve) { |
14 oncontrollerchanged = function(e) { | 15 oncontrollerchanged = function(e) { |
15 assert_equals(e.type, 'controllerchange', | 16 assert_equals(e.type, 'controllerchange', |
(...skipping 21 matching lines...) Expand all Loading... |
37 frame_sw = f.contentWindow.navigator.serviceWorker; | 38 frame_sw = f.contentWindow.navigator.serviceWorker; |
38 assert_equals( | 39 assert_equals( |
39 frame_sw.controller.scriptURL, normalizeURL(url1), | 40 frame_sw.controller.scriptURL, normalizeURL(url1), |
40 'Document controller scriptURL should equal to the first one'); | 41 'Document controller scriptURL should equal to the first one'); |
41 frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged); | 42 frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged); |
42 return navigator.serviceWorker.register(url2, {scope: scope}); | 43 return navigator.serviceWorker.register(url2, {scope: scope}); |
43 }) | 44 }) |
44 .then(function(registration) { | 45 .then(function(registration) { |
45 sw_registration = registration; | 46 sw_registration = registration; |
46 add_completion_callback(function() { | 47 add_completion_callback(function() { |
| 48 frame.remove(); |
47 registration.unregister(); | 49 registration.unregister(); |
48 }); | 50 }); |
49 return saw_controllerchanged; | 51 return saw_controllerchanged; |
50 }) | 52 }) |
51 .then(function() { | 53 .then(function() { |
52 frame.remove(); | |
53 assert_not_equals(sw_registration.active, null, | 54 assert_not_equals(sw_registration.active, null, |
54 'Registration active worker should not be null'); | 55 'Registration active worker should not be null'); |
55 fetch_tests_from_worker(sw_registration.active); | 56 fetch_tests_from_worker(sw_registration.active); |
56 }); | 57 }); |
57 }, 'Test skipWaiting while a client is using the registration'); | 58 }, 'Test skipWaiting while a client is using the registration'); |
58 | 59 |
59 </script> | 60 </script> |
OLD | NEW |