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

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: Put the expected result file at the right path. 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..88bad24ac9488f685d1ee8b22514bd1954399b23
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/waiting.html
@@ -0,0 +1,46 @@
+<!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>
+// "waiting" is set
+async_test(function(t) {
+ var step = t.step_func.bind(t);
+ var url = 'resources/worker-no-op.js';
+ var scope = 'resources/blank.html';
+ var frame;
+
+ navigator.serviceWorker.unregister(scope)
+ .then(step(function() { return with_iframe(scope); }),
+ unreached_rejection(t, 'Unregister should not fail'))
+ .then(step(function(f) {
+ frame = f;
+ return navigator.serviceWorker.register(url, {scope: scope});
+ }))
+ .then(step(function(serviceWorker) {
+ // FIXME: Replace this with .ready when that supports the in-waiting
+ // Service Worker.
+ return new Promise(step(function(resolve, reject) {
+ serviceWorker.onstatechange = step(function() {
+ if (serviceWorker.state == 'installed') {
+ resolve();
+ }
+ });
+ }));
+ }), unreached_rejection(t, 'Registration should not fail'))
+ .then(step(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(step(function() {
+ frame.remove();
+ return service_worker_unregister_and_done(t, scope);
+ }));
+}, 'waiting is set');
+</script>

Powered by Google App Engine
This is Rietveld 408576698