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

Side by Side Diff: chrome/test/data/webui/net_internals/log_view_painter.js

Issue 10870080: Add SPDY request headers to DevTools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix log view painter, add tests Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 stripCookiesAndLoginInfo correctly removes cookies and login
13 * information. 13 * information.
14 */ 14 */
15 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterStripInfo', function() { 15 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterStripInfo', function() {
16 function runTestCase(testCase) {
17 div.innerHTML = '';
18 timeutil.setTimeTickOffset(testCase.tickOffset);
19 printLogEntriesAsText(testCase.logEntries, div,
20 testCase.privacyStripping,
21 testCase.logCreationTime);
22
23 // Strip any trailing newlines, since the whitespace when using innerText
24 // can be a bit unpredictable.
25 var actualText = div.innerText;
26 actualText = actualText.replace(/^\s+|\s+$/g, '');
27
28 expectEquals(testCase.expectedText, actualText);
29 }
30
16 // Each entry in |expectations| is a list consisting of a header element 31 // 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 32 // before and after applying the filter. If the second entry is null, the
18 // element should be unmodified. 33 // element should be unmodified.
19 var expectations = [ 34 var expectations = [
20 ['set-cookie: blah', 'set-cookie: [value was stripped]'], 35 ['set-cookie: blah', 'set-cookie: [value was stripped]'],
21 ['set-cookie2: blah', 'set-cookie2: [value was stripped]'], 36 ['set-cookie2: blah', 'set-cookie2: [value was stripped]'],
22 ['cookie: blah', 'cookie: [value was stripped]'], 37 ['cookie: blah', 'cookie: [value was stripped]'],
23 ['authorization: NTLM blah', 'authorization: NTLM [value was stripped]'], 38 ['authorization: NTLM blah', 'authorization: NTLM [value was stripped]'],
24 39
25 ['proxy-authorization: Basic blah', 40 ['proxy-authorization: Basic blah',
(...skipping 29 matching lines...) Expand all
55 ['Proxy-Authenticate: Kerberos,Digest,Basic', null], 70 ['Proxy-Authenticate: Kerberos,Digest,Basic', null],
56 ['Proxy-Authenticate: Digest realm="asdfasdf", nonce=5, qop="auth"', null], 71 ['Proxy-Authenticate: Digest realm="asdfasdf", nonce=5, qop="auth"', null],
57 ['Proxy-Authenticate: Basic realm=foo,foo=bar , Digest ', null] 72 ['Proxy-Authenticate: Basic realm=foo,foo=bar , Digest ', null]
58 ]; 73 ];
59 74
60 for (var i = 0; i < expectations.length; ++i) { 75 for (var i = 0; i < expectations.length; ++i) {
61 var expectation = expectations[i]; 76 var expectation = expectations[i];
62 // Position within params.headers where the authentication information goes. 77 // Position within params.headers where the authentication information goes.
63 for (var position = 0; position < 3; ++position) { 78 for (var position = 0; position < 3; ++position) {
64 var entry = { 79 var entry = {
65 'params': { 80 'params': {
66 'headers': [ 81 'headers': [
67 'Host: clients1.google.com', 82 'Host: clients1.google.com',
68 'Connection: keep-alive', 83 'Connection: keep-alive',
69 'User-Agent: Mozilla/5.0'], 84 'User-Agent: Mozilla/5.0'
70 'line': 'GET / HTTP/1.1\r\n'}, 85 ],
71 'phase': 0, 86 'line': 'GET / HTTP/1.1\r\n'
72 'source': {'id': 329, 'type': 1}, 87 },
73 'time': '22468349', 88 'phase': EventPhase.PHASE_BEGIN,
74 'type': 104}; 89 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
90 'time': '22468349',
91 'type': EventSourceType.URL_REQUEST
92 };
75 93
76 entry.params.headers[position] = expectation[0]; 94 entry.params.headers[position] = expectation[0];
77 var stripped = stripCookiesAndLoginInfo(entry); 95 var stripped = stripCookiesAndLoginInfo(entry);
78 // The entry should be duplicated, so the original still has the deleted 96 // The entry should be duplicated, so the original still has the deleted
79 // information. 97 // information.
80 expectNotEquals(stripped, entry); 98 expectNotEquals(stripped, entry);
81 if (expectation[1] == null) { 99 if (expectation[1] == null) {
82 expectEquals(stripped.params.headers[position], expectation[0]); 100 expectEquals(expectation[0], stripped.params.headers[position]);
83 } else { 101 } else {
84 expectEquals(stripped.params.headers[position], expectation[1]); 102 expectEquals(expectation[1], stripped.params.headers[position]);
85 } 103 }
86 } 104 }
87 } 105 }
106
107 // Test with SPDY request headers, which use an object rather than an array.
108 var spdyRequestHeadersEntry = {
109 'params': {
110 'headers': {
111 ':host': 'clients1.google.com',
112 ':method': 'GET',
113 ':path': '/cute/cat/pictures/',
114 'cookie': 'blah'
115 },
116 'line': 'GET / HTTP/1.1\r\n'
117 },
118 'phase': EventPhase.PHASE_BEGIN,
119 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
120 'time': '22468349',
121 'type': EventSourceType.HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS
122 };
123 var strippedSpdyRequestHeadersEntry =
124 stripCookiesAndLoginInfo(spdyRequestHeadersEntry);
125 expectEquals('cookie: [value was stripped]',
126 strippedSpdyRequestHeadersEntry.params.headers[3]);
127
88 testDone(); 128 testDone();
89 }); 129 });
90 130
91 /** 131 /**
92 * Tests the formatting of log entries to fixed width text. 132 * Tests the formatting of log entries to fixed width text.
93 */ 133 */
94 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { 134 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() {
95 // Add a DOM node to draw the log entries into. 135 // Add a DOM node to draw the log entries into.
96 var div = addNode(document.body, 'div'); 136 var div = addNode(document.body, 'div');
97 137
(...skipping 18 matching lines...) Expand all
116 runTestCase(painterTestURLRequestIncomplete()); 156 runTestCase(painterTestURLRequestIncomplete());
117 runTestCase(painterTestURLRequestIncompleteFromLoadedLog()); 157 runTestCase(painterTestURLRequestIncompleteFromLoadedLog());
118 runTestCase(painterTestNetError()); 158 runTestCase(painterTestNetError());
119 runTestCase(painterTestHexEncodedBytes()); 159 runTestCase(painterTestHexEncodedBytes());
120 runTestCase(painterTestCertVerifierJob()); 160 runTestCase(painterTestCertVerifierJob());
121 runTestCase(painterTestProxyConfig()); 161 runTestCase(painterTestProxyConfig());
122 runTestCase(painterTestDontStripCookiesURLRequest()); 162 runTestCase(painterTestDontStripCookiesURLRequest());
123 runTestCase(painterTestStripCookiesURLRequest()); 163 runTestCase(painterTestStripCookiesURLRequest());
124 runTestCase(painterTestDontStripCookiesSPDYSession()); 164 runTestCase(painterTestDontStripCookiesSPDYSession());
125 runTestCase(painterTestStripCookiesSPDYSession()); 165 runTestCase(painterTestStripCookiesSPDYSession());
166 runTestCase(painterTestSpdyURLRequestDontStripCookies());
167 runTestCase(painterTestSpdyURLRequestStripCookies());
126 runTestCase(painterTestExtraCustomParameter()); 168 runTestCase(painterTestExtraCustomParameter());
127 runTestCase(painterTestMissingCustomParameter()); 169 runTestCase(painterTestMissingCustomParameter());
128 runTestCase(painterTestSSLVersionFallback()); 170 runTestCase(painterTestSSLVersionFallback());
129 171
130 testDone(); 172 testDone();
131 }); 173 });
132 174
133 /** 175 /**
134 * Test case for a URLRequest. This includes custom formatting for load flags, 176 * Test case for a URLRequest. This includes custom formatting for load flags,
135 * request/response HTTP headers, dependent sources, as well as basic 177 * request/response HTTP headers, dependent sources, as well as basic
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 */ 1510 */
1469 function painterTestStripCookiesSPDYSession() { 1511 function painterTestStripCookiesSPDYSession() {
1470 var testCase = painterTestDontStripCookiesSPDYSession(); 1512 var testCase = painterTestDontStripCookiesSPDYSession();
1471 testCase.privacyStripping = true; 1513 testCase.privacyStripping = true;
1472 testCase.expectedText = 1514 testCase.expectedText =
1473 testCase.expectedText.replace(/MyLittlePony/g, '[value was stripped]'); 1515 testCase.expectedText.replace(/MyLittlePony/g, '[value was stripped]');
1474 return testCase; 1516 return testCase;
1475 } 1517 }
1476 1518
1477 /** 1519 /**
1520 * Tests that cookies are NOT stripped from SPDY URL request headers when
1521 * stripping is not enabled. The difference from the above requests is that SPDY
1522 * URL request headers use dictionaries rather than lists.
1523 */
1524 function painterTestSpdyURLRequestDontStripCookies() {
1525 var testCase = {};
1526 testCase.tickOffset = '1337911098481';
1527
1528 testCase.logEntries = [
1529 {
1530 'params': {
1531 'headers': {
1532 ':host': 'www.google.com',
1533 ':method': 'GET',
1534 ':path': '/',
1535 ':scheme': 'https',
1536 ':version': 'HTTP/1.1',
1537 'cookie': 'MyMagicPony'},
1538 },
1539 'phase': EventPhase.PHASE_NONE,
1540 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
1541 'time': '954124663',
1542 'type': EventType.HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS
1543 }
1544 ];
1545
1546 testCase.expectedText =
1547 't=1338865223144 [st=0] HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS\n' +
1548 ' --> :host: www.google.com\n' +
1549 ' :method: GET\n' +
1550 ' :path: /\n' +
1551 ' :scheme: https\n' +
1552 ' :version: HTTP/1.1\n' +
1553 ' cookie: MyMagicPony';
1554 return testCase;
1555 }
1556
1557 /**
1558 * Tests that cookies are NOT stripped from SPDY URL request headers when
1559 * stripping is not enabled. The difference from the above requests is that
1560 */
1561 function painterTestSpdyURLRequestStripCookies() {
1562 var testCase = painterTestSpdyURLRequestDontStripCookies();
1563 testCase.privacyStripping = true;
1564 testCase.expectedText =
1565 testCase.expectedText.replace(/MyMagicPony/g, '[value was stripped]');
1566 return testCase;
1567 }
1568
1569 /**
1478 * Tests that when there are more custom parameters than we expect for an 1570 * Tests that when there are more custom parameters than we expect for an
1479 * event type, they are printed out in addition to the custom formatting. 1571 * event type, they are printed out in addition to the custom formatting.
1480 */ 1572 */
1481 function painterTestExtraCustomParameter() { 1573 function painterTestExtraCustomParameter() {
1482 var testCase = {}; 1574 var testCase = {};
1483 testCase.tickOffset = '1337911098446'; 1575 testCase.tickOffset = '1337911098446';
1484 1576
1485 testCase.logEntries = [ 1577 testCase.logEntries = [
1486 { 1578 {
1487 'params': { 1579 'params': {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 ' --> TLS 1.0 ==> SSL 3.0\n' + 1704 ' --> TLS 1.0 ==> SSL 3.0\n' +
1613 ' --> host_and_port = "www-927.ibm.com:443"\n' + 1705 ' --> host_and_port = "www-927.ibm.com:443"\n' +
1614 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + 1706 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' +
1615 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + 1707 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' +
1616 ' --> SSL 3.0 ==> SSL 0x123456'; 1708 ' --> SSL 3.0 ==> SSL 0x123456';
1617 1709
1618 return testCase; 1710 return testCase;
1619 } 1711 }
1620 1712
1621 })(); // Anonymous namespace 1713 })(); // Anonymous namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698