Index: third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f547bcd1c62f8d9e2b2d64bcb075dd6bac4961ba |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html |
@@ -0,0 +1,45 @@ |
+<!doctype html> |
+<meta charset="utf-8"> |
+<title>Background Fetch API: get() tests</title> |
+<script src="/resources/testharness.js"></script> |
+<script src="/resources/testharnessreport.js"></script> |
+<script src="/serviceworker/resources/test-helpers.js"></script> |
+ |
+<h1>BackgroundFetchManager.get()</h1> |
+<p>This test validates the behaviour of the get() method.</p> |
+ |
+<!-- TODO(peter): Move this to the WPT directory when it's merged. --> |
+ |
+<script> |
+'use strict'; |
+ |
+const workerUrl = 'resources/empty-worker.js'; |
+const scope = 'resources/scope/' + location.pathname; |
+ |
+promise_test(function(test) { |
+ return service_worker_unregister_and_register(test, workerUrl, scope) |
+ .then(registration => { |
+ assert_equals(null, registration.active); |
+ return registration.backgroundFetch.get('tag'); |
+ }) |
+ .then(unreached_fulfillment(test), error => { |
+ assert_equals(error.name, 'TypeError'); |
+ }); |
+ |
+}, 'BackgroundFetchManager.get() requires an activated Service Worker.'); |
+ |
+promise_test(function(test) { |
+ let registration = null; |
+ |
+ return service_worker_unregister_and_register(test, workerUrl, scope) |
+ .then(r => { |
+ registration = r; |
+ return wait_for_state(test, r.installing, 'activated'); |
+ }) |
+ .then(() => registration.backgroundFetch.get('invalid-fetch-tag')) |
+ .then(backgroundFetchRegistration => { |
+ assert_equals(backgroundFetchRegistration, null); |
+ }); |
+ |
+}, 'BackgroundFetchManager.get() returns NULL for non-existing fetches.'); |
+</script> |