Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <title>ServiceWorker: worker objects have synced state</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 // Tests that ServiceWorker objects representing the same Service Worker | |
| 8 // entity have the same state. JS-level equality is now required according to | |
| 9 // the spec. | |
| 10 promise_test(function(t) { | |
| 11 var scope = 'resources/synced-state'; | |
| 12 var script = 'resources/empty-worker.js'; | |
| 13 var registration; | |
| 14 return service_worker_unregister_and_register(t, script, scope) | |
| 15 .then(function(r) { | |
| 16 var step = 0; | |
| 17 registration = r; | |
| 18 add_completion_callback(function() { r.unregister(); }); | |
| 19 return new Promise(function(resolve) { | |
| 20 r.installing.addEventListener('statechange', function(e) { | |
| 21 step++; | |
| 22 if (step == 1) { | |
| 23 assert_equals(e.currentTarget.state, 'installed', | |
| 24 'original SW should be installed'); | |
| 25 assert_equals(r.installing, null, | |
| 26 'in installed, .installing should be null'); | |
| 27 assert_equals(r.waiting.state, 'installed', | |
| 28 'in installed, the state of .waiting ' + | |
| 29 'should be installed'); | |
| 30 assert_equals(r.active, null, | |
| 31 'in installed, .active should be null'); | |
| 32 assert_equals(r.waiting, e.currentTarget, | |
| 33 '.waiting should be equal to the original ' + | |
| 34 'SW in installed'); | |
| 35 } else if (step == 2) { | |
| 36 assert_equals(e.currentTarget.state, 'activating', | |
| 37 'original SW should be activating'); | |
| 38 assert_equals(r.installing, null, | |
| 39 'in activating, .installing should be null'); | |
| 40 assert_equals(r.waiting, null, | |
| 41 'in activating, .waiting should be null'); | |
| 42 assert_equals(r.active.state, 'activating', | |
| 43 'in activating, the state of .active ' + | |
| 44 'should be activating'); | |
| 45 assert_equals(r.active, e.currentTarget, | |
| 46 '.active should be equal to the original ' + | |
| 47 'SW in activating'); | |
| 48 } else if (step == 3) { | |
| 49 assert_equals(e.currentTarget.state, 'activated', | |
| 50 'original SW should be activated'); | |
| 51 assert_equals(r.installing, null, | |
| 52 'in activated, .installing should be null'); | |
| 53 assert_equals(r.waiting, null, | |
| 54 'in activated, .waiting should be null'); | |
| 55 assert_equals(r.active.state, 'activated', | |
| 56 'in activated, the state of .active should ' + | |
| 57 'be activated'); | |
| 58 assert_equals(r.active, e.currentTarget, | |
| 59 '.active should be equal to the original ' + | |
| 60 'SW in activated'); | |
| 61 resolve(); | |
| 62 } | |
| 63 }); | |
| 64 }); | |
| 65 }) | |
| 66 .then(function() { | |
| 67 return navigator.serviceWorker.getRegistration(scope); | |
| 68 }) | |
| 69 .then(function(r) { | |
| 70 assert_equals(r, registration, 'getRegistration should return the ' + | |
| 71 'same object with the registered one'); | |
|
falken
2017/05/29 04:06:25
We seem to have lost the asserts in lines 67-71.
mike3
2017/05/29 15:30:49
Acknowledged.
| |
| 72 }); | |
| 73 }, 'worker objects for the same entity have the same state'); | |
| 74 </script> | |
| OLD | NEW |