Index: LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html |
diff --git a/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html b/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aeca10f2a9fe9bc8ba460e8ebda8bfaddbce1ed3 |
--- /dev/null |
+++ b/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html |
@@ -0,0 +1,44 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <meta charset="utf-8"> |
+ <title>XMLHttpRequest: setRequestHeader() value argument checks</title> |
+ <script src="../resources/testharness.js"></script> |
+ <script src="../resources/testharnessreport.js"></script> |
+ <!-- Test based on http://w3c-test.org/web-platform-tests/master/XMLHttpRequest/setrequestheader-bogus-value.htm This test should be removed once wpt XMLHttpRequest is imported if both tests are in sync --> |
+ </head> |
+ <body> |
+ <div id="log"> |
+ <script type="text/javascript"> |
+ function try_value(value, expectError) { |
+ test(function() { |
+ var client = new XMLHttpRequest(); |
+ client.open("GET", "..."); |
+ if (expectError) |
+ assert_throws("SyntaxError", function() { client.setRequestHeader("x-test", value) }, ' given value ' + value+', '); |
tyoshino (SeeGerritForStatus)
2015/03/24 11:43:12
I know that this was just copied from W3C, but let
shiva.jm
2015/04/14 04:55:42
Done.
|
+ else |
+ client.setRequestHeader("x-test", value); |
+ }) |
+ } |
+ |
+ try_value("t\rt", true); |
+ try_value("t\nt", true); |
+ try_value("�ス�", true); |
hiroshige
2015/03/20 08:54:52
This test fails on trybots (i.e. no exception is t
shiva.jm
2015/03/23 05:21:24
Yes right, in my local linux machine, these test p
|
+ try_value("t\bt", true); |
+ try_value("t\vt", true); |
+ try_value("t\tt", false); |
+ try_value("t t", false); |
+ try_value(" t", true); |
+ try_value("t ", true); |
+ try_value("\xd0\xa1", false); |
+ try_value("\x7f", true); |
+ |
+ test(function() { |
+ var client = new XMLHttpRequest() |
+ client.open("GET", "...") |
+ assert_throws({name:'TypeError'}, function() { client.setRequestHeader("x-test") }) |
+ }) |
+ |
+ </script> |
+ </body> |
+</html> |