Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: claim client not using registration</title> | 2 <title>Service Worker: claim client not using registration</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharness-helpers.js"></script> | 4 <script src="../resources/testharness-helpers.js"></script> |
| 5 <script src="../resources/testharnessreport.js"></script> | 5 <script src="../resources/testharnessreport.js"></script> |
| 6 <script src="resources/test-helpers.js"></script> | 6 <script src="resources/test-helpers.js"></script> |
| 7 <script src="../fetch/resources/fetch-test-helpers.js"></script> | |
| 7 <body> | 8 <body> |
| 8 <script> | 9 <script> |
| 9 | 10 |
| 10 promise_test(function(t) { | 11 sequential_promise_test(function(t) { |
|
falken
2015/06/05 01:36:39
It's not clear to me why sequential_promise_test i
jungkees
2015/06/05 02:08:13
While I'd tried quite a few different fixes, I lef
| |
| 11 var init_scope = 'resources/blank.html?not-using-init'; | 12 var init_scope = 'resources/blank.html?not-using-init'; |
| 12 var claim_scope = 'resources/blank.html?not-using'; | 13 var claim_scope = 'resources/blank.html?not-using'; |
| 13 var init_worker_url = 'resources/empty.js'; | 14 var init_worker_url = 'resources/empty.js'; |
| 14 var claim_worker_url = 'resources/claim-worker.js'; | 15 var claim_worker_url = 'resources/claim-worker.js'; |
| 15 var claim_worker, claim_registration, frame1, frame2; | 16 var claim_worker, claim_registration, frame1, frame2; |
| 16 return service_worker_unregister_and_register( | 17 return service_worker_unregister_and_register( |
| 17 t, init_worker_url, init_scope) | 18 t, init_worker_url, init_scope) |
| 18 .then(function(registration) { | 19 .then(function(registration) { |
| 19 return wait_for_state(t, registration.installing, 'activated'); | 20 return wait_for_state(t, registration.installing, 'activated'); |
| 20 }) | 21 }) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 'Frame1 should not be influenced'); | 64 'Frame1 should not be influenced'); |
| 64 assert_equals( | 65 assert_equals( |
| 65 frame2.contentWindow.navigator.serviceWorker.controller.scriptURL, | 66 frame2.contentWindow.navigator.serviceWorker.controller.scriptURL, |
| 66 normalizeURL(claim_worker_url), | 67 normalizeURL(claim_worker_url), |
| 67 'Frame2 should be controlled by the new registration'); | 68 'Frame2 should be controlled by the new registration'); |
| 68 frame1.remove(); | 69 frame1.remove(); |
| 69 frame2.remove(); | 70 frame2.remove(); |
| 70 return claim_registration.unregister(); | 71 return claim_registration.unregister(); |
| 71 }) | 72 }) |
| 72 .then(function() { | 73 .then(function() { |
| 73 return service_worker_unregister_and_done(t, init_scope); | 74 return service_worker_unregister(t, init_scope); |
| 74 }); | 75 }); |
| 75 }, 'Test claim client which is not using registration'); | 76 }, 'Test claim client which is not using registration'); |
| 76 | 77 |
| 77 promise_test(function(t) { | 78 sequential_promise_test(function(t) { |
| 78 var scope = 'resources/blank.html?longer-matched'; | 79 var scope = 'resources/blank.html?longer-matched'; |
| 79 var claim_scope = 'resources/blank.html?longer'; | 80 var claim_scope = 'resources/blank.html?longer'; |
| 80 var claim_worker_url = 'resources/claim-worker.js'; | 81 var claim_worker_url = 'resources/claim-worker.js'; |
| 81 var installing_worker_url = 'resources/wait-forever-in-install-worker.js'; | 82 var installing_worker_url = 'resources/empty-worker.js'; |
|
falken
2015/06/05 01:36:39
Xiang: Do you remember why you used wait-forever-i
xiang
2015/06/08 02:55:29
I intended to test claim() failure when there's a
falken
2015/06/08 08:04:31
Thanks for the comment Xiang. So it sounds OK to p
| |
| 82 var frame, claim_worker; | 83 var frame, claim_worker, longer_matched_registration; |
| 83 return with_iframe(scope) | 84 return with_iframe(scope) |
| 84 .then(function(f) { | 85 .then(function(f) { |
| 85 frame = f; | 86 frame = f; |
| 86 return navigator.serviceWorker.register( | 87 return navigator.serviceWorker.register( |
| 87 claim_worker_url, {scope: claim_scope}); | 88 claim_worker_url, {scope: claim_scope}); |
| 88 }) | 89 }) |
| 89 .then(function(registration) { | 90 .then(function(registration) { |
| 90 claim_worker = registration.installing; | 91 claim_worker = registration.installing; |
| 91 return wait_for_state(t, registration.installing, 'activated'); | 92 return wait_for_state(t, registration.installing, 'activated'); |
| 92 }) | 93 }) |
| 93 .then(function() { | 94 .then(function() { |
| 94 return navigator.serviceWorker.register( | 95 return navigator.serviceWorker.register( |
| 95 installing_worker_url, {scope: scope}); | 96 installing_worker_url, {scope: scope}); |
| 96 }) | 97 }) |
| 97 .then(function() { | 98 .then(function(registration) { |
| 99 longer_matched_registration = registration; | |
| 98 var channel = new MessageChannel(); | 100 var channel = new MessageChannel(); |
| 99 var saw_message = new Promise(function(resolve) { | 101 var saw_message = new Promise(function(resolve) { |
| 100 channel.port1.onmessage = t.step_func(function(e) { | 102 channel.port1.onmessage = t.step_func(function(e) { |
| 101 assert_equals(e.data, 'PASS', | 103 assert_equals(e.data, 'PASS', |
| 102 'Worker call to claim() should fulfill.'); | 104 'Worker call to claim() should fulfill.'); |
| 103 resolve(); | 105 resolve(); |
| 104 }); | 106 }); |
| 105 }); | 107 }); |
| 106 claim_worker.postMessage({port: channel.port2}, [channel.port2]); | 108 claim_worker.postMessage({port: channel.port2}, [channel.port2]); |
| 107 return saw_message; | 109 return saw_message; |
| 108 }) | 110 }) |
| 109 .then(function() { | 111 .then(function() { |
| 110 assert_equals( | 112 assert_equals( |
| 111 frame.contentWindow.navigator.serviceWorker.controller, null, | 113 frame.contentWindow.navigator.serviceWorker.controller, null, |
| 112 'Frame should not be claimed when a longer-matched ' + | 114 'Frame should not be claimed when a longer-matched ' + |
| 113 'registration exists'); | 115 'registration exists'); |
| 114 frame.remove(); | 116 frame.remove(); |
| 115 return service_worker_unregister_and_done(t, claim_scope); | 117 return service_worker_unregister(t, claim_scope); |
| 118 }) | |
| 119 .then(function() { | |
| 120 return longer_matched_registration.unregister(); | |
| 116 }); | 121 }); |
| 117 }, 'Test claim client when there\'s a longer-matched registration not ' + | 122 }, 'Test claim client when there\'s a longer-matched registration not ' + |
| 118 'already used by the page'); | 123 'already used by the page'); |
| 124 sequential_promise_test_done(); | |
|
falken
2015/06/05 01:36:39
Nit: Easier to read with a newline before this.
jungkees
2015/06/05 02:08:13
Resolved by removing this call.
| |
| 125 done(); | |
| 119 | 126 |
| 120 </script> | 127 </script> |
| OLD | NEW |