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

Unified Diff: LayoutTests/http/tests/serviceworker/state.html

Issue 311573002: Add a test, ServiceWorker statechange target is the installing worker. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/state.html
diff --git a/LayoutTests/http/tests/serviceworker/state.html b/LayoutTests/http/tests/serviceworker/state.html
index ed44d2f6ad591b86cef3430332aa622ba87ba24c..a73afa9cb4f802be2e09feef278654e7a313f6a1 100644
--- a/LayoutTests/http/tests/serviceworker/state.html
+++ b/LayoutTests/http/tests/serviceworker/state.html
@@ -13,7 +13,7 @@
t, 'resources/worker-no-op.js', scope, onRegister);
function onRegister(sw) {
- sw.addEventListener('statechange', t.step_func(onStateChange));
+ sw.addEventListener('statechange', t.step_func(onStateChange(sw)));
assert_in_array(sw.state, ['parsed', 'installing'],
'the service worker should be in a state up to ' +
'"installing".');
@@ -51,17 +51,22 @@
currentState = newState;
}
- function onStateChange(event) {
- assert_true(event.target instanceof ServiceWorker,
- 'the target of the statechange event should be a ' +
- 'ServiceWorker.');
- assert_equals(event.type, 'statechange',
- 'the type of the event should be "statechange".');
+ function onStateChange(expectedTarget) {
+ return function(event) {
+ assert_true(event.target instanceof ServiceWorker,
+ 'the target of the statechange event should be a ' +
+ 'ServiceWorker.');
+ assert_equals(event.target, expectedTarget,
+ 'the target of the statechange event should be ' +
+ 'the installing ServiceWorker');
+ assert_equals(event.type, 'statechange',
+ 'the type of the event should be "statechange".');
- checkStateTransition(event.target.state);
+ checkStateTransition(event.target.state);
- if (event.target.state == 'active')
- service_worker_unregister_and_done(t, scope);
+ if (event.target.state == 'active')
+ service_worker_unregister_and_done(t, scope);
+ };
}
}());
</script>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698