Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html

Issue 776373003: ServiceWorker cleanup: remove wait_for_update() in favor of r.installing in most tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/scope.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <script> 1 <script>
2 var port = undefined; 2 var port = undefined;
3 var scope = 'fetch-request-body-file-test'; 3 var scope = 'fetch-request-body-file-test';
4 var script = 'fetch-request-body-file-worker.js'; 4 var script = 'fetch-request-body-file-worker.js';
5 5
6 window.addEventListener('message', function(evt) { 6 window.addEventListener('message', function(evt) {
7 port = evt.ports[0]; 7 port = evt.ports[0];
8 start(); 8 start();
9 }, false); 9 }, false);
10 10
11 function wait_for_update(registration) { 11 function wait_for_activated(registration) {
12 return new Promise(function(resolve) { 12 return new Promise(function(resolve) {
13 registration.addEventListener('updatefound', function() { 13 var worker = registration.installing;
14 resolve(registration.installing);
15 });
16 });
17 }
18
19 function wait_for_activated(worker) {
20 return new Promise(function(resolve) {
21 worker.addEventListener('statechange', function() { 14 worker.addEventListener('statechange', function() {
22 if (worker.state == 'activated') { 15 if (worker.state == 'activated') {
23 resolve(worker); 16 resolve(worker);
24 } 17 }
25 }); 18 });
26 }); 19 });
27 } 20 }
28 21
29 function start() { 22 function start() {
30 if (location.search == '?register') { 23 if (location.search == '?register') {
31 navigator.serviceWorker.register(script, {scope: scope}) 24 navigator.serviceWorker.register(script, {scope: scope})
32 .then(function(registration) { 25 .then(function(registration) {
33 return registration.unregister(); 26 return registration.unregister();
34 }) 27 })
35 .then(function() { 28 .then(function() {
36 return navigator.serviceWorker.register(script, {scope: scope}); 29 return navigator.serviceWorker.register(script, {scope: scope});
37 }) 30 })
38 .then(wait_for_update)
39 .then(wait_for_activated) 31 .then(wait_for_activated)
40 .then(function(worker) { 32 .then(function(worker) {
41 port.postMessage({msg: 'registered'}); 33 port.postMessage({msg: 'registered'});
42 }); 34 });
43 } else if (location.search == '?unregister') { 35 } else if (location.search == '?unregister') {
44 navigator.serviceWorker.register(script, {scope: scope}) 36 navigator.serviceWorker.register(script, {scope: scope})
45 .then(function(registration) { 37 .then(function(registration) {
46 return registration.unregister(); 38 return registration.unregister();
47 }) 39 })
48 .then(function() { 40 .then(function() {
49 port.postMessage({msg: 'unregistered'}); 41 port.postMessage({msg: 'unregistered'});
50 }); 42 });
51 } 43 }
52 } 44 }
53 </script> 45 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/scope.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698