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 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { | 94 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { |
95 // Add a DOM node to draw the log entries into. | 95 // Add a DOM node to draw the log entries into. |
96 var div = addNode(document.body, 'div'); | 96 var div = addNode(document.body, 'div'); |
97 | 97 |
98 // Helper function to run a particular "test case". This comprises an input | 98 // Helper function to run a particular "test case". This comprises an input |
99 // and the resulting formatted text expectation. | 99 // and the resulting formatted text expectation. |
100 function runTestCase(testCase) { | 100 function runTestCase(testCase) { |
101 div.innerHTML = ''; | 101 div.innerHTML = ''; |
102 timeutil.setTimeTickOffset(testCase.tickOffset); | 102 timeutil.setTimeTickOffset(testCase.tickOffset); |
103 printLogEntriesAsText(testCase.logEntries, div, | 103 printLogEntriesAsText(testCase.logEntries, div, |
104 testCase.enableSecurityStripping); | 104 testCase.enableSecurityStripping, |
| 105 testCase.logCreationTime); |
105 | 106 |
106 // Strip any trailing newlines, since the whitespace when using innerText | 107 // Strip any trailing newlines, since the whitespace when using innerText |
107 // can be a bit unpredictable. | 108 // can be a bit unpredictable. |
108 var actualText = div.innerText; | 109 var actualText = div.innerText; |
109 actualText = actualText.replace(/^\s+|\s+$/g, ''); | 110 actualText = actualText.replace(/^\s+|\s+$/g, ''); |
110 | 111 |
111 expectEquals(testCase.expectedText, actualText); | 112 expectEquals(testCase.expectedText, actualText); |
112 } | 113 } |
113 | 114 |
114 runTestCase(painterTestURLRequest()); | 115 runTestCase(painterTestURLRequest()); |
| 116 runTestCase(painterTestURLRequestIncomplete()); |
| 117 runTestCase(painterTestURLRequestIncompleteFromLoadedLog()); |
115 runTestCase(painterTestNetError()); | 118 runTestCase(painterTestNetError()); |
116 runTestCase(painterTestHexEncodedBytes()); | 119 runTestCase(painterTestHexEncodedBytes()); |
117 runTestCase(painterTestCertVerifierJob()); | 120 runTestCase(painterTestCertVerifierJob()); |
118 runTestCase(painterTestProxyConfig()); | 121 runTestCase(painterTestProxyConfig()); |
119 runTestCase(painterTestDontStripCookiesURLRequest()); | 122 runTestCase(painterTestDontStripCookiesURLRequest()); |
120 runTestCase(painterTestStripCookiesURLRequest()); | 123 runTestCase(painterTestStripCookiesURLRequest()); |
121 runTestCase(painterTestDontStripCookiesSPDYSession()); | 124 runTestCase(painterTestDontStripCookiesSPDYSession()); |
122 runTestCase(painterTestStripCookiesSPDYSession()); | 125 runTestCase(painterTestStripCookiesSPDYSession()); |
123 runTestCase(painterTestExtraCustomParameter()); | 126 runTestCase(painterTestExtraCustomParameter()); |
124 runTestCase(painterTestMissingCustomParameter()); | 127 runTestCase(painterTestMissingCustomParameter()); |
125 runTestCase(painterTestSSLVersionFallback()); | 128 runTestCase(painterTestSSLVersionFallback()); |
126 | 129 |
127 testDone(); | 130 testDone(); |
128 }); | 131 }); |
129 | 132 |
130 /** | 133 /** |
131 * Test case for a URLRequest. This includes custom formatting for load flags, | 134 * Test case for a URLRequest. This includes custom formatting for load flags, |
132 * request/response HTTP headers, dependent sources, as well as basic | 135 * request/response HTTP headers, dependent sources, as well as basic |
133 * indentation and grouping. | 136 * indentation and grouping. Also makes sure that no extra event is logged |
| 137 * for finished sources when there's a logCreationTime. |
134 */ | 138 */ |
135 function painterTestURLRequest() { | 139 function painterTestURLRequest() { |
136 var testCase = {}; | 140 var testCase = {}; |
137 testCase.tickOffset = '1337911098446'; | 141 testCase.tickOffset = '1337911098446'; |
| 142 testCase.logCreationTime = 1338864634013; |
138 | 143 |
139 testCase.logEntries = [ | 144 testCase.logEntries = [ |
140 { | 145 { |
141 'phase': EventPhase.PHASE_BEGIN, | 146 'phase': EventPhase.PHASE_BEGIN, |
142 'source': { | 147 'source': { |
143 'id': 146, | 148 'id': 146, |
144 'type': EventSourceType.URL_REQUEST | 149 'type': EventSourceType.URL_REQUEST |
145 }, | 150 }, |
146 'time': '953534778', | 151 'time': '953534778', |
147 'type': EventType.REQUEST_ALIVE | 152 'type': EventType.REQUEST_ALIVE |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 't=1338864633998 [st=774] HTTP_TRANSACTION_READ_BODY [dt=1]\n' + | 744 't=1338864633998 [st=774] HTTP_TRANSACTION_READ_BODY [dt=1]\n' + |
740 't=1338864633999 [st=775] HTTP_CACHE_WRITE_DATA [dt=3]\n' + | 745 't=1338864633999 [st=775] HTTP_CACHE_WRITE_DATA [dt=3]\n' + |
741 't=1338864634002 [st=778] HTTP_TRANSACTION_READ_BODY [dt=3]\n' + | 746 't=1338864634002 [st=778] HTTP_TRANSACTION_READ_BODY [dt=3]\n' + |
742 't=1338864634005 [st=781] HTTP_CACHE_WRITE_DATA [dt=0]\n' + | 747 't=1338864634005 [st=781] HTTP_CACHE_WRITE_DATA [dt=0]\n' + |
743 't=1338864634013 [st=789] -REQUEST_ALIVE'; | 748 't=1338864634013 [st=789] -REQUEST_ALIVE'; |
744 | 749 |
745 return testCase; | 750 return testCase; |
746 } | 751 } |
747 | 752 |
748 /** | 753 /** |
| 754 * Test case for a URLRequest that was not completed that did not come from a |
| 755 * loaded log file. |
| 756 */ |
| 757 function painterTestURLRequestIncomplete() { |
| 758 var testCase = {}; |
| 759 testCase.tickOffset = '1337911098446'; |
| 760 |
| 761 testCase.logEntries = [ |
| 762 { |
| 763 'phase': EventPhase.PHASE_BEGIN, |
| 764 'source': { |
| 765 'id': 146, |
| 766 'type': EventSourceType.URL_REQUEST |
| 767 }, |
| 768 'time': '953534778', |
| 769 'type': EventType.REQUEST_ALIVE |
| 770 }, |
| 771 { |
| 772 'params': { |
| 773 'load_flags': 128, |
| 774 'method': 'GET', |
| 775 'priority': 4, |
| 776 'url': 'http://www.google.com/' |
| 777 }, |
| 778 'phase': EventPhase.PHASE_BEGIN, |
| 779 'source': { |
| 780 'id': 146, |
| 781 'type': EventSourceType.URL_REQUEST |
| 782 }, |
| 783 'time': '953534910', |
| 784 'type': EventType.URL_REQUEST_START_JOB |
| 785 }, |
| 786 { |
| 787 'phase': EventPhase.PHASE_END, |
| 788 'source': { |
| 789 'id': 146, |
| 790 'type': EventSourceType.URL_REQUEST |
| 791 }, |
| 792 'time': '953534970', |
| 793 'type': EventType.URL_REQUEST_START_JOB |
| 794 }, |
| 795 ]; |
| 796 |
| 797 testCase.expectedText = |
| 798 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=?]\n' + |
| 799 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' + |
| 800 ' --> load_flags = 128 (ENABLE_LOAD_TIMING)\n' + |
| 801 ' --> method = "GET"\n' + |
| 802 ' --> priority = 4\n' + |
| 803 ' --> url = "http://www.google.com/"'; |
| 804 |
| 805 return testCase; |
| 806 } |
| 807 |
| 808 /** |
| 809 * Test case for a URLRequest that was not completed that came from a loaded |
| 810 * log file. |
| 811 */ |
| 812 function painterTestURLRequestIncompleteFromLoadedLog() { |
| 813 var testCase = painterTestURLRequestIncomplete(); |
| 814 testCase.logCreationTime = 1338864634013; |
| 815 testCase.expectedText = |
| 816 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789+]\n' + |
| 817 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' + |
| 818 ' --> load_flags = 128 (ENABLE_LOAD_TIMING)\n' + |
| 819 ' --> method = "GET"\n' + |
| 820 ' --> priority = 4\n' + |
| 821 ' --> url = "http://www.google.com/"\n' + |
| 822 't=1338864634013 [st=789]'; |
| 823 return testCase; |
| 824 } |
| 825 |
| 826 /** |
749 * Tests the custom formatting of net_errors across several different event | 827 * Tests the custom formatting of net_errors across several different event |
750 * types. | 828 * types. |
751 */ | 829 */ |
752 function painterTestNetError() { | 830 function painterTestNetError() { |
753 var testCase = {}; | 831 var testCase = {}; |
754 testCase.tickOffset = '1337911098446'; | 832 testCase.tickOffset = '1337911098446'; |
755 | 833 |
756 testCase.logEntries = [ | 834 testCase.logEntries = [ |
757 { | 835 { |
758 'phase': EventPhase.PHASE_BEGIN, | 836 'phase': EventPhase.PHASE_BEGIN, |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 return testCase; | 1365 return testCase; |
1288 } | 1366 } |
1289 | 1367 |
1290 /** | 1368 /** |
1291 * Tests that cookies are stripped from URLRequest when stripping is enabled. | 1369 * Tests that cookies are stripped from URLRequest when stripping is enabled. |
1292 */ | 1370 */ |
1293 function painterTestStripCookiesURLRequest() { | 1371 function painterTestStripCookiesURLRequest() { |
1294 var testCase = painterTestDontStripCookiesURLRequest(); | 1372 var testCase = painterTestDontStripCookiesURLRequest(); |
1295 testCase.enableSecurityStripping = true; | 1373 testCase.enableSecurityStripping = true; |
1296 testCase.expectedText = | 1374 testCase.expectedText = |
1297 testCase.expectedText.replace(/MyMagicPony/g, '[value was stripped]'); | 1375 testCase.expectedText.replace(/MyMagicPony/g, '[value was stripped]'); |
1298 return testCase; | 1376 return testCase; |
1299 } | 1377 } |
1300 | 1378 |
1301 /** | 1379 /** |
1302 * Tests that cookies are NOT stripped from SPDY sessions when stripping is not | 1380 * Tests that cookies are NOT stripped from SPDY sessions when stripping is not |
1303 * enabled. This test data was pieced together in order to get a "cookie" and | 1381 * enabled. This test data was pieced together in order to get a "cookie" and |
1304 * "set-cookie" header. | 1382 * "set-cookie" header. |
1305 */ | 1383 */ |
1306 function painterTestDontStripCookiesSPDYSession() { | 1384 function painterTestDontStripCookiesSPDYSession() { |
1307 var testCase = {}; | 1385 var testCase = {}; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 ' --> TLS 1.0 ==> SSL 3.0\n' + | 1612 ' --> TLS 1.0 ==> SSL 3.0\n' + |
1535 ' --> host_and_port = "www-927.ibm.com:443"\n' + | 1613 ' --> host_and_port = "www-927.ibm.com:443"\n' + |
1536 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + | 1614 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + |
1537 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + | 1615 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + |
1538 ' --> SSL 3.0 ==> SSL 0x123456'; | 1616 ' --> SSL 3.0 ==> SSL 0x123456'; |
1539 | 1617 |
1540 return testCase; | 1618 return testCase; |
1541 } | 1619 } |
1542 | 1620 |
1543 })(); // Anonymous namespace | 1621 })(); // Anonymous namespace |
OLD | NEW |