aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js')
-rw-r--r--tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js b/tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js
index 6a8cf6c0e3a..35b5709d22b 100644
--- a/tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js
+++ b/tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js
@@ -1,5 +1,7 @@
+// META: script=/common/get-host-info.sub.js
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
// META: script=resources/utils.js
+
'use strict';
// Covers basic functionality provided by BackgroundFetchManager.fetch().
@@ -324,3 +326,43 @@ backgroundFetchTest(async (test, backgroundFetch) => {
assert_equals(results[1].text, 'Background Fetch');
}, 'Matching multiple times on the same request works as expected.');
+
+backgroundFetchTest(async (test, backgroundFetch) => {
+ const filePath = '/background-fetch/resources/feature-name.txt';
+ const registration = await backgroundFetch.fetch(
+ uniqueId(),
+ `https://${get_host_info().REMOTE_HOST}${filePath}`);
+
+ const {type, eventRegistration, results} = await getMessageFromServiceWorker();
+ assert_equals(type, 'backgroundfetchfail');
+ assert_equals(results.length, 1);
+
+ assert_equals(results[0], null);
+ assert_equals(eventRegistration.id, registration.id);
+ assert_equals(eventRegistration.downloaded, 0);
+}, 'Responses failing CORS checks are not leaked');
+
+backgroundFetchTest(async (test, backgroundFetch) => {
+ const registration = await backgroundFetch.fetch(
+ uniqueId(), ['resources/feature-name.txt', '/common/slow.py']);
+
+ const record = await registration.match('resources/feature-name.txt');
+
+ await new Promise(resolve => {
+ const expectedResultText = 'Background Fetch';
+
+ registration.onprogress = async event => {
+ if (event.target.downloaded < expectedResultText.length)
+ return;
+
+ const response = await record.responseReady;
+
+ assert_true(response.url.includes('resources/feature-name.txt'));
+ const completedResponseText = await response.text();
+ assert_equals(completedResponseText, expectedResultText);
+
+ resolve();
+ };
+ });
+
+}, 'Access to active fetches is supported.');