| 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 6bed2f1460ccb43a2f7b11e2e5749747b113cfbe..f72f60c71e4f53ebbe2332fdc96891d31ada3cf6 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'));
|
| + }
|
| +
|
| + 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'));
|
| + }
|
| +
|
| + return new Promise(test.step_func(function(resolve) {
|
| + worker.addEventListener('statechange', test.step_func(function() {
|
| + if (worker.state === state)
|
| + resolve(state);
|
| }));
|
| }));
|
| }
|
|
|