Bug 1184550 - Add a mochitest for the Request constructor that tests that the body is set to used after being fetched and then fails on the second fetch with the same Request. r=bkelly

This commit is contained in:
Thomas Kuyper 2016-01-14 08:59:00 -05:00
Родитель 2ae35fec9a
Коммит 5244c3a2d4
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -124,6 +124,19 @@ function testBug1109574() {
var r3 = new Request(r1);
}
// Bug 1184550 - Request constructor should always throw if used flag is set,
// even if body is null
function testBug1184550() {
var req = new Request("", { method: 'post', body: "Test" });
fetch(req);
ok(req.bodyUsed, "Request body should be used immediately after fetch()");
return fetch(req).then(function(resp) {
ok(false, "Second fetch with same request should fail.");
}).catch(function(err) {
is(err.name, 'TypeError', "Second fetch with same request should fail.");
});
}
function testHeaderGuard() {
var headers = {
"Cookie": "Custom cookie",
@ -500,6 +513,7 @@ function runTest() {
testUrlMalformed();
testMethod();
testBug1109574();
testBug1184550();
testHeaderGuard();
testModeCorsPreflightEnumValue();
testBug1154268();