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

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

Issue 1177563005: ServiceWorker: Implement ServiceWorkerRegistration.update() (3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@implement_update_1
Patch Set: incorporate falken@'s comments Created 5 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/update-worker.php ('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/update.html
diff --git a/LayoutTests/http/tests/serviceworker/update.html b/LayoutTests/http/tests/serviceworker/update.html
new file mode 100644
index 0000000000000000000000000000000000000000..9eb392a9898336b51f14b1d476611b9d50b2046c
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/update.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<title>Service Worker: Registration update()</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+promise_test(function(t) {
+ var scope = 'resources/scope/update';
+ var worker_url = 'resources/update-worker.php';
+ var expected_url = normalizeURL(worker_url);
+ var registration;
+
+ return service_worker_unregister_and_register(t, worker_url, scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ assert_equals(registration.installing, null,
+ 'installing should be null in the initial state');
+ assert_equals(registration.waiting, null,
+ 'waiting should be null in the initial state');
+ assert_equals(registration.active.scriptURL, expected_url,
+ 'active should exist in the initial state');
+
+ // A new worker should be found.
+ registration.update();
+ return wait_for_update(t, registration);
+ })
+ .then(function() {
+ assert_equals(registration.installing.scriptURL, expected_url,
+ 'new installing should be set after updatefound');
+ assert_equals(registration.waiting, null,
+ 'waiting should still be null after updatefound');
+ assert_equals(registration.active.scriptURL, expected_url,
+ 'active should still exist after update found');
+ return wait_for_state(t, registration.installing, 'installed');
+ })
+ .then(function() {
+ assert_equals(registration.installing, null,
+ 'installing should be null after installing');
+ assert_equals(registration.waiting.scriptURL, expected_url,
+ 'waiting should be set after installing');
+ assert_equals(registration.active.scriptURL, expected_url,
+ 'active should still exist after installing');
+ return wait_for_state(t, registration.waiting, 'activated');
+ })
+ .then(function() {
+ assert_equals(registration.installing, null,
+ 'installing should be null after activated');
+ assert_equals(registration.waiting, null,
+ 'waiting should be null after activated');
+ assert_equals(registration.active.scriptURL, expected_url,
+ 'new worker should be promoted to active');
+ return service_worker_unregister_and_done(t, scope);
+ })
+ }, 'Update a registration');
+</script>
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/update-worker.php ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698