summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm')
-rwxr-xr-xtesting/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm83
1 files changed, 83 insertions, 0 deletions
diff --git a/testing/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm b/testing/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm
new file mode 100755
index 000000000..9e93279d6
--- /dev/null
+++ b/testing/web-platform/tests/XMLHttpRequest/send-content-type-charset.htm
@@ -0,0 +1,83 @@
+<!doctype html>
+<html>
+ <head>
+ <title>XMLHttpRequest: send() - charset parameter of Content-Type</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4]/p/code[contains(text(),'Content-Type')]/.. following::ol[1]/li[4]/p/code[contains(text(),'Content-Type')]/../following-sibling::p" />
+ <link rel="help" href="https://xhr.spec.whatwg.org/#dom-XMLHttpRequest-send-a-string" data-tested-assertations="following::p[2]" />
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ function request(input, output, title) {
+ title = title || document.title + ' - ' + input;
+ test(function() {
+ var client = new XMLHttpRequest()
+ client.open("POST", "resources/content.py", false)
+ if(input)
+ client.setRequestHeader("Content-Type", input)
+ client.send("TEST")
+ assert_equals(client.responseText, "TEST")
+ assert_equals(client.getResponseHeader("x-request-content-type"), output)
+ }, title)
+ }
+
+ request(
+ "text; charset=ascii",
+ "text; charset=ascii",
+ "header with invalid MIME type is not changed"
+ )
+ request(
+ "charset=ascii",
+ "charset=ascii",
+ "known charset but bogus header - missing MIME type"
+ )
+ request(
+ "charset=bogus",
+ "charset=bogus",
+ "bogus charset and bogus header - missing MIME type"
+ )
+ request(
+ "text/plain;charset=utf-8",
+ "text/plain;charset=utf-8",
+ "Correct text/plain MIME with charset"
+ )
+ request(
+ "text/x-pink-unicorn",
+ "text/x-pink-unicorn",
+ "If no charset= param is given, implementation should not add one - unknown MIME"
+ )
+ request(
+ "text/plain",
+ "text/plain",
+ "If no charset= param is given, implementation should not add one - known MIME"
+ )
+ request(
+ "text/x-thepiano;charset= waddup",
+ "text/x-thepiano;charset=UTF-8",
+ "charset given but wrong, fix it (unknown MIME, bogus charset)"
+ )
+ request(
+ "text/plain;charset=utf-8;charset=waddup",
+ "text/plain;charset=utf-8;charset=UTF-8",
+ "charset given but wrong, fix it (known MIME, bogus charset)"
+ )
+ request(
+ "text/plain;charset=shift-jis",
+ "text/plain;charset=UTF-8",
+ "charset given but wrong, fix it (known MIME, actual charset)"
+ )
+ request(
+ "text/x-pink-unicorn; charset=windows-1252; charset=bogus; notrelated; charset=ascii",
+ "text/x-pink-unicorn; charset=UTF-8; charset=UTF-8; notrelated; charset=UTF-8",
+ "If multiple charset parameters are given, all should be rewritten"
+ )
+ request(
+ null,
+ "text/plain;charset=UTF-8",
+ "No content type set, give MIME and charset"
+ )
+ </script>
+ </body>
+</html>