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

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

Issue 480943002: Service Worker: Add tests for same-scope new script registration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback and test expectation 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 6bed2f1460ccb43a2f7b11e2e5749747b113cfbe..f72f60c71e4f53ebbe2332fdc96891d31ada3cf6 100644
--- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
+++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js
@@ -66,18 +66,28 @@ function normalizeURL(url) {
}
function wait_for_update(test, registration) {
- return new Promise(test.step_func(function(resolve) {
- registration.addEventListener('updatefound', test.step_func(function() {
- resolve(registration.installing);
- }));
+ if (!registration || registration.unregister == undefined) {
+ return Promise.reject(new Error(
+ 'wait_for_update must be passed a ServiceWorkerRegistration'));
+ }
+
+ return new Promise(test.step_func(function(resolve) {
+ 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) {
- worker.addEventListener('statechange', test.step_func(function() {
- if (worker.state === state)
- resolve(state);
+ if (!worker || worker.state == undefined) {
+ return Promise.reject(new Error(
+ 'wait_for_state must be passed a ServiceWorker'));
+ }
+
+ return new Promise(test.step_func(function(resolve) {
+ worker.addEventListener('statechange', test.step_func(function() {
+ if (worker.state === state)
+ resolve(state);
}));
}));
}

Powered by Google App Engine
This is Rietveld 408576698