提交 e428559a 编写于 作者: Z Zirak

Fixed uncaught error when a body was consumed more than once.

Ammended tets to also check error message, not just type.
上级 ea501dc3
......@@ -63,7 +63,7 @@
function consumed(body) {
if (body.bodyUsed) {
return new Promise.reject(new TypeError('Body already consumed'))
return Promise.reject(new TypeError('Body already consumed'))
}
body.bodyUsed = true
}
......
......@@ -150,32 +150,35 @@ asyncTest('post sets content-type header', 1, function() {
})
})
asyncTest('rejects blob promise after body is consumed', 1, function() {
asyncTest('rejects blob promise after body is consumed', 2, function() {
fetch('/hello').then(function(response) {
response.blob()
return response.blob()
}).catch(function(error) {
ok(error instanceof TypeError, 'Promise rejected after body consumed')
ok(error.message === 'Body already consumed', 'Promise rejected for incorrect reason')
start()
})
})
asyncTest('rejects json promise after body is consumed', 1, function() {
asyncTest('rejects json promise after body is consumed', 2, function() {
fetch('/json').then(function(response) {
response.json()
return response.json()
}).catch(function(error) {
ok(error instanceof TypeError, 'Promise rejected after body consumed')
ok(error.message === 'Body already consumed', 'Promise rejected for incorrect reason')
start()
})
})
asyncTest('rejects text promise after body is consumed', 1, function() {
asyncTest('rejects text promise after body is consumed', 2, function() {
fetch('/hello').then(function(response) {
response.text()
return response.text()
}).catch(function(error) {
ok(error instanceof TypeError, 'Promise rejected after body consumed')
ok(error.message === 'Body already consumed', 'Promise rejected for incorrect reason')
start()
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册