Bug 1508360 [wpt PR 14128] - [Background Fetch] Remove chromium specific WPT code, a=testonly

Automatic update from web-platform-tests[Background Fetch] Remove chromium specific WPT code

Also add an upload endpoint to test Background Fetch uploads.

Bug: 774054
Change-Id: I305e9f43b5d2e77a8e78e9e460e8398d771b03e0
Reviewed-on: https://chromium-review.googlesource.com/c/1341923
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609394}

--

wpt-commits: dcda413dc629781f75684101e9f8ec7d122fa30b
wpt-pr: 14128
This commit is contained in:
Rayan Kanso 2018-11-22 10:34:18 +00:00 коммит произвёл moz-wptsync-bot
Родитель 11e9adad75
Коммит 9a5b791909
4 изменённых файлов: 31 добавлений и 25 удалений

Просмотреть файл

@ -8,7 +8,7 @@
backgroundFetchTest(async (test, backgroundFetch) => {
const registration = await backgroundFetch.fetch(
uniqueId(),
['resources/feature-name.txt', '/serviceworker/resources/slow-response.php']);
['resources/feature-name.txt', '/common/slow.py']);
assert_true(await registration.abort());
assert_false(await registration.abort());
@ -18,7 +18,7 @@ backgroundFetchTest(async (test, backgroundFetch) => {
backgroundFetchTest(async (test, backgroundFetch) => {
const registration = await backgroundFetch.fetch(
uniqueId(),
['resources/feature-name.txt', '/serviceworker/resources/slow-response.php']);
['resources/feature-name.txt', '/common/slow.py']);
await new Promise(resolve => {
let aborted = false;
@ -63,7 +63,7 @@ backgroundFetchTest(async (test, backgroundFetch) => {
backgroundFetchTest(async (test, backgroundFetch) => {
const registration = await backgroundFetch.fetch(
uniqueId(), '/serviceworker/resources/slow-response.php');
uniqueId(), '/common/slow.py');
assert_true(await registration.abort());
const {results} = await getMessageFromServiceWorker();

Просмотреть файл

@ -0,0 +1,23 @@
// 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().
// Specifically, when `fetch` contains request uploads.
// https://wicg.github.io/background-fetch/#background-fetch-manager-fetch
backgroundFetchTest(async (test, backgroundFetch) => {
const uploadData = 'Background Fetch!';
const request =
new Request('resources/upload.py', {method: 'POST', body: uploadData});
await backgroundFetch.fetch(uniqueId(), request);
const {type, eventRegistration, results} = await getMessageFromServiceWorker();
assert_equals(type, 'backgroundfetchsuccess');
assert_equals(results.length, 1);
assert_equals(eventRegistration.result, 'success');
assert_equals(eventRegistration.failureReason, '');
assert_equals(results[0].text, uploadData);
}, 'Fetch with an upload should work');

Просмотреть файл

@ -195,27 +195,6 @@ backgroundFetchTest(async (test, backgroundFetch) => {
}, 'Fetches can have requests with duplicate URLs');
backgroundFetchTest(async (test, backgroundFetch) => {
const request =
new Request('resources/feature-name.txt',
{method: 'POST', body: 'TestBody'});
const registration = await backgroundFetch.fetch('my-id', request);
const {type, eventRegistration, results} = await getMessageFromServiceWorker();
assert_equals('backgroundfetchsuccess', type);
assert_equals(results.length, 1);
assert_equals(eventRegistration.id, registration.id);
assert_equals(eventRegistration.failureReason, '');
assert_true(results[0].url.includes('resources/feature-name.txt'));
assert_equals(results[0].status, 200);
assert_equals(results[0].text, 'Background Fetch');
}, 'Fetches can have requests with a body');
backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = uniqueId();
const registration =
@ -319,4 +298,5 @@ backgroundFetchTest(async (test, backgroundFetch) => {
assert_equals(eventRegistration.result, 'success');
assert_equals(eventRegistration.failureReason, '');
}, 'Matching to a non-existing request should work');
}, 'Matching to a non-existing request should work');

Просмотреть файл

@ -0,0 +1,3 @@
# Simply returns the request body to check if the upload succeeded.
def main(request, response):
return 200, [("Content-Type", request.headers['content-type'])], request.body