mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update web-platform-tests to revision 7f2f85a88f434798e9d643427b34b05fab8278c6
This commit is contained in:
parent
6b1a08c051
commit
73bc5cf1b8
180 changed files with 5807 additions and 169 deletions
68
tests/wpt/web-platform-tests/fetch/api/resources/utils.js
Normal file
68
tests/wpt/web-platform-tests/fetch/api/resources/utils.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
var inWorker = false;
|
||||
var RESOURCES_DIR = "../resources/";
|
||||
|
||||
try {
|
||||
inWorker = !(self instanceof Window);
|
||||
} catch (e) {
|
||||
inWorker = true;
|
||||
}
|
||||
|
||||
function dirname(path) {
|
||||
return path.replace(/\/[^\/]*$/, '/')
|
||||
}
|
||||
|
||||
function checkRequest(request, ExpectedValuesDict) {
|
||||
for (var attribute in ExpectedValuesDict) {
|
||||
switch(attribute) {
|
||||
case "headers":
|
||||
for (var key of ExpectedValuesDict["headers"].keys()) {
|
||||
assert_equals(request["headers"].get(key), ExpectedValuesDict["headers"].get(key),
|
||||
"Check headers attribute has " + key + ":" + ExpectedValuesDict["headers"].get(key));
|
||||
}
|
||||
break;
|
||||
|
||||
case "body":
|
||||
//for checking body's content, a dedicated asyncronous/promise test should be used
|
||||
assert_true(request["headers"].has("Content-Type") , "Check request has body using Content-Type header")
|
||||
break;
|
||||
|
||||
case "method":
|
||||
case "referrer":
|
||||
case "referrerPolicy":
|
||||
case "credentials":
|
||||
case "cache":
|
||||
case "redirect":
|
||||
case "integrity":
|
||||
case "url":
|
||||
case "destination":
|
||||
assert_equals(request[attribute], ExpectedValuesDict[attribute], "Check " + attribute + " attribute")
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check reader's text content in an asyncronous test
|
||||
function readTextStream(reader, asyncTest, expectedValue, retrievedText) {
|
||||
if (!retrievedText)
|
||||
retrievedText = "";
|
||||
reader.read().then(function(data) {
|
||||
if (!data.done) {
|
||||
var decoder = new TextDecoder();
|
||||
retrievedText += decoder.decode(data.value);
|
||||
readTextStream(reader, asyncTest, expectedValue, retrievedText);
|
||||
return;
|
||||
}
|
||||
asyncTest.step(function() {
|
||||
assert_equals(retrievedText, expectedValue, "Retrieve and verify stream");
|
||||
asyncTest.done();
|
||||
});
|
||||
}).catch(function(e) {
|
||||
asyncTest.step(function() {
|
||||
assert_unreached("Cannot read stream " + e);
|
||||
asyncTest.done();
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue