OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['net_internals_test.js']); | 6 GEN_INCLUDE(['net_internals_test.js']); |
7 | 7 |
8 // Anonymous namespace | 8 // Anonymous namespace |
9 (function() { | 9 (function() { |
10 | 10 |
11 /** | 11 /** |
12 * Check that stripCookiesAndLoginInfo correctly removes cookies and login | 12 * Check that stripPrivacyInfo correctly removes cookies and login information. |
13 * information. | |
14 */ | 13 */ |
15 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterStripInfo', function() { | 14 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterStripInfo', function() { |
16 // Each entry in |expectations| is a list consisting of a header element | 15 // Each entry in |expectations| is a list consisting of a header element |
17 // before and after applying the filter. If the second entry is null, the | 16 // before and after applying the filter. If the second entry is null, the |
18 // element should be unmodified. | 17 // element should be unmodified. |
19 var expectations = [ | 18 var expectations = [ |
20 ['set-cookie: blah', 'set-cookie: [4 bytes were stripped]'], | 19 ['set-cookie: blah', 'set-cookie: [4 bytes were stripped]'], |
21 ['set-cookie2: blah', 'set-cookie2: [4 bytes were stripped]'], | 20 ['set-cookie2: blah', 'set-cookie2: [4 bytes were stripped]'], |
22 ['cookie: blah', 'cookie: [4 bytes were stripped]'], | 21 ['cookie: blah', 'cookie: [4 bytes were stripped]'], |
23 ['authorization: NTLM blah', 'authorization: NTLM [4 bytes were stripped]'], | 22 ['authorization: NTLM blah', 'authorization: NTLM [4 bytes were stripped]'], |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ], | 77 ], |
79 'line': 'GET / HTTP/1.1\r\n' | 78 'line': 'GET / HTTP/1.1\r\n' |
80 }, | 79 }, |
81 'phase': EventPhase.PHASE_BEGIN, | 80 'phase': EventPhase.PHASE_BEGIN, |
82 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, | 81 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, |
83 'time': '22468349', | 82 'time': '22468349', |
84 'type': EventSourceType.URL_REQUEST | 83 'type': EventSourceType.URL_REQUEST |
85 }; | 84 }; |
86 | 85 |
87 entry.params.headers[position] = expectation[0]; | 86 entry.params.headers[position] = expectation[0]; |
88 var stripped = stripCookiesAndLoginInfo(entry); | 87 var stripped = stripPrivacyInfo(entry); |
89 // The entry should be duplicated, so the original still has the deleted | 88 // The entry should be duplicated, so the original still has the deleted |
90 // information. | 89 // information. |
91 expectNotEquals(stripped, entry); | 90 expectNotEquals(stripped, entry); |
92 if (expectation[1] == null) { | 91 if (expectation[1] == null) { |
93 expectEquals(expectation[0], stripped.params.headers[position]); | 92 expectEquals(expectation[0], stripped.params.headers[position]); |
94 } else { | 93 } else { |
95 expectEquals(expectation[1], stripped.params.headers[position]); | 94 expectEquals(expectation[1], stripped.params.headers[position]); |
96 } | 95 } |
97 } | 96 } |
98 } | 97 } |
99 | 98 |
100 // Test with HTTP/2 request headers, which use an object rather than an array. | 99 // Test with HTTP/2 request headers, which use an object rather than an array. |
101 var spdyRequestHeadersEntry = { | 100 var spdyRequestHeadersEntry = { |
102 'params': { | 101 'params': { |
103 'headers': { | 102 'headers': { |
104 ':host': 'clients1.google.com', | 103 ':host': 'clients1.google.com', |
105 ':method': 'GET', | 104 ':method': 'GET', |
106 ':path': '/cute/cat/pictures/', | 105 ':path': '/cute/cat/pictures/', |
107 'cookie': 'blah' | 106 'cookie': 'blah' |
108 }, | 107 }, |
109 'line': 'GET / HTTP/1.1\r\n' | 108 'line': 'GET / HTTP/1.1\r\n' |
110 }, | 109 }, |
111 'phase': EventPhase.PHASE_BEGIN, | 110 'phase': EventPhase.PHASE_BEGIN, |
112 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, | 111 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST}, |
113 'time': '22468349', | 112 'time': '22468349', |
114 'type': EventSourceType.HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS | 113 'type': EventSourceType.HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS |
115 }; | 114 }; |
116 var strippedSpdyRequestHeadersEntry = | 115 var strippedSpdyRequestHeadersEntry = |
117 stripCookiesAndLoginInfo(spdyRequestHeadersEntry); | 116 stripPrivacyInfo(spdyRequestHeadersEntry); |
118 expectEquals('cookie: [4 bytes were stripped]', | 117 expectEquals('cookie: [4 bytes were stripped]', |
119 strippedSpdyRequestHeadersEntry.params.headers[3]); | 118 strippedSpdyRequestHeadersEntry.params.headers[3]); |
120 | 119 |
121 testDone(); | 120 testDone(); |
122 }); | 121 }); |
123 | 122 |
124 /** | 123 /** |
| 124 * Check that stripPrivacyInfo correctly removes HTTP/2 GOAWAY frame debug data. |
| 125 */ |
| 126 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterStripGoAway', function() { |
| 127 var entry = { |
| 128 'params': { |
| 129 'active_streams': 1, |
| 130 'debug_data': 'potentially privacy sensitive information', |
| 131 'last_accepted_stream_id': 1, |
| 132 'status': 0, |
| 133 'unclaimed_streams': 0, |
| 134 }, |
| 135 'phase': 0, |
| 136 'source': {'id': 404, 'type': 5}, |
| 137 'time': '49236780', |
| 138 'type': EventType.HTTP2_SESSION_GOAWAY, |
| 139 }; |
| 140 |
| 141 var stripped = stripPrivacyInfo(entry); |
| 142 |
| 143 // The entry should be duplicated, so the original still has the deleted |
| 144 // information. |
| 145 expectNotEquals(stripped, entry); |
| 146 expectEquals('[41 bytes were stripped]', |
| 147 stripped.params.debug_data); |
| 148 |
| 149 testDone(); |
| 150 }); |
| 151 |
| 152 /** |
125 * Tests the formatting of log entries to fixed width text. | 153 * Tests the formatting of log entries to fixed width text. |
126 */ | 154 */ |
127 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { | 155 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { |
128 // Add a DOM node to draw the log entries into. | 156 // Add a DOM node to draw the log entries into. |
129 var div = addNode(document.body, 'div'); | 157 var div = addNode(document.body, 'div'); |
130 | 158 |
131 // Helper function to run a particular "test case". This comprises an input | 159 // Helper function to run a particular "test case". This comprises an input |
132 // and the resulting formatted text expectation. | 160 // and the resulting formatted text expectation. |
133 function runTestCase(testCase) { | 161 function runTestCase(testCase) { |
134 div.innerHTML = ''; | 162 div.innerHTML = ''; |
(...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 | 2195 |
2168 testCase.expectedText = | 2196 testCase.expectedText = |
2169 't= 2 [st= 0] +REQUEST_ALIVE [dt=789+]\n' + | 2197 't= 2 [st= 0] +REQUEST_ALIVE [dt=789+]\n' + |
2170 't=152 [st=150] HTTP_STREAM_REQUEST [dt=1]\n' + | 2198 't=152 [st=150] HTTP_STREAM_REQUEST [dt=1]\n' + |
2171 't=791 [st=789]'; | 2199 't=791 [st=789]'; |
2172 | 2200 |
2173 return testCase; | 2201 return testCase; |
2174 } | 2202 } |
2175 | 2203 |
2176 })(); // Anonymous namespace | 2204 })(); // Anonymous namespace |
OLD | NEW |