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 51d8ebbb0a4f05b4233d4301cd7c5dbab359481d..9efff87884b3258ca7c6396b68c3ff108f21dd5a 100644 |
--- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
+++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
@@ -59,6 +59,14 @@ function normalizeURL(url) { |
return new URL(url, document.location).toString().replace(/#.*$/, ''); |
} |
+function wait_for_update(test, registration) { |
+ return new Promise(test.step_func(function(resolve, reject) { |
falken
2014/08/14 10:16:36
you can omit reject as it's not used
nhiroki
2014/08/14 13:22:07
Done.
|
+ 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, reject) { |
worker.addEventListener('statechange', test.step_func(function() { |
@@ -112,6 +120,9 @@ function wait_for_state(test, worker, state) { |
var test = async_test(description); |
service_worker_unregister_and_register(test, url, scope) |
+ .then(function(registration) { |
+ return wait_for_update(test, registration); |
+ }) |
.then(function(worker) { return fetch_tests_from_worker(worker); }) |
.then(function() { return navigator.serviceWorker.unregister(scope); }) |
.then(function() { test.done(); }) |