Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xmlhttprequest / xmlhttprequest-invalid-values.html
blob9419e7957058e6c834d06c4e7d91b7ab44dd1fc2
1 <html>
2 <script>
3 function testInvalidMethod() {
4 var result = 'FAILURE';
6 var req = new XMLHttpRequest();
8 try {
9 req.open('test\r\nfoobar', window.location, true)
10 } catch (e) {
11 if (e.code == DOMException.SYNTAX_ERR)
12 result = 'SUCCESS';
15 debug('testInvalidMethod: ' + result);
18 function testInvalidHeaderName() {
19 var result = 'FAILURE';
21 var req = new XMLHttpRequest();
22 req.open('GET', window.location, true)
24 try {
25 req.setRequestHeader("host:", "example.com");
26 } catch (e) {
27 if (e.code == DOMException.SYNTAX_ERR)
28 result = 'SUCCESS';
31 debug('testInvalidHeaderName: ' + result);
34 function testInvalidHeaderValues() {
35 var result = 'FAILURE';
36 var successCount = 0;
38 var req = new XMLHttpRequest();
39 req.open('GET', window.location, true)
41 try {
42 req.setRequestHeader("X-Hack", "Test\r\nHost: www.example.com\r\n\r\nGET / HTTP/1.1");
43 } catch (e) {
44 if (e.code == DOMException.SYNTAX_ERR)
45 successCount++;
48 try {
49 req.setRequestHeader("X-Hack", "Test\nHost: www.example.com\n\nGET / HTTP/1.1");
50 } catch (e) {
51 if (e.code == DOMException.SYNTAX_ERR)
52 successCount++;
55 try {
56 req.setRequestHeader("X-Hack", "Test\rHost: www.example.com\r\rGET / HTTP/1.1");
57 } catch (e) {
58 if (e.code == DOMException.SYNTAX_ERR)
59 successCount++;
62 if (successCount == 3)
63 result = 'SUCCESS';
65 debug('testInvalidHeaderValues: ' + result);
68 function debug(str) {
69 var console = document.getElementById('console');
70 var li = document.createElement('li');
71 li.appendChild(document.createTextNode(str));
72 console.appendChild(li);
75 function runTest() {
76 if (window.testRunner)
77 testRunner.dumpAsText();
79 testInvalidMethod();
80 testInvalidHeaderName();
81 testInvalidHeaderValues();
83 </script>
84 <body onload="runTest()">
85 This tests that setting invalid header names, values and using an invalid method causes XMLHttpRequest to throw the appropriate exceptions.
86 </body>
87 <ul id="console">
88 </ul>
89 </html>