Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>ServiceWorkerGlobalScope: registration</title> | 2 <title>ServiceWorkerGlobalScope: registration</title> |
| 3 <script src='../../resources/testharness.js'></script> | 3 <script src='../../resources/testharness.js'></script> |
| 4 <script src='../../resources/testharnessreport.js'></script> | 4 <script src='../../resources/testharnessreport.js'></script> |
| 5 <script src='../resources/test-helpers.js'></script> | 5 <script src='../resources/test-helpers.js'></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 promise_test(function(t) { | 8 promise_test(function(t) { |
| 9 var script = 'resources/registration-attribute-worker.js'; | 9 var script = 'resources/registration-attribute-worker.js'; |
| 10 var scope = 'resources/scope/registration-attribute'; | 10 var scope = 'resources/scope/registration-attribute'; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 'fetch', | 25 'fetch', |
| 26 ]; | 26 ]; |
| 27 | 27 |
| 28 assert_equals( | 28 assert_equals( |
| 29 frame.contentDocument.body.textContent, | 29 frame.contentDocument.body.textContent, |
| 30 expected_events_seen.toString(), | 30 expected_events_seen.toString(), |
| 31 'Service Worker should respond to fetch'); | 31 'Service Worker should respond to fetch'); |
| 32 frame.remove(); | 32 frame.remove(); |
| 33 return service_worker_unregister_and_done(t, scope); | 33 return service_worker_unregister_and_done(t, scope); |
| 34 }); | 34 }); |
| 35 }, 'Verify registration attribute on ServiceWorkerGlobalScope'); | 35 }, 'Verify registration attributes on ServiceWorkerGlobalScope'); |
| 36 | |
| 37 promise_test(function(t) { | |
| 38 var script = 'resources/registration-attribute-worker.js'; | |
| 39 var newer_script = 'resources/registration-attribute-newer-worker.js'; | |
| 40 var scope = 'resources/scope/registration-attribute'; | |
| 41 var newer_worker; | |
| 42 | |
| 43 return service_worker_unregister_and_register(t, script, scope) | |
| 44 .then(function(registration) { | |
| 45 return wait_for_state(t, registration.installing, 'activated'); | |
| 46 }) | |
| 47 .then(function() { | |
| 48 return navigator.serviceWorker.register(newer_script, {scope: scope}); | |
| 49 }) | |
| 50 .then(function(registration) { | |
| 51 newer_worker = registration.installing; | |
| 52 return wait_for_state(t, registration.installing, 'activated'); | |
| 53 }) | |
| 54 .then(function() { | |
| 55 var channel = new MessageChannel; | |
| 56 var sawMessage = new Promise(function(resolve) { | |
|
falken
2015/11/19 01:29:22
nit: saw_message
nhiroki
2015/11/19 09:02:54
Done.
| |
| 57 channel.port1.onmessage = function(e) { resolve(e.data); }; | |
| 58 }); | |
| 59 newer_worker.postMessage({port: channel.port2}, [channel.port2]); | |
| 60 return sawMessage; | |
| 61 }) | |
| 62 .then(function(results) { | |
| 63 var script_url = normalizeURL(script); | |
| 64 var newer_script_url = normalizeURL(newer_script); | |
| 65 var expectations = [ | |
| 66 'evaluate', | |
| 67 ' installing: empty', | |
| 68 ' waiting: empty', | |
| 69 ' active: ' + script_url, | |
| 70 'updatefound', | |
| 71 ' installing: ' + newer_script_url, | |
| 72 ' waiting: empty', | |
| 73 ' active: ' + script_url, | |
| 74 'install', | |
| 75 ' installing: ' + newer_script_url, | |
| 76 ' waiting: empty', | |
| 77 ' active: ' + script_url, | |
| 78 'statechange(installed)', | |
| 79 ' installing: empty', | |
| 80 ' waiting: ' + newer_script_url, | |
| 81 ' active: ' + script_url, | |
| 82 'statechange(activating)', | |
| 83 ' installing: empty', | |
| 84 ' waiting: empty', | |
| 85 ' active: ' + newer_script_url, | |
| 86 'activate', | |
| 87 ' installing: empty', | |
| 88 ' waiting: empty', | |
| 89 ' active: ' + newer_script_url, | |
| 90 'statechange(activated)', | |
| 91 ' installing: empty', | |
| 92 ' waiting: empty', | |
| 93 ' active: ' + newer_script_url, | |
| 94 ]; | |
| 95 assert_array_equals(results, expectations); | |
| 96 return service_worker_unregister_and_done(t, scope); | |
|
falken
2015/11/19 01:29:22
add_completion_callback instead?
nhiroki
2015/11/19 09:02:54
Done.
| |
| 97 }); | |
| 98 }, 'Verify registration attributes on ServiceWorkerGlobalScope of the ' + | |
| 99 'newer worker'); | |
| 36 | 100 |
| 37 </script> | 101 </script> |
| OLD | NEW |