diff --git a/testing/web-platform/tests/fetch/api/basic/request-upload.any.js b/testing/web-platform/tests/fetch/api/basic/request-upload.any.js index 6da2c8a38c3c..24f7c5b432ca 100644 --- a/testing/web-platform/tests/fetch/api/basic/request-upload.any.js +++ b/testing/web-platform/tests/fetch/api/basic/request-upload.any.js @@ -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."); diff --git a/testing/web-platform/tests/fetch/api/basic/request-upload.h2.any.js b/testing/web-platform/tests/fetch/api/basic/request-upload.h2.any.js index 00b54150d6f2..355a331c9d63 100644 --- a/testing/web-platform/tests/fetch/api/basic/request-upload.h2.any.js +++ b/testing/web-platform/tests/fetch/api/basic/request-upload.h2.any.js @@ -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"); +