OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <script src="/js-test-resources/js-test.js"></script> |
| 3 <script> |
| 4 window.jsTestIsAsync = true; |
| 5 description('A single call to XMLHttpRequest.setRequestHeader() with ' + |
| 6 'a header value with leading/trailing whitespaces ' + |
| 7 'should not show a deprecation message.'); |
| 8 |
| 9 // According to the XHR spec [1], normalization (removing leading/trailing |
| 10 // whitespaces) must be done on the value argument on setRequestHeader() call. |
| 11 // Currently Blink's XHR implementation doesn't do the normalization, but other |
| 12 // parts of Chromium do the normalization after setRequestHeader() and before |
| 13 // headers are sent to network. |
| 14 // A deprecation warning should be shown if the headers sent to the network is |
| 15 // affected by introducing header value normalization in Blink's XHR. |
| 16 // [1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader |
| 17 // https://crbug.com/455099 |
| 18 |
| 19 var xhr = new XMLHttpRequest; |
| 20 xhr.open("GET", "../resources/print-headers.cgi"); |
| 21 |
| 22 // The leading/trailing whitespaces are removed by Chromium after |
| 23 // setRequestHeader() if there aren't multiple setRequestHeader() calls with |
| 24 // the same header name, so normalization in Blink's XHR wouldn't affect and |
| 25 // no deprecation warnings should be shown. |
| 26 xhr.setRequestHeader('test1', ' a '); |
| 27 xhr.setRequestHeader('test2', '\ta\t'); |
| 28 |
| 29 xhr.onload = function() { |
| 30 // This expectation must be updated once we update header value checks. |
| 31 shouldNotBe('xhr.responseText.match(/HTTP_TEST1: a\\r?\\n/)', |
| 32 'null'); |
| 33 shouldNotBe('xhr.responseText.match(/HTTP_TEST2: a\\r?\\n/)', |
| 34 'null'); |
| 35 finishJSTest(); |
| 36 }; |
| 37 xhr.onerror = function() { |
| 38 testFailed(); |
| 39 finishJSTest(); |
| 40 }; |
| 41 xhr.send(); |
| 42 </script> |
OLD | NEW |