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('\n' + testCase.expectedText, '\n' + 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()); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 't=1338864633998 [st=774] HTTP_TRANSACTION_READ_BODY [dt=1]\n' + | 742 't=1338864633998 [st=774] HTTP_TRANSACTION_READ_BODY [dt=1]\n' + |
740 't=1338864633999 [st=775] HTTP_CACHE_WRITE_DATA [dt=3]\n' + | 743 't=1338864633999 [st=775] HTTP_CACHE_WRITE_DATA [dt=3]\n' + |
741 't=1338864634002 [st=778] HTTP_TRANSACTION_READ_BODY [dt=3]\n' + | 744 't=1338864634002 [st=778] HTTP_TRANSACTION_READ_BODY [dt=3]\n' + |
742 't=1338864634005 [st=781] HTTP_CACHE_WRITE_DATA [dt=0]\n' + | 745 't=1338864634005 [st=781] HTTP_CACHE_WRITE_DATA [dt=0]\n' + |
743 't=1338864634013 [st=789] -REQUEST_ALIVE'; | 746 't=1338864634013 [st=789] -REQUEST_ALIVE'; |
744 | 747 |
745 return testCase; | 748 return testCase; |
746 } | 749 } |
747 | 750 |
748 /** | 751 /** |
| 752 * Test case for a URLRequest that was not completed that did not come from a |
| 753 * loaded log file. |
| 754 */ |
| 755 function painterTestURLRequestIncomplete() { |
| 756 var testCase = {}; |
| 757 testCase.tickOffset = '1337911098446'; |
| 758 |
| 759 testCase.logEntries = [ |
| 760 { |
| 761 'phase': EventPhase.PHASE_BEGIN, |
| 762 'source': { |
| 763 'id': 146, |
| 764 'type': EventSourceType.URL_REQUEST |
| 765 }, |
| 766 'time': '953534778', |
| 767 'type': EventType.REQUEST_ALIVE |
| 768 }, |
| 769 { |
| 770 'params': { |
| 771 'load_flags': 128, |
| 772 'method': 'GET', |
| 773 'priority': 4, |
| 774 'url': 'http://www.google.com/' |
| 775 }, |
| 776 'phase': EventPhase.PHASE_BEGIN, |
| 777 'source': { |
| 778 'id': 146, |
| 779 'type': EventSourceType.URL_REQUEST |
| 780 }, |
| 781 'time': '953534910', |
| 782 'type': EventType.URL_REQUEST_START_JOB |
| 783 }, |
| 784 { |
| 785 'phase': EventPhase.PHASE_END, |
| 786 'source': { |
| 787 'id': 146, |
| 788 'type': EventSourceType.URL_REQUEST |
| 789 }, |
| 790 'time': '953534970', |
| 791 'type': EventType.URL_REQUEST_START_JOB |
| 792 }, |
| 793 ]; |
| 794 |
| 795 testCase.expectedText = |
| 796 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=?]\n' + |
| 797 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' + |
| 798 ' --> load_flags = 128 (ENABLE_LOAD_TIMING)\n' + |
| 799 ' --> method = "GET"\n' + |
| 800 ' --> priority = 4\n' + |
| 801 ' --> url = "http://www.google.com/"'; |
| 802 |
| 803 return testCase; |
| 804 } |
| 805 |
| 806 /** |
| 807 * Test case for a URLRequest that was not completed that came from a loaded |
| 808 * log file. |
| 809 */ |
| 810 function painterTestURLRequestIncompleteFromLoadedLog() { |
| 811 var testCase = painterTestURLRequestIncomplete(); |
| 812 testCase.logCreationTime = 1338864634013; |
| 813 testCase.expectedText += '\nt=1338864634013 [st=789]'; |
| 814 return testCase; |
| 815 } |
| 816 |
| 817 /** |
749 * Tests the custom formatting of net_errors across several different event | 818 * Tests the custom formatting of net_errors across several different event |
750 * types. | 819 * types. |
751 */ | 820 */ |
752 function painterTestNetError() { | 821 function painterTestNetError() { |
753 var testCase = {}; | 822 var testCase = {}; |
754 testCase.tickOffset = '1337911098446'; | 823 testCase.tickOffset = '1337911098446'; |
755 | 824 |
756 testCase.logEntries = [ | 825 testCase.logEntries = [ |
757 { | 826 { |
758 'phase': EventPhase.PHASE_BEGIN, | 827 'phase': EventPhase.PHASE_BEGIN, |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 ' --> TLS 1.0 ==> SSL 3.0\n' + | 1603 ' --> TLS 1.0 ==> SSL 3.0\n' + |
1535 ' --> host_and_port = "www-927.ibm.com:443"\n' + | 1604 ' --> host_and_port = "www-927.ibm.com:443"\n' + |
1536 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + | 1605 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' + |
1537 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + | 1606 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' + |
1538 ' --> SSL 3.0 ==> SSL 0x123456'; | 1607 ' --> SSL 3.0 ==> SSL 0x123456'; |
1539 | 1608 |
1540 return testCase; | 1609 return testCase; |
1541 } | 1610 } |
1542 | 1611 |
1543 })(); // Anonymous namespace | 1612 })(); // Anonymous namespace |
OLD | NEW |