Bug 1774120 [wpt PR 34418] - Fix streaming upload tests, a=testonly

Automatic update from web-platform-tests
Fix streaming upload tests

 - Streaming upload is disabled on HTTP/1.1. Move some tests to the
   h2 file.
 - Explicitly test that streaming upload is blocked on HTTP/1.1.

421 handling hasn't been implemented yet.

Also fix the implementation which blocked CORS requests unintentionally.

Change-Id: I8da8ea411ae6d55e2d7dfddc34f3da529651aa7f
Bug: 1234368
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3699531
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014859}

--

wpt-commits: d387101095115f28446dbf2da77fb64dea697815
wpt-pr: 34418
This commit is contained in:
Yutaka Hirano 2022-06-21 09:56:40 +00:00 коммит произвёл moz-wptsync-bot
Родитель 7c2c7557cd
Коммит e04eea5b5a
2 изменённых файлов: 48 добавлений и 42 удалений

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

@ -129,44 +129,6 @@ promise_test(async (test) => {
}, "Fetch with POST with text body on 421 response should be retried once on new connection.");
promise_test(async (test) => {
const body = new ReadableStream({start: controller => {
const encoder = new TextEncoder();
controller.enqueue(encoder.encode("Test"));
controller.close();
}});
const resp = await fetch(
"/fetch/connection-pool/resources/network-partition-key.py?"
+ `status=421&uuid=${token()}&partition_id=${get_host_info().ORIGIN}`
+ `&dispatch=check_partition&addcounter=true`,
{method: "POST", body: body});
assert_equals(resp.status, 421);
const text = await resp.text();
assert_equals(text, "ok. Request was sent 1 times. 1 connections were created.");
}, "Fetch with POST with ReadableStream on 421 response should return the response and not retry.");
promise_test(async (test) => {
const request = new Request('', {
body: new ReadableStream(),
method: 'POST',
});
assert_equals(request.headers.get('Content-Type'), null, `Request should not have a content-type set`);
const response = await fetch('data:a/a;charset=utf-8,test', {
method: 'POST',
body: new ReadableStream(),
});
assert_equals(await response.text(), 'test', `Response has correct body`);
}, "Feature detect for POST with ReadableStream");
promise_test(async (test) => {
const request = new Request('data:a/a;charset=utf-8,test', {
body: new ReadableStream(),
method: 'POST',
});
assert_equals(request.headers.get('Content-Type'), null, `Request should not have a content-type set`);
const response = await fetch(request);
assert_equals(await response.text(), 'test', `Response has correct body`);
}, "Feature detect for POST with ReadableStream, using request object");
const body = new ReadableStream({start: c => c.close()});
await promise_rejects_js(test, TypeError, fetch('/', {method: 'POST', body}));
}, "Streaming upload shouldn't work on Http/1.1.");

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

@ -5,7 +5,7 @@
function testUpload(desc, url, method, createBody, expectedBody) {
const requestInit = {method};
promise_test(async function(){
promise_test(async () => {
const body = createBody();
if (body) {
requestInit["body"] = body;
@ -37,3 +37,47 @@ testUpload("Fetch with POST with ReadableStream", url,
}})
},
"Test");
promise_test(async (test) => {
const body = new ReadableStream({start: controller => {
const encoder = new TextEncoder();
controller.enqueue(encoder.encode("Test"));
controller.close();
}});
const resp = await fetch(
"/fetch/connection-pool/resources/network-partition-key.py?"
+ `status=421&uuid=${token()}&partition_id=${self.origin}`
+ `&dispatch=check_partition&addcounter=true`,
{method: "POST", body: body});
assert_equals(resp.status, 421);
const text = await resp.text();
assert_equals(text, "ok. Request was sent 1 times. 1 connections were created.");
}, "Fetch with POST with ReadableStream on 421 response should return the response and not retry.");
promise_test(async (test) => {
const request = new Request('', {
body: new ReadableStream(),
method: 'POST',
});
assert_equals(request.headers.get('Content-Type'), null, `Request should not have a content-type set`);
const response = await fetch('data:a/a;charset=utf-8,test', {
method: 'POST',
body: new ReadableStream(),
});
assert_equals(await response.text(), 'test', `Response has correct body`);
}, "Feature detect for POST with ReadableStream");
promise_test(async (test) => {
const request = new Request('data:a/a;charset=utf-8,test', {
body: new ReadableStream(),
method: 'POST',
});
assert_equals(request.headers.get('Content-Type'), null, `Request should not have a content-type set`);
const response = await fetch(request);
assert_equals(await response.text(), 'test', `Response has correct body`);
}, "Feature detect for POST with ReadableStream, using request object");