| 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>
|
|
|