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

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

Issue 324893002: Add tests for navigator.serviceWorker.waiting. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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/waiting.html
diff --git a/LayoutTests/http/tests/serviceworker/waiting.html b/LayoutTests/http/tests/serviceworker/waiting.html
new file mode 100644
index 0000000000000000000000000000000000000000..89bc149684cd58a3b5e49001af77886df91c311f
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/waiting.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<title>ServiceWorker: navigator.serviceWorker.waiting</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<body>
+<script>
+var t = async_test('waiting is set');
+t.step(function() {
+ var url = 'resources/worker-no-op.js';
+ var scope = 'resources/blank.html';
+ var frame;
+
+ navigator.serviceWorker.unregister(scope)
+ .then(function() { return with_iframe(scope); },
jsbell 2014/06/10 17:59:32 Style nit: In other tests, we don't seem to start
jsbell 2014/06/10 17:59:33 Needs t.step_func() wrapper (testharness.js is upd
dominicc (has gone to gerrit) 2014/06/10 21:27:18 Yeah, I wrote it the style guide way, and then dec
jsbell 2014/06/10 22:36:23 Sounds good. It's not my personal preference for n
+ unreached_rejection(t, 'Unregister should not fail'))
+ .then(function(f) {
jsbell 2014/06/10 17:59:32 Needs t.step_func() wrapper
dominicc (has gone to gerrit) 2014/06/10 21:27:18 The only thing that does for me is fail the test i
jsbell 2014/06/10 22:36:23 Correct. However, from my experience trying to deb
+ frame = f;
+ return navigator.serviceWorker.register(url, {scope: scope});
+ })
+ .then(function(serviceWorker) {
jsbell 2014/06/10 17:59:32 Needs t.step_func() wrapper
+ // FIXME: Replace this with .ready when that supports the in-waiting
+ // Service Worker.
+ return new Promise(function(resolve, reject) {
jsbell 2014/06/10 17:59:32 Needs t.step_func() wrapper
+ serviceWorker.onstatechange = function() {
jsbell 2014/06/10 17:59:32 Needs t.step_func() wrapper
+ if (serviceWorker.state == 'installed') {
+ resolve();
+ }
+ };
+ });
+ }, unreached_rejection(t, 'Registration should not fail'))
+ .then(t.step_func(function() {
+ var container = frame.contentWindow.navigator.serviceWorker;
+ assert_equals(container.controller, null);
+ assert_equals(container.waiting.url, normalizeURL(url));
+
+ // FIXME: Add a test for a frame created after installation.
+ // Should the existing frame ("frame") block activation?
+ }))
+ .then(function() {
jsbell 2014/06/10 17:59:32 Needs t.step_func() wrapper
+ frame.remove();
+ return service_worker_unregister_and_done(t, scope);
+ });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698