diff options
author | Ms2ger <ms2ger@gmail.com> | 2016-02-01 09:19:46 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2016-02-01 17:25:22 +0100 |
commit | 73bc5cf1b80992a2920c169dcdd66f06e2386adf (patch) | |
tree | 0820b05524e7d34197110c5365dafd8cec818c81 /tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js | |
parent | 6b1a08c051f3be4b7bc7e6200053dfa530ecd106 (diff) | |
download | servo-73bc5cf1b80992a2920c169dcdd66f06e2386adf.tar.gz servo-73bc5cf1b80992a2920c169dcdd66f06e2386adf.zip |
Update web-platform-tests to revision 7f2f85a88f434798e9d643427b34b05fab8278c6
Diffstat (limited to 'tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js')
-rw-r--r-- | tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js b/tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js new file mode 100644 index 00000000000..775466799cd --- /dev/null +++ b/tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js @@ -0,0 +1,39 @@ +if (this.document === undefined) { + importScripts("/resources/testharness.js"); + importScripts("../resources/utils.js"); +} + +function checkFetchResponse(url, data, mime) { + var cut = (url.length >= 40) ? "[...]" : ""; + desc = "Fetching " + url.substring(0, 40) + cut + " is OK" + promise_test(function(test) { + return fetch(url).then(function(resp) { + assert_equals(resp.status, 200, "HTTP status is 200"); + assert_equals(resp.type, "basic", "response type is basic"); + assert_equals(resp.headers.get("Content-Type"), mime, "Content-Type is " + resp.headers.get("Content-Type")); + return resp.text(); + }).then(function(body) { + assert_equals(body, data, "Response's body is correct"); + }); + }, desc); +} + +checkFetchResponse("data:,response%27s%20body", "response's body", "text/plain;charset=US-ASCII"); +checkFetchResponse("data:text/plain;base64,cmVzcG9uc2UncyBib2R5", "response's body", "text/plain"); +checkFetchResponse("data:image/png;base64,cmVzcG9uc2UncyBib2R5", + "response's body", + "image/png"); + +function checkKoUrl(url, method, desc) { + var cut = (url.length >= 40) ? "[...]" : ""; + desc = "Fetching [" + method + "] " + url.substring(0, 45) + cut + " is KO" + promise_test(function(test) { + return promise_rejects(test, new TypeError(), fetch(url, {"method": method})); + }, desc); +} + +checkKoUrl("data:notAdataUrl.com", "GET"); +checkKoUrl("data:,response%27s%20body", "POST"); +checkKoUrl("data:,response%27s%20body", "HEAD"); + +done(); |