Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
|
falken
2016/04/14 18:34:57
I think we should keep this outside of chromium/ b
| |
| 2 <script src="../../resources/testharness.js"></script> | |
| 3 <script src="../../resources/testharnessreport.js"></script> | |
| 4 <script src="../resources/test-helpers.js"></script> | |
| 5 <script> | |
| 6 | |
| 7 promise_test(function(t) { | |
| 8 var worker_url1 = './resources/empty-worker.js?1'; | |
| 9 var worker_url2 = './resources/empty-worker.js?2'; | |
| 10 var scope = './resources/blank.html?check-activate-process-after-reloading'; | |
| 11 var frame; | |
| 12 var registration; | |
| 13 var old_worker; | |
| 14 var new_worker; | |
| 15 return service_worker_unregister_and_register(t, worker_url1, scope) | |
| 16 .then(function(r) { | |
| 17 add_completion_callback(function() { | |
| 18 service_worker_unregister(t, scope); | |
|
falken
2016/04/14 18:34:57
Can this just be r.unregister()?
| |
| 19 }); | |
| 20 registration = r; | |
| 21 old_worker = r.installing; | |
| 22 assert_not_equals(r.installing, null, | |
| 23 '.installing should be set just after registration'); | |
|
falken
2016/04/14 18:34:57
Let's remove this assert. Most of our tests have t
| |
| 24 return wait_for_state(t, r.installing, 'activated'); | |
| 25 }) | |
| 26 .then(function() { | |
| 27 return with_iframe(scope); | |
| 28 }) | |
| 29 .then(function(f) { | |
| 30 frame = f; | |
| 31 var c = frame.contentWindow.navigator.serviceWorker.controller; | |
| 32 assert_not_equals(c, null, 'An iframe should be controlled by SW '+ | |
| 33 'after registration'); | |
|
falken
2016/04/14 18:34:57
Let's remove this assert, it should be covered by
| |
| 34 return navigator.serviceWorker.register(worker_url2, {scope: scope}); | |
| 35 }) | |
| 36 .then(function(r) { | |
| 37 assert_equals(r, registration, | |
| 38 'registration should be the same for the same scope'); | |
| 39 new_worker = r.installing; | |
| 40 assert_not_equals(r.installing, null, | |
| 41 'install process should be triggered after ' + | |
| 42 'resolving register()'); | |
| 43 return wait_for_state(t, r.installing, 'installed'); | |
| 44 }) | |
| 45 .then(function() { | |
| 46 assert_not_equals(registration.waiting, null, | |
| 47 'installing worker should move to waiting worker ' + | |
| 48 'after installed'); | |
| 49 assert_not_equals(registration.active, null, | |
| 50 'active worker should remain until iframe is ' + | |
| 51 'controlled by this worker'); | |
|
falken
2016/04/14 18:34:57
Let's make these:
assert_equals(registration.waiti
| |
| 52 return new Promise(function(resolve) { | |
| 53 frame.onload = resolve; | |
| 54 frame.contentWindow.location.reload(); | |
| 55 }); | |
| 56 }) | |
| 57 .then(function() { | |
| 58 assert_equals(registration.waiting, new_worker, | |
| 59 'installing worker should move to waiting worker after ' + | |
| 60 'installed'); | |
| 61 assert_equals(registration.active, old_worker, | |
| 62 'active worker should remain until iframe is ' + | |
| 63 'controlled by this worker'); | |
|
falken
2016/04/14 18:34:57
The descriptions should be updated to mention the
| |
| 64 var c = frame.contentWindow.navigator.serviceWorker.controller; | |
| 65 assert_not_equals(c, null, 'An iframe should be controlled by SW ' + | |
| 66 'after re-registration'); | |
|
falken
2016/04/14 18:34:57
Can this assert be more specific? c.scriptURL == o
| |
| 67 }); | |
| 68 }, 'Reloading the last controlled iframe after re-registration should not ' + | |
| 69 'invoke Activate process of the registration'); | |
|
falken
2016/04/14 18:34:57
In spec language, it's called Activate algorithm.
| |
| 70 | |
| 71 promise_test(function(t) { | |
| 72 var worker_url = 'resources/empty-worker.js'; | |
| 73 var scope = 'resources/blank.html?check-clear-process-after-reloading'; | |
| 74 var registration; | |
| 75 var frame; | |
| 76 return service_worker_unregister_and_register(t, worker_url, scope) | |
| 77 .then(function(r) { | |
| 78 registration = r; | |
| 79 return wait_for_state(t, r.installing, 'activated'); | |
| 80 }) | |
| 81 .then(function() { | |
| 82 return with_iframe(scope); | |
| 83 }) | |
| 84 .then(function(f) { | |
| 85 frame = f; | |
| 86 return registration.unregister(); | |
| 87 }) | |
| 88 .then(function() { | |
| 89 return new Promise(function(resolve) { | |
| 90 frame.onload = resolve; | |
| 91 frame.contentWindow.location.reload(); | |
| 92 }); | |
| 93 }) | |
| 94 .then(function() { | |
| 95 // TODO(shimazu): Expected behavior is NOT to invoke "Clear" procedure | |
| 96 // after reloading according to comments at | |
| 97 // http://crrev.com/1865103003#msg29 | |
| 98 // Assertions after here should be fixed once the behavior is fixed. | |
| 99 var c = frame.contentWindow.navigator.serviceWorker.controller; | |
| 100 assert_equals(c, null, 'a page after unregistration should not be ' + | |
| 101 'controlled by the service worker'); | |
| 102 return navigator.serviceWorker.getRegistration(scope); | |
| 103 }) | |
| 104 .then(function(r) { | |
| 105 assert_equals(r, undefined, | |
| 106 'getRegistration should return undefined after ' + | |
| 107 'reloading the controlled iframe following ' + | |
| 108 'unregistration'); | |
| 109 }); | |
| 110 }, 'Reloading the last controlled iframe after unregistration should ' + | |
| 111 'invoke Clear process of the registration'); | |
| 112 </script> | |
| OLD | NEW |