| <!DOCTYPE html> |
| <!-- This test is prefixed with `chromium.` because it asserts the behavior of |
| the HTTP cache. This behavior does not violate any standard but neither is it |
| required. --> |
| <title>Service Worker: Registration update() served from cache</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-served-from-cache'; |
| var worker_url = 'resources/update-served-from-cache-worker.php'; |
| var registration; |
| |
| return service_worker_unregister_and_register(t, worker_url, scope) |
| .then(function(r) { |
| // The script resource for this register() having a non-zero max-age |
| // value was cached. |
| registration = r; |
| return wait_for_state(t, registration.installing, 'activated'); |
| }) |
| .then(function() { |
| // update() should consult the cache. The returned promise should |
| // resolve when the script is retrieved from the cache. |
| return registration.update(); |
| }) |
| .then(function() { |
| // installing should be null as update() does not trigger install. |
| assert_equals( |
| registration.installing, |
| null, |
| 'installing should be null as the script was served from cache.'); |
| return service_worker_unregister_and_done(t, scope); |
| }); |
| }, 'Update a registration served from cache.'); |
| </script> |