Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-empty.html

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: LayoutTests, FetchDataLoader Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-empty.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-empty.html b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-empty.html
index faa443b5e301155c014f0fe0cd268dccfe876444..4bfcfbc8f44617190e9469f7ce85ce6dc91d2df9 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-empty.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/response/response-consume-empty.html
@@ -11,14 +11,14 @@
</head>
<body>
<script>
- function checkBodyText(response) {
+ function checkBodyText(test, response) {
return response.text().then(function(bodyAsText) {
assert_equals(bodyAsText, "", "Resolved value should be empty");
assert_false(response.bodyUsed);
});
}
- function checkBodyBlob(response) {
+ function checkBodyBlob(test, response) {
return response.blob().then(function(bodyAsBlob) {
var promise = new Promise(function(resolve, reject) {
var reader = new FileReader();
@@ -37,14 +37,14 @@
});
}
- function checkBodyArrayBuffer(response) {
+ function checkBodyArrayBuffer(test, response) {
return response.arrayBuffer().then(function(bodyAsArrayBuffer) {
assert_equals(bodyAsArrayBuffer.byteLength, 0, "Resolved value should be empty");
assert_false(response.bodyUsed);
});
}
- function checkBodyJSON(response) {
+ function checkBodyJSON(test, response) {
return response.json().then(
function(bodyAsJSON) {
assert_unreached("JSON parsing should fail");
@@ -54,27 +54,34 @@
});
}
- function checkBodyFormData(response) {
+ function checkBodyFormData(test, response) {
return response.formData().then(function(bodyAsFormData) {
assert_true(bodyAsFormData instanceof FormData, "Should receive a FormData");
assert_false(response.bodyUsed);
});
}
- function checkResponseWithNoBody(bodyType, checkFunction) {
+ function checkBodyFormDataError(test, response) {
+ return promise_rejects(test, new TypeError(), response.formData()).then(function() {
+ assert_false(response.bodyUsed);
+ });
+ }
+
+ function checkResponseWithNoBody(bodyType, checkFunction, headers = []) {
promise_test(function(test) {
- var response = new Response();
+ var response = new Response(undefined, { "headers": headers });
assert_false(response.bodyUsed);
- return checkFunction(response);
+ return checkFunction(test, response);
}, "Consume response's body as " + bodyType);
}
- var formData = new FormData();
checkResponseWithNoBody("text", checkBodyText);
checkResponseWithNoBody("blob", checkBodyBlob);
checkResponseWithNoBody("arrayBuffer", checkBodyArrayBuffer);
- checkResponseWithNoBody("json", checkBodyJSON);
- checkResponseWithNoBody("formData", checkBodyFormData);
+ checkResponseWithNoBody("json (error case)", checkBodyJSON);
+ checkResponseWithNoBody("formData with correct multipart type (error case)", checkBodyFormDataError, [["Content-Type", 'multipart/form-data; boundary="boundary"']]);
+ checkResponseWithNoBody("formData with correct urlencoded type", checkBodyFormData, [["Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"]]);
+ checkResponseWithNoBody("formData without correct type (error case)", checkBodyFormDataError);
function checkResponseWithEmptyBody(bodyType, body, asText) {
promise_test(function(test) {

Powered by Google App Engine
This is Rietveld 408576698