Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-fetch.https.html

Issue 2745543002: Implement BackgroundFetchManager::{get, fetch}() (Closed)
Patch Set: more webexposed tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-fetch.https.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-fetch.https.html b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-fetch.https.html
new file mode 100644
index 0000000000000000000000000000000000000000..365995f982f0c6c1e6be591bab46df9faa42ca73
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-fetch.https.html
@@ -0,0 +1,67 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Background Fetch API: fetch() tests</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/serviceworker/resources/test-helpers.js"></script>
+
+<h1>BackgroundFetchManager.fetch()</h1>
+<p>This test validates the behaviour of the fetch() 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.fetch('tag', ['resources/non-existing-file.png']);
+ })
+ .then(unreached_fulfillment(test), error => {
+ assert_equals(error.name, 'TypeError');
+ });
+
+}, 'BackgroundFetchManager.fetch() requires an activated Service Worker.');
+
+promise_test(function(test) {
+ const tag = 'my-background-fetch';
+ const options = {
+ icons: [
+ {
+ src: 'resources/non-existing-large-icon.png',
+ sizes: '256x256',
+ type: 'image/png'
+ },
+ {
+ src: 'resources/non-existing-small-icon.jpg',
+ sizes: '64x64',
+ type: 'image/jpg'
+ }
+ ],
+ title: 'My Background Fetch',
+ totalDownloadSize: 1024
+ };
+
+ 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.fetch(tag, ['resources/non-existing-file.png'], options))
+ .then(backgroundFetchRegistration => {
+ assert_true(backgroundFetchRegistration instanceof BackgroundFetchRegistration);
+ assert_equals(backgroundFetchRegistration.tag, tag);
+ assert_object_equals(backgroundFetchRegistration.icons, options.icons);
+ assert_equals(backgroundFetchRegistration.totalDownloadSize, options.totalDownloadSize);
+ assert_equals(backgroundFetchRegistration.title, options.title);
+ });
+
+}, 'BackgroundFetchManager.fetch() returns a BackgroundFetchRegistration object.');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698