mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Update web-platform-tests to revision 66c4613f823c4384c78ada77346eda17bb128947
This commit is contained in:
parent
183772583f
commit
a91433f0c8
234 changed files with 4368 additions and 967 deletions
|
@ -8,6 +8,7 @@
|
|||
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../resources/utils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
@ -39,16 +40,14 @@
|
|||
|
||||
function checkBodyArrayBuffer(response, expectedBody) {
|
||||
return response.arrayBuffer().then( function(bodyAsArrayBuffer) {
|
||||
var decoder = new TextDecoder("utf-8");
|
||||
var strBody = decoder.decode(bodyAsArrayBuffer);
|
||||
assert_equals(strBody, expectedBody, "Retrieve and verify response's body");
|
||||
validateBufferFromString(bodyAsArrayBuffer, expectedBody, "Retrieve and verify response's body");
|
||||
assert_true(response.bodyUsed, "body as arrayBuffer: bodyUsed turned true");
|
||||
});
|
||||
}
|
||||
|
||||
function checkBodyJson(response, expectedBody) {
|
||||
return response.json().then(function(bodyAsJson) {
|
||||
var strBody = JSON.stringify(bodyAsJson)
|
||||
function checkBodyJSON(response, expectedBody) {
|
||||
return response.json().then(function(bodyAsJSON) {
|
||||
var strBody = JSON.stringify(bodyAsJSON)
|
||||
assert_equals(strBody, expectedBody, "Retrieve and verify response's body");
|
||||
assert_true(response.bodyUsed, "body as json: bodyUsed turned true");
|
||||
});
|
||||
|
@ -70,12 +69,29 @@
|
|||
}
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append("name", "value")
|
||||
checkResponseBody("This is response's body", "text", checkBodyText);
|
||||
checkResponseBody("This is response's body", "blob", checkBodyBlob);
|
||||
checkResponseBody("This is response's body", "arrayBuffer", checkBodyArrayBuffer);
|
||||
checkResponseBody(JSON.stringify("This is response's body"), "json", checkBodyJson);
|
||||
formData.append("name", "value");
|
||||
var textData = JSON.stringify("This is response's body");
|
||||
var blob = new Blob([textData], { "type" : "text/plain" });
|
||||
|
||||
checkResponseBody(textData, "text", checkBodyText);
|
||||
checkResponseBody(textData, "blob", checkBodyBlob);
|
||||
checkResponseBody(textData, "arrayBuffer", checkBodyArrayBuffer);
|
||||
checkResponseBody(textData, "json", checkBodyJSON);
|
||||
checkResponseBody(formData, "formData", checkBodyFormData);
|
||||
|
||||
function checkBlobResponseBody(blobBody, blobData, bodyType, checkFunction) {
|
||||
promise_test(function(test) {
|
||||
var response = new Response(blobBody);
|
||||
assert_false(response.bodyUsed, "bodyUsed is false at init");
|
||||
return checkFunction(response, blobData);
|
||||
}, "Consume blob response's body as " + bodyType);
|
||||
}
|
||||
|
||||
checkBlobResponseBody(blob, textData, "blob", checkBodyBlob);
|
||||
checkBlobResponseBody(blob, textData, "text", checkBodyText);
|
||||
checkBlobResponseBody(blob, textData, "json", checkBodyJSON);
|
||||
checkBlobResponseBody(blob, textData, "arrayBuffer", checkBodyArrayBuffer);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue