Chromium Code Reviews| 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 testCase.expectedText.replace('[dt=?]', '[dt=789+]') + '\n' + | |
|
eroman
2012/07/31 21:53:43
optional: I think it would be more readable to jus
mmenke
2012/07/31 22:53:16
Done.
| |
| 817 't=1338864634013 [st=789]'; | |
| 818 return testCase; | |
| 819 } | |
| 820 | |
| 821 /** | |
| 749 * Tests the custom formatting of net_errors across several different event | 822 * Tests the custom formatting of net_errors across several different event |
| 750 * types. | 823 * types. |
| 751 */ | 824 */ |
| 752 function painterTestNetError() { | 825 function painterTestNetError() { |
| 753 var testCase = {}; | 826 var testCase = {}; |
| 754 testCase.tickOffset = '1337911098446'; | 827 testCase.tickOffset = '1337911098446'; |
| 755 | 828 |
| 756 testCase.logEntries = [ | 829 testCase.logEntries = [ |
| 757 { | 830 { |
| 758 'phase': EventPhase.PHASE_BEGIN, | 831 'phase': EventPhase.PHASE_BEGIN, |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1287 return testCase; | 1360 return testCase; |
| 1288 } | 1361 } |
| 1289 | 1362 |
| 1290 /** | 1363 /** |
| 1291 * Tests that cookies are stripped from URLRequest when stripping is enabled. | 1364 * Tests that cookies are stripped from URLRequest when stripping is enabled. |
| 1292 */ | 1365 */ |
| 1293 function painterTestStripCookiesURLRequest() { | 1366 function painterTestStripCookiesURLRequest() { |
| 1294 var testCase = painterTestDontStripCookiesURLRequest(); | 1367 var testCase = painterTestDontStripCookiesURLRequest(); |
| 1295 testCase.enableSecurityStripping = true; | 1368 testCase.enableSecurityStripping = true; |
| 1296 testCase.expectedText = | 1369 testCase.expectedText = |
| 1297 testCase.expectedText.replace(/MyMagicPony/g, '[value was stripped]'); | 1370 testCase.expectedText.replace(/MyMagicPony/g, '[value was stripped]'); |
| 1298 return testCase; | 1371 return testCase; |
| 1299 } | 1372 } |
| 1300 | 1373 |
| 1301 /** | 1374 /** |
| 1302 * Tests that cookies are NOT stripped from SPDY sessions when stripping is not | 1375 * 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 | 1376 * enabled. This test data was pieced together in order to get a "cookie" and |
| 1304 * "set-cookie" header. | 1377 * "set-cookie" header. |
| 1305 */ | 1378 */ |
| 1306 function painterTestDontStripCookiesSPDYSession() { | 1379 function painterTestDontStripCookiesSPDYSession() { |
| 1307 var testCase = {}; | 1380 var testCase = {}; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1534 ' --> TLS 1.0 ==> SSL 3.0\n' + | 1607 ' --> TLS 1.0 ==> SSL 3.0\n' + |
| 1535 ' --> host_and_port = "www-927.ibm.com:443"\n' + | 1608 ' --> host_and_port = "www-927.ibm.com:443"\n' + |
| 1536 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + | 1609 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + |
| 1537 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + | 1610 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + |
| 1538 ' --> SSL 3.0 ==> SSL 0x123456'; | 1611 ' --> SSL 3.0 ==> SSL 0x123456'; |
| 1539 | 1612 |
| 1540 return testCase; | 1613 return testCase; |
| 1541 } | 1614 } |
| 1542 | 1615 |
| 1543 })(); // Anonymous namespace | 1616 })(); // Anonymous namespace |
| OLD | NEW |