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

Unified Diff: LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js

Issue 861743002: ServiceWorker: Test ServiceWorkerGlobalScope.registration attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@expose_swreg2
Patch Set: s/eventsSeen/events_seen/ Created 5 years, 11 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/ServiceWorkerGlobalScope/registration-attribute.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/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js b/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js
index 236a27891506f4b661a1d50c5de539bc285a4fbb..38651374fac8be8c4be4ac7d963f1a5e7dd0dca6 100644
--- a/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js
+++ b/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/registration-attribute-worker.js
@@ -1,6 +1,8 @@
importScripts('../../resources/test-helpers.js');
importScripts('../../resources/worker-testharness.js');
+var events_seen = [];
+
assert_equals(
self.registration.scope,
normalizeURL('scope/registration-attribute'),
@@ -18,36 +20,113 @@ assert_equals(
null,
'On worker script evaluation, active worker should be null');
+self.registration.addEventListener('updatefound', function() {
+ events_seen.push('updatefound');
+
+ assert_equals(
+ self.registration.scope,
+ normalizeURL('scope/registration-attribute'),
+ 'On updatefound event, registration attribute should be set');
+ assert_equals(
+ self.registration.installing.scriptURL,
+ normalizeURL('registration-attribute-worker.js'),
+ 'On updatefound event, installing worker should be set');
+ assert_equals(
+ self.registration.waiting,
+ null,
+ 'On updatefound event, waiting worker should be null');
+ assert_equals(
+ self.registration.active,
+ null,
+ 'On updatefound event, active worker should be null');
+
+ assert_equals(
+ self.registration.installing.state,
+ 'installing',
+ 'On updatefound event, worker should be in the installing state');
+
+ var worker = self.registration.installing;
+ self.registration.installing.addEventListener('statechange', function() {
+ events_seen.push('statechange(' + worker.state + ')');
+ });
+ });
+
self.addEventListener('install', function(e) {
+ events_seen.push('install');
+
assert_equals(
self.registration.scope,
normalizeURL('scope/registration-attribute'),
'On install event, registration attribute should be set');
- // FIXME: Verify that...
- // - registration.installing is set.
- // - registration.{waiting, active} are null.
- // (http://crbug.com/437677)
+ assert_equals(
+ self.registration.installing.scriptURL,
+ normalizeURL('registration-attribute-worker.js'),
+ 'On install event, installing worker should be set');
+ assert_equals(
+ self.registration.waiting,
+ null,
+ 'On install event, waiting worker should be null');
+ assert_equals(
+ self.registration.active,
+ null,
+ 'On install event, active worker should be null');
+
+ assert_equals(
+ self.registration.installing.state,
+ 'installing',
+ 'On install event, worker should be in the installing state');
});
self.addEventListener('activate', function(e) {
+ events_seen.push('activate');
+
assert_equals(
self.registration.scope,
normalizeURL('scope/registration-attribute'),
'On activate event, registration attribute should be set');
- // FIXME: Verify that...
- // - registration.{installing, waiting} are null.
- // - registration.active is set.
- // (http://crbug.com/437677)
+ assert_equals(
+ self.registration.installing,
+ null,
+ 'On activate event, installing worker should be null');
+ assert_equals(
+ self.registration.waiting,
+ null,
+ 'On activate event, waiting worker should be null');
+ assert_equals(
+ self.registration.active.scriptURL,
+ normalizeURL('registration-attribute-worker.js'),
+ 'On activate event, active worker should be set');
+
+ assert_equals(
+ self.registration.active.state,
+ 'activating',
+ 'On activate event, worker should be in the activating state');
});
self.addEventListener('fetch', function(e) {
+ events_seen.push('fetch');
+
assert_equals(
self.registration.scope,
normalizeURL('scope/registration-attribute'),
'On fetch event, registration attribute should be set');
- // FIXME: Verify that...
- // - registration.{installing, waiting} are null.
- // - registration.active is set.
- // (http://crbug.com/437677)
- e.respondWith(new Response('PASS'));
+ assert_equals(
+ self.registration.installing,
+ null,
+ 'On fetch event, installing worker should be null');
+ assert_equals(
+ self.registration.waiting,
+ null,
+ 'On fetch event, waiting worker should be null');
+ assert_equals(
+ self.registration.active.scriptURL,
+ normalizeURL('registration-attribute-worker.js'),
+ 'On fetch event, active worker should be set');
+
+ assert_equals(
+ self.registration.active.state,
+ 'activated',
+ 'On fetch event, worker should be in the activated state');
+
+ e.respondWith(new Response(events_seen));
});
« no previous file with comments | « LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698