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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Created 4 years, 3 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/body-mixin.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js b/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js
index c391b7930e48992072dad6d4a30f56cd717e5d95..c1709640e69afdb73e37e52c34e29f950f4650b5 100644
--- a/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js
+++ b/third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/body-mixin.js
@@ -103,6 +103,25 @@ promise_test(function(test) {
.then(function(res) {
response = res;
assert_false(response.bodyUsed);
+ var p = response.formData();
+ assert_true(response.bodyUsed);
+ assert_true(isLocked(response.body));
+ return p;
+ })
+ .then(
+ test.unreached_func('formData() must fail'),
yhirano 2016/09/26 10:59:33 Please use unreached_fulfillment.
e_hakkinen 2016/09/28 15:15:04 Done.
+ function(e) {
+ assert_true(isLocked(response.body));
+ assert_equals(e.name, 'TypeError', 'expected MIME type error');
+ })
+ }, 'FormDataFailedTest');
+
+promise_test(function(test) {
+ var response;
+ return fetch('/fetch/resources/doctype.html')
+ .then(function(res) {
+ response = res;
+ assert_false(response.bodyUsed);
var p = response.json();
assert_true(response.bodyUsed);
assert_true(isLocked(response.body));
@@ -245,6 +264,14 @@ promise_test(t => {
promise_test(t => {
var res = new Response('');
res.body.cancel();
+ return res.formData().then(unreached_fulfillment(t), e => {
+ assert_equals(e.name, 'TypeError');
+ });
+ }, 'Used => formData');
+
+promise_test(t => {
+ var res = new Response('');
+ res.body.cancel();
return res.json().then(unreached_fulfillment(t), e => {
assert_equals(e.name, 'TypeError');
});
@@ -280,6 +307,15 @@ promise_test(t => {
promise_test(t => {
var res = new Response('');
const reader = res.body.getReader();
+ return res.formData().then(unreached_fulfillment(t), e => {
+ reader.releaseLock();
+ assert_equals(e.name, 'TypeError');
+ });
+ }, 'Locked => formData');
+
+promise_test(t => {
+ var res = new Response('');
+ const reader = res.body.getReader();
return res.json().then(unreached_fulfillment(t), e => {
reader.releaseLock();
assert_equals(e.name, 'TypeError');

Powered by Google App Engine
This is Rietveld 408576698