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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Created 4 years, 4 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/http/tests/fetch/script-tests/response-content.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js b/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js
index 0a9fe017fef3e0479d55208bf873148cdd0d1d3f..b442a7268f88d6382cfc8a7b28b3107b014d2a53 100644
--- a/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js
+++ b/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/response-content.js
@@ -78,7 +78,7 @@ promise_test(function() {
});
}, 'Behavior of Response with ArrayBufferView content with a slice.');
-promise_test(function() {
+promise_test(function(t) {
var formData = new FormData();
formData.append('sample string', '1234567890');
formData.append('sample blob', new Blob(['blob content']));
@@ -111,7 +111,19 @@ promise_test(function() {
assert_equals(
result, expected_body,
'Creating a Response with FormData body must succeed.');
- });
+ response = new Response(
+ expected_body, {headers: [['Content-Type', regResult[0]]]});
+ return response.formData();
+ })
+ .then(function(result) {
+ assert_equals(result.get('sample string'),
+ formData.get('sample string'));
+ assert_equals(result.get('sample blob').size,
+ formData.get('sample blob').size);
horo 2016/08/30 05:12:55 Please check the content of the blob and .name and
e_hakkinen 2016/08/30 07:59:08 Done.
+ assert_equals(result.get('sample file').size,
+ formData.get('sample file').size);
+ })
horo 2016/08/30 05:12:55 ditto
e_hakkinen 2016/08/30 07:59:08 Done.
+ .catch(unreached_rejection(t));
horo 2016/08/30 05:12:55 You don't need this catch. promise_test() checks i
e_hakkinen 2016/08/30 07:59:08 Done.
}, 'Behavior of Response with FormData content');
promise_test(function() {
@@ -125,9 +137,22 @@ promise_test(function() {
'A Response constructed with a URLSearchParams should have a Content-Type.');
return response.text()
.then(function(result) {
+ const expected_body =
+ 'sample+string=1234567890&sample+string+2=1234567890+%26+2';
assert_equals(
- result, 'sample+string=1234567890&sample+string+2=1234567890+%26+2',
+ result, expected_body,
'Creating a Response with URLSearchParams body must succeed.');
+ response = new Response(
+ expected_body, {headers: [
+ ['Content-Type',
+ 'application/x-www-form-urlencoded; charset=UTF-8']]});
+ return response.formData();
+ })
+ .then(function(result) {
+ assert_equals(result.get('sample string'),
+ urlSearchParams.get('sample string'));
+ assert_equals(result.get('sample string 2'),
+ urlSearchParams.get('sample string 2'));
});
}, 'Behavior of Response with URLSearchParams content');

Powered by Google App Engine
This is Rietveld 408576698