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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/header-value-update/normalize-affected-1.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, 2 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
(Empty)
1 <!doctype html>
2 <script src="/js-test-resources/js-test.js"></script>
3 <script>
4 window.jsTestIsAsync = true;
5 description('Multiple calls to XMLHttpRequest.setRequestHeader() with ' +
6 'the same header name and header values with leading/trailing ' +
7 'whitespaces should 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 not removed by Chromium after
23 // setRequestHeader() if there are multiple setRequestHeader() calls with
24 // the same header name because it is applied the header value concatenated by
25 // ', ' in setRequestHeader().
26 // In the following case,
27 // a1. Blink's XHR creates the header value 'a , \tb',
28 // a2. Chromium normalizes 'a , \tb' but does nothing, and
29 // a3. 'a , \tb' is sent to the network.
30 // If we introduce header value normalization in Blink's XHR, then:
31 // b1. Blink's XHR creates the header value 'a, b' because it normalizes
32 // 'a ' and '\tb' into 'a' and 'b', respectively, before concatenating by
33 // ', '.
34 // b2. Chromium normalizes 'a, b' but does nothing, and
35 // b3. 'a, b' is sent to the network.
36 // 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
37 xhr.setRequestHeader('test1', 'a ');
38 xhr.setRequestHeader('test1', '\tb');
39
40 xhr.onload = function() {
41 // This expectation must be updated once we update header value checks.
42 shouldNotBe('xhr.responseText.match(/HTTP_TEST1: a , \\tb\\r?\\n/)',
43 'null');
44 finishJSTest();
45 };
46 xhr.onerror = function() {
47 testFailed();
48 finishJSTest();
49 };
50 xhr.send();
51 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698