Index: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-affected-1.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-affected-1.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-affected-1.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..06bbc27c10caab08bd06c3db196d8fc62e91c40c |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-affected-1.html |
@@ -0,0 +1,51 @@ |
+<!doctype html> |
+<script src="/js-test-resources/js-test.js"></script> |
+<script> |
+window.jsTestIsAsync = true; |
+description('Multiple calls to XMLHttpRequest.setRequestHeader() with ' + |
+ 'the same header name and header values with leading/trailing ' + |
+ 'whitespaces should show a deprecation message.'); |
+ |
+// According to the XHR spec [1], normalization (removing leading/trailing |
+// whitespaces) must be done on the value argument on setRequestHeader() call. |
+// Currently Blink's XHR implementation doesn't do the normalization, but other |
+// parts of Chromium do the normalization after setRequestHeader() and before |
+// headers are sent to network. |
+// A deprecation warning should be shown if the headers sent to the network is |
+// affected by introducing header value normalization in Blink's XHR. |
+// [1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader |
+// https://crbug.com/455099 |
+ |
+var xhr = new XMLHttpRequest; |
+xhr.open("GET", "../resources/print-headers.cgi"); |
+ |
+// The leading/trailing whitespaces are not removed by Chromium after |
+// setRequestHeader() if there are multiple setRequestHeader() calls with |
+// the same header name because it is applied the header value concatenated by |
+// ', ' in setRequestHeader(). |
+// In the following case, |
+// a1. Blink's XHR creates the header value 'a , \tb', |
+// a2. Chromium normalizes 'a , \tb' but does nothing, and |
+// a3. 'a , \tb' is sent to the network. |
+// If we introduce header value normalization in Blink's XHR, then: |
+// b1. Blink's XHR creates the header value 'a, b' because it normalizes |
+// 'a ' and '\tb' into 'a' and 'b', respectively, before concatenating by |
+// ', '. |
+// b2. Chromium normalizes 'a, b' but does nothing, and |
+// b3. 'a, b' is sent to the network. |
+// a3 and b3 are different, so a deprecation warning should be shown. |
kinuko
2015/09/29 12:51:33
Wow super detailed comments. I feel a bit shorter
|
+xhr.setRequestHeader('test1', 'a '); |
+xhr.setRequestHeader('test1', '\tb'); |
+ |
+xhr.onload = function() { |
+ // This expectation must be updated once we update header value checks. |
+ shouldNotBe('xhr.responseText.match(/HTTP_TEST1: a , \\tb\\r?\\n/)', |
+ 'null'); |
+ finishJSTest(); |
+}; |
+xhr.onerror = function() { |
+ testFailed(); |
+ finishJSTest(); |
+}; |
+xhr.send(); |
+</script> |