Chromium Code Reviews| 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 frame, frame_sw, oncontrollerchanged; | |
| 13 var controllerchanged = new Promise(function(resolve) { | |
|
falken
2014/12/04 06:15:38
nit: pick either controllerchanged or saw_controll
xiang
2014/12/11 11:24:32
Done.
| |
| 14 oncontrollerchanged = function(e) { | |
| 15 assert_equals(e.type, 'controllerchange', | |
| 16 'Event name should be "controllerchange"'); | |
| 17 assert_true( | |
| 18 e.target instanceof frame.contentWindow.ServiceWorkerContainer, | |
| 19 'Event target should be a ServiceWorkerContainer'); | |
| 20 assert_equals(e.target.controller.state, 'activating', | |
| 21 'Controller state should be activating'); | |
| 22 assert_equals( | |
| 23 frame_sw.controller.scriptURL, normalizeURL(url2), | |
| 24 'Controller scriptURL should change to the second one'); | |
| 25 resolve(); | |
| 26 }; | |
| 27 }); | |
|
falken
2014/12/04 06:15:38
this needs +2 indent
xiang
2014/12/11 11:24:32
Done.
| |
| 28 return service_worker_unregister_and_register(t, url1, scope) | |
| 29 .then(function(registration) { | |
| 30 return wait_for_update(t, registration); }) | |
| 31 .then(function(sw) { | |
| 32 return wait_for_state(t, sw, 'activated'); | |
|
falken
2014/12/11 05:01:51
Lines 30-32 should be collapsed into simply: retur
xiang
2014/12/11 11:24:32
Done.
| |
| 33 }) | |
| 34 .then(function() { | |
| 35 return with_iframe(scope); | |
| 36 }) | |
| 37 .then(function(f) { | |
| 38 frame = f; | |
| 39 frame_sw = f.contentWindow.navigator.serviceWorker; | |
| 40 assert_equals( | |
| 41 frame_sw.controller.scriptURL, normalizeURL(url1), | |
| 42 'Document controller scriptURL should equal to the first one'); | |
| 43 frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged); | |
| 44 return navigator.serviceWorker.register(url2, {scope: scope}); | |
| 45 }) | |
| 46 .then(function(registration) { | |
| 47 return Promise.all([controllerchanged, | |
| 48 fetch_tests_from_worker(registration.installing)]) ; | |
| 49 }) | |
| 50 .then(function() { | |
| 51 frame.remove(); | |
| 52 return service_worker_unregister_and_done(t, scope); | |
| 53 }) | |
| 54 }, 'Test skipWaiting while a client is using the registration'); | |
| 55 | |
| 56 </script> | |
| OLD | NEW |