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

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

Issue 468753003: SW tests update (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 467133002 and fix test 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 5a72d31ca1bac7a061c90a030c25e6311e75204e..79eb7c5785ce9024f47793614d1fc1df461de1b7 100644
--- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
+++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
@@ -48,6 +48,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) {
+ 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() {
@@ -101,6 +109,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