Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/xmlhttprequest/xmlhttprequest-invalid-values.html

Issue 2297483002: Make XMLHttpRequest.open() throw for invalid URLs (Closed)
Patch Set: Addressed #12 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <script> 2 <script>
3 function testInvalidMethod() {
4 var result = 'FAILURE';
5
6 var req = new XMLHttpRequest();
7
8 try {
9 req.open('test\r\nfoobar', window.location, true)
10 } catch (e) {
11 if (e.code == DOMException.SYNTAX_ERR)
12 result = 'SUCCESS';
13 }
14
15 debug('testInvalidMethod: ' + result);
16 }
17
18 function testInvalidHeaderName() { 3 function testInvalidHeaderName() {
19 var result = 'FAILURE'; 4 var result = 'FAILURE';
20 5
21 var req = new XMLHttpRequest(); 6 var req = new XMLHttpRequest();
22 req.open('GET', window.location, true) 7 req.open('GET', window.location, true)
23 8
24 try { 9 try {
25 req.setRequestHeader("host:", "example.com"); 10 req.setRequestHeader("host:", "example.com");
26 } catch (e) { 11 } catch (e) {
27 if (e.code == DOMException.SYNTAX_ERR) 12 if (e.code == DOMException.SYNTAX_ERR)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 var console = document.getElementById('console'); 54 var console = document.getElementById('console');
70 var li = document.createElement('li'); 55 var li = document.createElement('li');
71 li.appendChild(document.createTextNode(str)); 56 li.appendChild(document.createTextNode(str));
72 console.appendChild(li); 57 console.appendChild(li);
73 } 58 }
74 59
75 function runTest() { 60 function runTest() {
76 if (window.testRunner) 61 if (window.testRunner)
77 testRunner.dumpAsText(); 62 testRunner.dumpAsText();
78 63
79 testInvalidMethod();
80 testInvalidHeaderName(); 64 testInvalidHeaderName();
81 testInvalidHeaderValues(); 65 testInvalidHeaderValues();
82 } 66 }
83 </script> 67 </script>
84 <body onload="runTest()"> 68 <body onload="runTest()">
85 This tests that setting invalid header names, values and using an invalid me thod causes XMLHttpRequest to throw the appropriate exceptions. 69 This tests that setting invalid header names, values and using an invalid me thod causes XMLHttpRequest to throw the appropriate exceptions.
86 </body> 70 </body>
87 <ul id="console"> 71 <ul id="console">
88 </ul> 72 </ul>
89 </html> 73 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698