| Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-consume-empty.html
|
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-consume-empty.html b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-consume-empty.html
|
| index c3ca8383a9521268c0330ca24d1e0ba5ba248f81..c84d2cecd3799967d6a1e371a5142d28a927c4b5 100644
|
| --- a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-consume-empty.html
|
| +++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/request/request-consume-empty.html
|
| @@ -11,14 +11,14 @@
|
| </head>
|
| <body>
|
| <script>
|
| - function checkBodyText(request) {
|
| + function checkBodyText(test, request) {
|
| return request.text().then(function(bodyAsText) {
|
| assert_equals(bodyAsText, "", "Resolved value should be empty");
|
| assert_false(request.bodyUsed);
|
| });
|
| }
|
|
|
| - function checkBodyBlob(request) {
|
| + function checkBodyBlob(test, request) {
|
| return request.blob().then(function(bodyAsBlob) {
|
| var promise = new Promise(function(resolve, reject) {
|
| var reader = new FileReader();
|
| @@ -37,14 +37,14 @@
|
| });
|
| }
|
|
|
| - function checkBodyArrayBuffer(request) {
|
| + function checkBodyArrayBuffer(test, request) {
|
| return request.arrayBuffer().then(function(bodyAsArrayBuffer) {
|
| assert_equals(bodyAsArrayBuffer.byteLength, 0, "Resolved value should be empty");
|
| assert_false(request.bodyUsed);
|
| });
|
| }
|
|
|
| - function checkBodyJSON(request) {
|
| + function checkBodyJSON(test, request) {
|
| return request.json().then(
|
| function(bodyAsJSON) {
|
| assert_unreached("JSON parsing should fail");
|
| @@ -54,27 +54,34 @@
|
| });
|
| }
|
|
|
| - function checkBodyFormData(request) {
|
| + function checkBodyFormData(test, request) {
|
| return request.formData().then(function(bodyAsFormData) {
|
| assert_true(bodyAsFormData instanceof FormData, "Should receive a FormData");
|
| assert_false(request.bodyUsed);
|
| });
|
| }
|
|
|
| - function checkRequestWithNoBody(bodyType, checkFunction) {
|
| + function checkBodyFormDataError(test, request) {
|
| + return promise_rejects(test, new TypeError(), request.formData()).then(function() {
|
| + assert_false(request.bodyUsed);
|
| + });
|
| + }
|
| +
|
| + function checkRequestWithNoBody(bodyType, checkFunction, headers = []) {
|
| promise_test(function(test) {
|
| - var request = new Request("", {"method": "POST"});
|
| + var request = new Request("", {"method": "POST", "headers": headers});
|
| assert_false(request.bodyUsed);
|
| - return checkFunction(request);
|
| + return checkFunction(test, request);
|
| }, "Consume request's body as " + bodyType);
|
| }
|
|
|
| - var formData = new FormData();
|
| checkRequestWithNoBody("text", checkBodyText);
|
| checkRequestWithNoBody("blob", checkBodyBlob);
|
| checkRequestWithNoBody("arrayBuffer", checkBodyArrayBuffer);
|
| - checkRequestWithNoBody("json", checkBodyJSON);
|
| - checkRequestWithNoBody("formData", checkBodyFormData);
|
| + checkRequestWithNoBody("json (error case)", checkBodyJSON);
|
| + checkRequestWithNoBody("formData with correct multipart type (error case)", checkBodyFormDataError, [["Content-Type", 'multipart/form-data; boundary="boundary"']]);
|
| + checkRequestWithNoBody("formData with correct urlencoded type", checkBodyFormData, [["Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"]]);
|
| + checkRequestWithNoBody("formData without correct type (error case)", checkBodyFormDataError);
|
|
|
| function checkRequestWithEmptyBody(bodyType, body, asText) {
|
| promise_test(function(test) {
|
|
|