Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
| diff --git a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
| index 230acd629d2355724c59a61cafd5bada0ce29299..aec050426c3f91d71989c00c5ffbb5f774a87d4e 100644 |
| --- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
| +++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
| @@ -66,18 +66,28 @@ function normalizeURL(url) { |
| } |
| function wait_for_update(test, registration) { |
| - return new Promise(test.step_func(function(resolve) { |
| - registration.addEventListener('updatefound', test.step_func(function() { |
| - resolve(registration.installing); |
| - })); |
| + if (!registration || registration.unregister == undefined) { |
| + return Promise.reject(new Error( |
| + 'wait_for_update must be passed a ServiceWorkerRegistration')); |
|
michaeln
2014/09/12 00:37:20
ditto
horo
2014/09/12 01:16:32
Done.
|
| + } |
| + |
| + return new Promise(test.step_func(function(resolve) { |
| + registration.addEventListener('updatefound', test.step_func(function() { |
| + resolve(registration.installing); |
| + })); |
| })); |
| } |
| function wait_for_state(test, worker, state) { |
| - return new Promise(test.step_func(function(resolve) { |
| - worker.addEventListener('statechange', test.step_func(function() { |
| - if (worker.state === state) |
| - resolve(state); |
| + if (!worker || worker.state == undefined) { |
| + return Promise.reject(new Error( |
| + 'wait_for_state must be passed a ServiceWorker')); |
|
michaeln
2014/09/12 00:37:20
nit: 2 more spaces
horo
2014/09/12 01:16:33
Done.
|
| + } |
| + |
| + return new Promise(test.step_func(function(resolve) { |
| + worker.addEventListener('statechange', test.step_func(function() { |
| + if (worker.state === state) |
| + resolve(state); |
| })); |
| })); |
| } |