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

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

Issue 531423002: ServiceWorker: Clean up fetch-event.html (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: introduce wait_fo_activated Created 6 years, 3 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/fetch-event.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1c3d4645ae1e38d10f2ce18ea737d3d0d5056d9b..230acd629d2355724c59a61cafd5bada0ce29299 100644
--- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
+++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
@@ -82,6 +82,22 @@ function wait_for_state(test, worker, state) {
}));
}
+function wait_for_activated(test, registration) {
+ var expected_state = 'activated';
+ if (registration.active) {
+ if (registration.active.state === expected_state)
+ return Promise.resolve(registration.active);
+ else
+ return wait_for_state(test, registration.active, expected_state);
+ }
+ if (registration.waiting)
+ return wait_for_state(test, registration.waiting, expected_state);
+ if (registration.installing)
+ return wait_for_state(test, registration.installing, expected_state);
+ return Promise.reject(
+ new Error('registration must have at least one version'));
+}
+
(function() {
function fetch_tests_from_worker(worker) {
return new Promise(function(resolve, reject) {
« no previous file with comments | « LayoutTests/http/tests/serviceworker/fetch-event.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698