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

Unified Diff: LayoutTests/http/tests/serviceworker/resources/test-helpers.js

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: apply horo@'s patch (PatchSet 28 on https://codereview.chromium.org/468753003/) Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
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(); })

Powered by Google App Engine
This is Rietveld 408576698