Skip to content

Commit

Permalink
Fetch: change Response's statusText's default
Browse files Browse the repository at this point in the history
See whatwg/fetch#836 for context.

This also cleans up the code a bit.
  • Loading branch information
annevk authored and Ms2ger committed Nov 20, 2018
1 parent 3557c53 commit 99e9e99
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions fetch/api/response/response-init-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"url" : "",
"ok" : true,
"status" : 200,
"statusText" : "OK",
"statusText" : "",
"body" : null
};

var statusCodes = { "givenValues" : [200, 300, 400, 500, 599],
"expectedValues" : [200, 300, 400, 500, 599]
"expectedValues" : [200, 300, 400, 500, 599]
};
var statusTexts = { "givenValues" : ["OK", "with space", String.fromCharCode(0x80)],
"expectedValues" : ["OK", "with space", String.fromCharCode(0x80)]
var statusTexts = { "givenValues" : ["", "OK", "with space", String.fromCharCode(0x80)],
"expectedValues" : ["", "OK", "with space", String.fromCharCode(0x80)]
};
var initValuesDict = { "status" : statusCodes,
"statusText" : statusTexts
Expand All @@ -42,7 +42,7 @@
}, "Check default value for " + attributeName + " attribute");
}

for (var attributeName in initValuesDict)
for (var attributeName in initValuesDict) {
test(function() {
var valuesToTest = initValuesDict[attributeName];
for (var valueIdx in valuesToTest["givenValues"]) {
Expand All @@ -58,19 +58,20 @@
"Expect response.ok is " + isOkStatus(response.status));
}
}, "Check " + attributeName + " init values and associated getter");
}

test(function() {
const response1 = new Response("");
assert_equals(response1.headers, response1.headers);
test(function() {
const response1 = new Response("");
assert_equals(response1.headers, response1.headers);

const response2 = new Response("", {"headers": {"X-Foo": "bar"}});
assert_equals(response2.headers, response2.headers);
const headers = response2.headers;
response2.headers.set("X-Foo", "quux");
assert_equals(headers, response2.headers);
headers.set("X-Other-Header", "baz");
assert_equals(headers, response2.headers);
}, "Test that Response.headers has the [SameObject] extended attribute");
const response2 = new Response("", {"headers": {"X-Foo": "bar"}});
assert_equals(response2.headers, response2.headers);
const headers = response2.headers;
response2.headers.set("X-Foo", "quux");
assert_equals(headers, response2.headers);
headers.set("X-Other-Header", "baz");
assert_equals(headers, response2.headers);
}, "Test that Response.headers has the [SameObject] extended attribute");
</script>
</body>
</html>

0 comments on commit 99e9e99

Please sign in to comment.