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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-unaffected.html

Issue 1378543002: Add UMA for header values in XHR's setRequestHeader() checked against RFC 7230 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflected tyoshino's comments. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-unaffected.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-unaffected.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-unaffected.html
new file mode 100644
index 0000000000000000000000000000000000000000..04dd6c0567a2883574aacfdf945c48ade12726f5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-unaffected.html
@@ -0,0 +1,42 @@
+<!doctype html>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+window.jsTestIsAsync = true;
+description('A single call to XMLHttpRequest.setRequestHeader() with ' +
+ 'a header value with leading/trailing whitespaces ' +
+ 'should not 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 removed by Chromium after
+// setRequestHeader() if there aren't multiple setRequestHeader() calls with
+// the same header name, so normalization in Blink's XHR wouldn't affect and
+// no deprecation warnings should be shown.
+xhr.setRequestHeader('test1', ' a ');
+xhr.setRequestHeader('test2', '\ta\t');
+
+xhr.onload = function() {
+ // This expectation must be updated once we update header value checks.
+ shouldNotBe('xhr.responseText.match(/HTTP_TEST1: a\\r?\\n/)',
+ 'null');
+ shouldNotBe('xhr.responseText.match(/HTTP_TEST2: a\\r?\\n/)',
+ 'null');
+ finishJSTest();
+};
+xhr.onerror = function() {
+ testFailed();
+ finishJSTest();
+};
+xhr.send();
+</script>

Powered by Google App Engine
This is Rietveld 408576698