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

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

Issue 580033002: ServiceWorker: Stabilize install-phase-event-waituntil.html (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/install-phase-event-waituntil.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 8ff035e5cc975dab233206ca9dc6fac5f5c2fbaf..1af9804f07127b4d7a5f8e3eb56015035420fb6c 100644
--- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
+++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
@@ -65,6 +65,21 @@ function normalizeURL(url) {
return new URL(url, document.location).toString().replace(/#.*$/, '');
}
+function get_newest_worker(registration) {
+ if (!registration) {
+ return Promise.reject(new Error(
+ 'get_newest_worker must be passed a ServiceWorkerRegistration'));
+ }
+ if (registration.installing)
+ return Promise.resolve(registration.installing);
+ if (registration.waiting)
+ return Promise.resolve(registration.waiting);
+ if (registration.active)
+ return Promise.resolve(registration.active);
+ return Promise.reject(new Error(
+ 'registration must have at least one version'));
+}
+
function wait_for_update(test, registration) {
if (!registration || registration.unregister == undefined) {
return Promise.reject(new Error(
« no previous file with comments | « LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698