Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-newer-worker.js |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-newer-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-newer-worker.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..63fd6c10eb359bf27c427783c469513924689a78 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-newer-worker.js |
| @@ -0,0 +1,30 @@ |
| +var results = []; |
|
falken
2015/11/19 01:29:22
A lot of our tests do this, but I think we shouldn
nhiroki
2015/11/19 09:02:54
I agree that we should avoid global states. I'm th
|
| + |
| +function stringify(worker) { |
| + return worker ? worker.scriptURL : 'empty'; |
| +} |
| + |
| +function record(event_name) { |
| + results.push(event_name); |
| + results.push(' installing: ' + stringify(self.registration.installing)); |
| + results.push(' waiting: ' + stringify(self.registration.waiting)); |
| + results.push(' active: ' + stringify(self.registration.active)); |
| +} |
| + |
| +record('evaluate'); |
| + |
| +self.registration.addEventListener('updatefound', function() { |
| + record('updatefound'); |
| + var worker = self.registration.installing; |
| + self.registration.installing.addEventListener('statechange', function() { |
| + record('statechange(' + worker.state + ')'); |
| + }); |
| + }); |
| + |
| +self.addEventListener('install', function(e) { record('install'); }); |
| + |
| +self.addEventListener('activate', function(e) { record('activate'); }); |
| + |
| +self.addEventListener('message', function(e) { |
| + e.data.port.postMessage(results); |
| + }); |