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

Unified Diff: LayoutTests/http/tests/serviceworker/activation-after-registration.html

Issue 247263010: ServiceWorker: Wait for registration promise to resolve before changing states. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: yhirano comments Created 6 years, 8 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/activation-after-registration.html
diff --git a/LayoutTests/http/tests/serviceworker/activation-after-registration.html b/LayoutTests/http/tests/serviceworker/activation-after-registration.html
new file mode 100644
index 0000000000000000000000000000000000000000..bde27e2cac5e7cd882c8d2efaadb6d10ea0f1b8d
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/activation-after-registration.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<title>Service Worker: Activation occurs after registration</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/testutils.js"></script>
+<body>
+<script>
+var t = async_test('activation occurs after registration');
+t.step(function() {
+ var scope = 'resources/blank.html';
+ navigator.serviceWorker.unregister(scope).then(doTest, doTest);
+ function doTest() {
+ navigator.serviceWorker.register(
+ 'resources/worker-no-op.js', {scope: scope}
+ ).then(t.step_func(onRegister), t.step_func(function(reason) {
+ assert_unreached('Registration should succeed, but failed: ' + reason.name);
+ }));
+ }
+
+ function onRegister(worker) {
+ assert_equals(worker.state, 'parsed', 'worker should be in the "parsed" state upon registration');
+ worker.addEventListener('statechange', t.step_func(function(event) {
+ if (event.target.state == 'active')
+ t.done();
+ }));
+ }
+});
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698