OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Background Fetch API: get() tests</title> |
| 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="/serviceworker/resources/test-helpers.js"></script> |
| 7 |
| 8 <h1>BackgroundFetchManager.get()</h1> |
| 9 <p>This test validates the behaviour of the get() method.</p> |
| 10 |
| 11 <!-- TODO(peter): Move this to the WPT directory when it's merged. --> |
| 12 |
| 13 <script> |
| 14 'use strict'; |
| 15 |
| 16 const workerUrl = 'resources/empty-worker.js'; |
| 17 const scope = 'resources/scope/' + location.pathname; |
| 18 |
| 19 promise_test(function(test) { |
| 20 return service_worker_unregister_and_register(test, workerUrl, scope) |
| 21 .then(registration => { |
| 22 assert_equals(null, registration.active); |
| 23 return registration.backgroundFetch.get('tag'); |
| 24 }) |
| 25 .then(unreached_fulfillment(test), error => { |
| 26 assert_equals(error.name, 'TypeError'); |
| 27 }); |
| 28 |
| 29 }, 'BackgroundFetchManager.get() requires an activated Service Worker.'); |
| 30 |
| 31 promise_test(function(test) { |
| 32 let registration = null; |
| 33 |
| 34 return service_worker_unregister_and_register(test, workerUrl, scope) |
| 35 .then(r => { |
| 36 registration = r; |
| 37 return wait_for_state(test, r.installing, 'activated'); |
| 38 }) |
| 39 .then(() => registration.backgroundFetch.get('invalid-fetch-tag')) |
| 40 .then(backgroundFetchRegistration => { |
| 41 assert_equals(backgroundFetchRegistration, null); |
| 42 }); |
| 43 |
| 44 }, 'BackgroundFetchManager.get() returns NULL for non-existing fetches.'); |
| 45 </script> |
OLD | NEW |