| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Skip waiting installed worker</title> | 2 <title>Service Worker: Skip waiting installed worker</title> |
| 3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="resources/testharness-helpers.js"></script> | |
| 5 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="resources/test-helpers.sub.js"></script> | 5 <script src="resources/test-helpers.sub.js"></script> |
| 7 <script> | 6 <script> |
| 7 'use strict'; |
| 8 | 8 |
| 9 promise_test(function(t) { | 9 promise_test(function(t) { |
| 10 var scope = 'resources/blank.html?skip-waiting-installed'; | 10 var scope = 'resources/blank.html?skip-waiting-installed'; |
| 11 var url1 = 'resources/empty.js'; | 11 var url1 = 'resources/empty.js'; |
| 12 var url2 = 'resources/skip-waiting-installed-worker.js'; | 12 var url2 = 'resources/skip-waiting-installed-worker.js'; |
| 13 var frame, frame_sw, service_worker, registration, onmessage, oncontrollerch
anged; | 13 var frame, frame_sw, service_worker, registration, onmessage, oncontrollerch
anged; |
| 14 var saw_message = new Promise(function(resolve) { | 14 var saw_message = new Promise(function(resolve) { |
| 15 onmessage = function(e) { | 15 onmessage = function(e) { |
| 16 var message = e.data; | 16 resolve(e.data); |
| 17 assert_equals( | 17 }; |
| 18 message, 'PASS', | 18 }) |
| 19 'skipWaiting promise should be resolved with undefined'); | 19 .then(function(message) { |
| 20 assert_equals( |
| 21 message, 'PASS', |
| 22 'skipWaiting promise should be resolved with undefined'); |
| 20 | 23 |
| 21 assert_equals(registration.active.scriptURL, normalizeURL(url2), | 24 assert_equals(registration.active.scriptURL, normalizeURL(url2), |
| 22 "skipWaiting should make worker become active"); | 25 'skipWaiting should make worker become active'); |
| 23 resolve(); | 26 }); |
| 24 }; | |
| 25 }); | |
| 26 var saw_controllerchanged = new Promise(function(resolve) { | 27 var saw_controllerchanged = new Promise(function(resolve) { |
| 27 oncontrollerchanged = function() { | 28 oncontrollerchanged = function() { |
| 28 assert_equals( | 29 assert_equals( |
| 29 frame_sw.controller.scriptURL, normalizeURL(url2), | 30 frame_sw.controller.scriptURL, normalizeURL(url2), |
| 30 'Controller scriptURL should change to the second one'); | 31 'Controller scriptURL should change to the second one'); |
| 31 resolve(); | 32 resolve(); |
| 32 }; | 33 }; |
| 33 }); | 34 }); |
| 34 return service_worker_unregister_and_register(t, url1, scope) | 35 return service_worker_unregister_and_register(t, url1, scope) |
| 35 .then(function(r) { | 36 .then(function(r) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 service_worker.postMessage({port: channel.port2}, [channel.port2]); | 59 service_worker.postMessage({port: channel.port2}, [channel.port2]); |
| 59 return Promise.all([saw_message, saw_controllerchanged]); | 60 return Promise.all([saw_message, saw_controllerchanged]); |
| 60 }) | 61 }) |
| 61 .then(function() { | 62 .then(function() { |
| 62 frame.remove(); | 63 frame.remove(); |
| 63 return service_worker_unregister_and_done(t, scope); | 64 return service_worker_unregister_and_done(t, scope); |
| 64 }); | 65 }); |
| 65 }, 'Test skipWaiting when a installed worker is waiting'); | 66 }, 'Test skipWaiting when a installed worker is waiting'); |
| 66 | 67 |
| 67 </script> | 68 </script> |
| OLD | NEW |