diff options
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.js | 33 |
1 files changed, 32 insertions, 1 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 98ecdfa3933..b8b1ff0983c 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 @@ -70,6 +70,21 @@ backgroundFetchTest(async (test, backgroundFetch) => { backgroundFetchTest(async (test, backgroundFetch) => { const registrationId = uniqueId(); const registration = + await backgroundFetch.fetch(registrationId, ''); + + assert_equals(registration.id, registrationId); + + const {type, eventRegistration, results} = await getMessageFromServiceWorker(); + + assert_equals('backgroundfetchsuccess', type); + assert_equals(eventRegistration.result, 'success'); + assert_equals(eventRegistration.failureReason, ''); + +}, 'Empty URL is OK.'); + +backgroundFetchTest(async (test, backgroundFetch) => { + const registrationId = uniqueId(); + const registration = await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt'); assert_equals(registration.id, registrationId); @@ -190,4 +205,20 @@ backgroundFetchTest(async (test, backgroundFetch) => { assert_equals(eventRegistration.result, 'failure'); assert_equals(eventRegistration.failureReason, 'bad-status'); -}, 'Using Background Fetch to fetch a non-existent resource should fail.');
\ No newline at end of file +}, 'Using Background Fetch to fetch a non-existent resource should fail.'); + +backgroundFetchTest(async (test, backgroundFetch) => { + const registration = await backgroundFetch.fetch( + 'my-id', + ['https://example.com', 'http://example.com']); + + const {type, eventRegistration, results} = await getMessageFromServiceWorker(); + + assert_equals('backgroundfetchfail', type); + assert_equals(eventRegistration.failureReason, 'fetch-error'); + + assert_equals(results.length, 2); + assert_true(results[0].url.includes('https://example.com')); + assert_equals(results[1].url, ''); + +}, 'Fetches with mixed content should fail.'); |