OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Service Worker: Skip waiting</title> | |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="resources/test-helpers.js"></script> | |
6 <script> | |
7 | |
8 promise_test(function(t) { | |
9 var scope = 'resources/blank.html'; | |
10 var url1 = 'resources/empty.js'; | |
11 var url2 = 'resources/skip-waiting-worker.js'; | |
12 var iframeContainer, onControllerChanged, worker; | |
falken
2014/12/01 02:28:48
nit: variables should be snake_case (same with oth
xiang
2014/12/01 07:13:44
Done.
| |
13 var controllerchanged = new Promise(function(resolve) { | |
14 onControllerChanged = function() { | |
15 assert_equals( | |
16 iframeContainer.controller.scriptURL, normalizeURL(url2), | |
17 'Controller scriptURL should change to the second one'); | |
18 resolve(); | |
19 }; | |
20 }); | |
21 return service_worker_unregister_and_register(t, url1, scope) | |
22 .then(function(registration) { | |
23 return wait_for_update(t, registration); | |
24 }) | |
25 .then(function(sw) { | |
26 return wait_for_state(t, sw, 'activated'); | |
27 }) | |
28 .then(function() { | |
29 return with_iframe(scope); | |
falken
2014/12/01 02:28:48
nit: please remove this iframe when done, as per s
xiang
2014/12/01 07:13:44
Done.
| |
30 }) | |
31 .then(function(frame) { | |
32 iframeContainer = frame.contentWindow.navigator.serviceWorker; | |
33 assert_equals( | |
34 iframeContainer.controller.scriptURL, normalizeURL(url1), | |
35 'Document controller scriptURL should equal to the first one'); | |
36 iframeContainer.oncontrollerchange = t.step_func(onControllerChanged); | |
37 return navigator.serviceWorker.register(url2, {scope : scope}); | |
38 }) | |
39 .then(function(registration) { | |
40 return Promise.all([controllerchanged, | |
41 fetch_tests_from_worker(registration.installing)]) ; | |
42 }) | |
43 .then(function() { | |
44 return service_worker_unregister_and_done(t, scope); | |
45 }) | |
46 }, 'Test skipWaiting while a client is using the registration'); | |
47 | |
48 </script> | |
OLD | NEW |