Chromium Code Reviews| 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..7f980a2de35debd007aeab869107ca20d272ec5f |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/update.html |
| @@ -0,0 +1,57 @@ |
| +<!DOCTYPE html> |
|
falken
2015/06/10 04:14:39
<title>
nhiroki
2015/06/10 06:47:21
Done.
|
| +<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; |
| + |
| + 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'); |
| + t.done(); |
| + }) |
| + }, 'Update a registration'); |
| +</script> |