diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/xhr/send-content-type-charset.htm | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/xhr/send-content-type-charset.htm')
-rw-r--r-- | testing/web-platform/tests/xhr/send-content-type-charset.htm | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/testing/web-platform/tests/xhr/send-content-type-charset.htm b/testing/web-platform/tests/xhr/send-content-type-charset.htm new file mode 100644 index 0000000000..a968bb3f4d --- /dev/null +++ b/testing/web-platform/tests/xhr/send-content-type-charset.htm @@ -0,0 +1,115 @@ +<!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> + </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 !== null) + 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( + "", + "", + "header with invalid MIME type (empty string) 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", + "If charset= param is UTF-8 (case-insensitive), it should not be changed" + ) + 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/plain; hi=bye", + "text/plain; hi=bye", + "If no charset= param is given, implementation should not add one - known MIME, unknown param, two spaces" + ) + 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=waddup", + "If charset= param is UTF-8 (case-insensitive), it should not be changed (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", + "Multiple non-UTF-8 charset parameters deduplicate, bogus parameter dropped" + ) + request( + null, + "text/plain;charset=UTF-8", + "No content type set, give MIME and charset" + ) + request( + "text/plain;charset= utf-8", + "text/plain;charset=UTF-8", + "charset with leading space that is UTF-8 does change") + request( + "text/plain;charset=utf-8 ;x=x", + "text/plain;charset=utf-8 ;x=x", + "charset with trailing space that is UTF-8 does not change"); + request( + "text/plain;charset=\"utf-8\"", + "text/plain;charset=\"utf-8\"", + "charset in double quotes that is UTF-8 does not change") + request( + "text/plain;charset=\" utf-8\"", + "text/plain;charset=UTF-8", + "charset in double quotes with space") + request( + "text/plain;charset=\"u\\t\\f-8\"", + "text/plain;charset=\"u\\t\\f-8\"", + "charset in double quotes with backslashes that is UTF-8 does not change") + request( + "YO/yo;charset=x;yo=YO; X=y", + "yo/yo;charset=UTF-8;yo=YO;x=y", + "unknown parameters need to be preserved") + </script> + </body> +</html> |