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
3 // found in the LICENSE file.
5 // Include test fixture.
6 GEN_INCLUDE(['net_internals_test.js']);
12 * Check that stripCookiesAndLoginInfo correctly removes cookies and login
15 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterStripInfo', function() {
16 // 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
18 // element should be unmodified.
20 ['set-cookie: blah', 'set-cookie: [4 bytes were stripped]'],
21 ['set-cookie2: blah', 'set-cookie2: [4 bytes were stripped]'],
22 ['cookie: blah', 'cookie: [4 bytes were stripped]'],
23 ['authorization: NTLM blah', 'authorization: NTLM [4 bytes were stripped]'],
25 ['proxy-authorization: Basic blah',
26 'proxy-authorization: Basic [4 bytes were stripped]'],
28 ['WWW-Authenticate: Basic realm="Something, or another"', null],
30 ['WWW-Authenticate: Negotiate blah-token-blah',
31 'WWW-Authenticate: Negotiate [15 bytes were stripped]'],
33 ['WWW-Authenticate: NTLM asdllk2j3l423lk4j23l4kj',
34 'WWW-Authenticate: NTLM [23 bytes were stripped]'],
36 ['WWW-Authenticate: Kerberos , Negotiate asdfasdfasdfasfa', null],
37 ['WWW-Authenticate: Kerberos, Negotiate asdfasdfasdfasfa', null],
38 ['WWW-Authenticate: Digest , Negotiate asdfasdfasdfasfa', null],
39 ['WWW-Authenticate: Digest realm="Foo realm", Negotiate asdf', null],
40 ['WWW-Authenticate: Kerberos,Digest,Basic', null],
41 ['WWW-Authenticate: Digest realm="asdfasdf", nonce=5, qop="auth"', null],
42 ['WWW-Authenticate: Basic realm=foo,foo=bar , Digest ', null],
43 ['Proxy-Authenticate: Basic realm="Something, or another"', null],
45 ['Proxy-Authenticate: Negotiate blah-token-blah',
46 'Proxy-Authenticate: Negotiate [15 bytes were stripped]'],
48 ['Proxy-Authenticate: NTLM asdllk2j3l423lk4j23l4kj',
49 'Proxy-Authenticate: NTLM [23 bytes were stripped]'],
51 ['Proxy-Authenticate: Kerberos , Negotiate asdfasdfa', null],
52 ['Proxy-Authenticate: Kerberos, Negotiate asdfasdfa', null],
53 ['Proxy-Authenticate: Digest , Negotiate asdfasdfa', null],
54 ['Proxy-Authenticate: Digest realm="Foo realm", Negotiate asdfasdfa', null],
55 ['Proxy-Authenticate: Kerberos,Digest,Basic', null],
56 ['Proxy-Authenticate: Digest realm="asdfasdf", nonce=5, qop="auth"', null],
57 ['Proxy-Authenticate: Basic realm=foo,foo=bar , Digest ', null],
59 ['cookie: Stuff [4 bytes were stripped]',
60 'cookie: [29 bytes were stripped]'],
61 ['cookie: [4 bytes were stripped] Stuff',
62 'cookie: [29 bytes were stripped]'],
63 ['set-cookie: [4 bytes were stripped]', null],
64 ['Proxy-Authenticate: NTLM [23 bytes were stripped]', null],
65 ['cookie: [value was stripped]', null],
68 for (var i = 0; i < expectations.length; ++i) {
69 var expectation = expectations[i];
70 // Position within params.headers where the authentication information goes.
71 for (var position = 0; position < 3; ++position) {
75 'Host: clients1.google.com',
76 'Connection: keep-alive',
77 'User-Agent: Mozilla/5.0'
79 'line': 'GET / HTTP/1.1\r\n'
81 'phase': EventPhase.PHASE_BEGIN,
82 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
84 'type': EventSourceType.URL_REQUEST
87 entry.params.headers[position] = expectation[0];
88 var stripped = stripCookiesAndLoginInfo(entry);
89 // The entry should be duplicated, so the original still has the deleted
91 expectNotEquals(stripped, entry);
92 if (expectation[1] == null) {
93 expectEquals(expectation[0], stripped.params.headers[position]);
95 expectEquals(expectation[1], stripped.params.headers[position]);
100 // Test with HTTP/2 request headers, which use an object rather than an array.
101 var spdyRequestHeadersEntry = {
104 ':host': 'clients1.google.com',
106 ':path': '/cute/cat/pictures/',
109 'line': 'GET / HTTP/1.1\r\n'
111 'phase': EventPhase.PHASE_BEGIN,
112 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
114 'type': EventSourceType.HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS
116 var strippedSpdyRequestHeadersEntry =
117 stripCookiesAndLoginInfo(spdyRequestHeadersEntry);
118 expectEquals('cookie: [4 bytes were stripped]',
119 strippedSpdyRequestHeadersEntry.params.headers[3]);
125 * Tests the formatting of log entries to fixed width text.
127 TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() {
128 // Add a DOM node to draw the log entries into.
129 var div = addNode(document.body, 'div');
131 // Helper function to run a particular "test case". This comprises an input
132 // and the resulting formatted text expectation.
133 function runTestCase(testCase) {
135 timeutil.setTimeTickOffset(testCase.tickOffset);
138 if (typeof testCase.baseTimeTicks != 'undefined')
139 baseTime = timeutil.convertTimeTicksToTime(testCase.baseTimeTicks);
142 createLogEntryTablePrinter(testCase.logEntries,
143 testCase.privacyStripping,
144 baseTime, testCase.logCreationTime);
145 tablePrinter.toText(0, div);
147 // Strip any trailing newlines, since the whitespace when using innerText
148 // can be a bit unpredictable.
149 var actualText = div.innerText;
150 actualText = actualText.replace(/^\s+|\s+$/g, '');
152 expectEquals(testCase.expectedText, actualText);
155 runTestCase(painterTestURLRequest());
156 runTestCase(painterTestURLRequestIncomplete());
157 runTestCase(painterTestURLRequestIncompleteFromLoadedLog());
158 runTestCase(painterTestURLRequestIncompleteFromLoadedLogSingleEvent());
159 runTestCase(painterTestNetError());
160 runTestCase(painterTestQuicError());
161 runTestCase(painterTestQuicCryptoHandshakeMessage());
162 runTestCase(painterTestHexEncodedBytes());
163 runTestCase(painterTestCertVerifierJob());
164 runTestCase(painterTestCertVerifyResult());
165 runTestCase(painterTestProxyConfigOneProxyAllSchemes());
166 runTestCase(painterTestProxyConfigTwoProxiesAllSchemes());
167 runTestCase(painterTestDontStripCookiesURLRequest());
168 runTestCase(painterTestStripCookiesURLRequest());
169 runTestCase(painterTestDontStripCookiesSPDYSession());
170 runTestCase(painterTestStripCookiesSPDYSession());
171 runTestCase(painterTestSpdyURLRequestDontStripCookies());
172 runTestCase(painterTestSpdyURLRequestStripCookies());
173 runTestCase(painterTestExtraCustomParameter());
174 runTestCase(painterTestMissingCustomParameter());
175 runTestCase(painterTestSSLVersionFallback());
176 runTestCase(painterTestInProgressURLRequest());
177 runTestCase(painterTestBaseTime());
183 * Test case for a URLRequest. This includes custom formatting for load flags,
184 * request/response HTTP headers, dependent sources, as well as basic
185 * indentation and grouping. Also makes sure that no extra event is logged
186 * for finished sources when there's a logCreationTime.
188 function painterTestURLRequest() {
190 testCase.tickOffset = '1337911098446';
191 testCase.logCreationTime = 1338864634013;
192 testCase.loadFlags = LoadFlag.MAIN_FRAME | LoadFlag.MAYBE_USER_GESTURE |
193 LoadFlag.VERIFY_EV_CERT;
195 testCase.logEntries = [
197 'phase': EventPhase.PHASE_BEGIN,
200 'type': EventSourceType.URL_REQUEST
203 'type': EventType.REQUEST_ALIVE
207 'load_flags': testCase.loadFlags,
210 'url': 'http://www.google.com/'
212 'phase': EventPhase.PHASE_BEGIN,
215 'type': EventSourceType.URL_REQUEST
218 'type': EventType.URL_REQUEST_START_JOB
221 'phase': EventPhase.PHASE_END,
224 'type': EventSourceType.URL_REQUEST
227 'type': EventType.URL_REQUEST_START_JOB
231 'load_flags': testCase.loadFlags,
234 'url': 'http://www.google.com/'
236 'phase': EventPhase.PHASE_BEGIN,
239 'type': EventSourceType.URL_REQUEST
242 'type': EventType.URL_REQUEST_START_JOB
245 'phase': EventPhase.PHASE_BEGIN,
248 'type': EventSourceType.URL_REQUEST
251 'type': EventType.HTTP_CACHE_GET_BACKEND
254 'phase': EventPhase.PHASE_END,
257 'type': EventSourceType.URL_REQUEST
260 'type': EventType.HTTP_CACHE_GET_BACKEND
263 'phase': EventPhase.PHASE_BEGIN,
266 'type': EventSourceType.URL_REQUEST
269 'type': EventType.HTTP_CACHE_OPEN_ENTRY
272 'phase': EventPhase.PHASE_END,
275 'type': EventSourceType.URL_REQUEST
278 'type': EventType.HTTP_CACHE_OPEN_ENTRY
281 'phase': EventPhase.PHASE_BEGIN,
284 'type': EventSourceType.URL_REQUEST
287 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
290 'phase': EventPhase.PHASE_END,
293 'type': EventSourceType.URL_REQUEST
296 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
299 'phase': EventPhase.PHASE_BEGIN,
302 'type': EventSourceType.URL_REQUEST
305 'type': EventType.HTTP_CACHE_READ_INFO
308 'phase': EventPhase.PHASE_END,
311 'type': EventSourceType.URL_REQUEST
314 'type': EventType.HTTP_CACHE_READ_INFO
317 'phase': EventPhase.PHASE_BEGIN,
320 'type': EventSourceType.URL_REQUEST
323 'type': EventType.HTTP_STREAM_REQUEST
327 'source_dependency': {
329 'type': EventSourceType.HTTP_STREAM_JOB
332 'phase': EventPhase.PHASE_NONE,
335 'type': EventSourceType.URL_REQUEST
338 'type': EventType.HTTP_STREAM_REQUEST_BOUND_TO_JOB
341 'phase': EventPhase.PHASE_END,
344 'type': EventSourceType.URL_REQUEST
347 'type': EventType.HTTP_STREAM_REQUEST
350 'phase': EventPhase.PHASE_BEGIN,
353 'type': EventSourceType.URL_REQUEST
356 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST
361 'Host: www.google.com',
362 'Connection: keep-alive',
363 'User-Agent: Mozilla/5.0',
365 'Accept-Encoding: gzip,deflate,sdch',
366 'Accept-Language: en-US,en;q=0.8',
367 'Accept-Charset: ISO-8859-1'
369 'line': 'GET / HTTP/1.1\r\n'
371 'phase': EventPhase.PHASE_NONE,
374 'type': EventSourceType.URL_REQUEST
377 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
380 'phase': EventPhase.PHASE_END,
383 'type': EventSourceType.URL_REQUEST
386 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST
389 'phase': EventPhase.PHASE_BEGIN,
392 'type': EventSourceType.URL_REQUEST
395 'type': EventType.HTTP_TRANSACTION_READ_HEADERS
398 'phase': EventPhase.PHASE_BEGIN,
401 'type': EventSourceType.URL_REQUEST
404 'type': EventType.HTTP_STREAM_PARSER_READ_HEADERS
407 'phase': EventPhase.PHASE_END,
410 'type': EventSourceType.URL_REQUEST
413 'type': EventType.HTTP_STREAM_PARSER_READ_HEADERS
419 'Date: Tue, 05 Jun 2012 02:50:33 GMT',
421 'Cache-Control: private, max-age=0',
422 'Content-Type: text/html; charset=UTF-8',
423 'Content-Encoding: gzip',
425 'Content-Length: 23798',
428 'phase': EventPhase.PHASE_NONE,
431 'type': EventSourceType.URL_REQUEST
434 'type': EventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS
437 'phase': EventPhase.PHASE_END,
440 'type': EventSourceType.URL_REQUEST
443 'type': EventType.HTTP_TRANSACTION_READ_HEADERS
446 'phase': EventPhase.PHASE_BEGIN,
449 'type': EventSourceType.URL_REQUEST
452 'type': EventType.HTTP_CACHE_WRITE_INFO
455 'phase': EventPhase.PHASE_END,
458 'type': EventSourceType.URL_REQUEST
461 'type': EventType.HTTP_CACHE_WRITE_INFO
464 'phase': EventPhase.PHASE_BEGIN,
467 'type': EventSourceType.URL_REQUEST
470 'type': EventType.HTTP_CACHE_WRITE_DATA
473 'phase': EventPhase.PHASE_END,
476 'type': EventSourceType.URL_REQUEST
479 'type': EventType.HTTP_CACHE_WRITE_DATA
482 'phase': EventPhase.PHASE_BEGIN,
485 'type': EventSourceType.URL_REQUEST
488 'type': EventType.HTTP_CACHE_WRITE_INFO
491 'phase': EventPhase.PHASE_END,
494 'type': EventSourceType.URL_REQUEST
497 'type': EventType.HTTP_CACHE_WRITE_INFO
500 'phase': EventPhase.PHASE_END,
503 'type': EventSourceType.URL_REQUEST
506 'type': EventType.URL_REQUEST_START_JOB
509 'phase': EventPhase.PHASE_BEGIN,
512 'type': EventSourceType.URL_REQUEST
515 'type': EventType.HTTP_TRANSACTION_READ_BODY
518 'phase': EventPhase.PHASE_END,
521 'type': EventSourceType.URL_REQUEST
524 'type': EventType.HTTP_TRANSACTION_READ_BODY
527 'phase': EventPhase.PHASE_BEGIN,
530 'type': EventSourceType.URL_REQUEST
533 'type': EventType.HTTP_CACHE_WRITE_DATA
536 'phase': EventPhase.PHASE_END,
539 'type': EventSourceType.URL_REQUEST
542 'type': EventType.HTTP_CACHE_WRITE_DATA
545 'phase': EventPhase.PHASE_BEGIN,
548 'type': EventSourceType.URL_REQUEST
551 'type': EventType.HTTP_TRANSACTION_READ_BODY
554 'phase': EventPhase.PHASE_END,
557 'type': EventSourceType.URL_REQUEST
560 'type': EventType.HTTP_TRANSACTION_READ_BODY
563 'phase': EventPhase.PHASE_BEGIN,
566 'type': EventSourceType.URL_REQUEST
569 'type': EventType.HTTP_CACHE_WRITE_DATA
572 'phase': EventPhase.PHASE_END,
575 'type': EventSourceType.URL_REQUEST
578 'type': EventType.HTTP_CACHE_WRITE_DATA
581 'phase': EventPhase.PHASE_BEGIN,
584 'type': EventSourceType.URL_REQUEST
587 'type': EventType.HTTP_TRANSACTION_READ_BODY
590 'phase': EventPhase.PHASE_END,
593 'type': EventSourceType.URL_REQUEST
596 'type': EventType.HTTP_TRANSACTION_READ_BODY
599 'phase': EventPhase.PHASE_BEGIN,
602 'type': EventSourceType.URL_REQUEST
605 'type': EventType.HTTP_CACHE_WRITE_DATA
608 'phase': EventPhase.PHASE_END,
611 'type': EventSourceType.URL_REQUEST
614 'type': EventType.HTTP_CACHE_WRITE_DATA
617 'phase': EventPhase.PHASE_BEGIN,
620 'type': EventSourceType.URL_REQUEST
623 'type': EventType.HTTP_TRANSACTION_READ_BODY
626 'phase': EventPhase.PHASE_END,
629 'type': EventSourceType.URL_REQUEST
632 'type': EventType.HTTP_TRANSACTION_READ_BODY
635 'phase': EventPhase.PHASE_BEGIN,
638 'type': EventSourceType.URL_REQUEST
641 'type': EventType.HTTP_CACHE_WRITE_DATA
644 'phase': EventPhase.PHASE_END,
647 'type': EventSourceType.URL_REQUEST
650 'type': EventType.HTTP_CACHE_WRITE_DATA
653 'phase': EventPhase.PHASE_BEGIN,
656 'type': EventSourceType.URL_REQUEST
659 'type': EventType.HTTP_TRANSACTION_READ_BODY
662 'phase': EventPhase.PHASE_END,
665 'type': EventSourceType.URL_REQUEST
668 'type': EventType.HTTP_TRANSACTION_READ_BODY
671 'phase': EventPhase.PHASE_BEGIN,
674 'type': EventSourceType.URL_REQUEST
677 'type': EventType.HTTP_CACHE_WRITE_DATA
680 'phase': EventPhase.PHASE_END,
683 'type': EventSourceType.URL_REQUEST
686 'type': EventType.HTTP_CACHE_WRITE_DATA
689 'phase': EventPhase.PHASE_BEGIN,
692 'type': EventSourceType.URL_REQUEST
695 'type': EventType.HTTP_TRANSACTION_READ_BODY
698 'phase': EventPhase.PHASE_END,
701 'type': EventSourceType.URL_REQUEST
704 'type': EventType.HTTP_TRANSACTION_READ_BODY
707 'phase': EventPhase.PHASE_BEGIN,
710 'type': EventSourceType.URL_REQUEST
713 'type': EventType.HTTP_CACHE_WRITE_DATA
716 'phase': EventPhase.PHASE_END,
719 'type': EventSourceType.URL_REQUEST
722 'type': EventType.HTTP_CACHE_WRITE_DATA
725 'phase': EventPhase.PHASE_END,
728 'type': EventSourceType.URL_REQUEST
731 'type': EventType.REQUEST_ALIVE
735 testCase.expectedText =
736 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789]\n' +
737 't=1338864633238 [st= 14] URL_REQUEST_START_JOB [dt=8]\n' +
738 ' --> load_flags = ' +
739 testCase.loadFlags.toString() +
740 ' (MAIN_FRAME | MAYBE_USER_GESTURE ' +
741 '| VERIFY_EV_CERT)\n' +
742 ' --> method = "GET"\n' +
743 ' --> priority = 4\n' +
744 ' --> url = "http://www.google.com/"\n' +
745 't=1338864633248 [st= 24] +URL_REQUEST_START_JOB [dt=279]\n' +
746 ' --> load_flags = ' +
747 testCase.loadFlags.toString() +
748 ' (MAIN_FRAME | MAYBE_USER_GESTURE ' +
749 '| VERIFY_EV_CERT)\n' +
750 ' --> method = "GET"\n' +
751 ' --> priority = 4\n' +
752 ' --> url = "http://www.google.com/"\n' +
753 't=1338864633255 [st= 31] HTTP_CACHE_GET_BACKEND [dt=1]\n' +
754 't=1338864633257 [st= 33] HTTP_CACHE_OPEN_ENTRY [dt=5]\n' +
755 't=1338864633263 [st= 39] HTTP_CACHE_ADD_TO_ENTRY [dt=1]\n' +
756 't=1338864633269 [st= 45] HTTP_CACHE_READ_INFO [dt=4]\n' +
757 't=1338864633276 [st= 52] +HTTP_STREAM_REQUEST [dt=72]\n' +
758 't=1338864633344 [st=120] HTTP_STREAM_REQUEST_BOUND_TO_JOB\n' +
759 ' --> source_dependency = 149 ' +
760 '(HTTP_STREAM_JOB)\n' +
761 't=1338864633348 [st=124] -HTTP_STREAM_REQUEST\n' +
762 't=1338864633352 [st=128] +HTTP_TRANSACTION_SEND_REQUEST [dt=9]\n' +
763 't=1338864633356 [st=132] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
764 ' --> GET / HTTP/1.1\n' +
765 ' Host: www.google.com\n' +
766 ' Connection: keep-alive\n' +
767 ' User-Agent: Mozilla/5.0\n' +
768 ' Accept: text/html\n' +
769 ' Accept-Encoding: gzip,deflate,sdch\n' +
770 ' Accept-Language: en-US,en;q=0.8\n' +
771 ' Accept-Charset: ISO-8859-1\n' +
772 't=1338864633361 [st=137] -HTTP_TRANSACTION_SEND_REQUEST\n' +
773 't=1338864633362 [st=138] +HTTP_TRANSACTION_READ_HEADERS [dt=76]\n' +
774 't=1338864633363 [st=139] HTTP_STREAM_PARSER_READ_HEADERS [dt=70]\n' +
775 't=1338864633435 [st=211] HTTP_TRANSACTION_READ_RESPONSE_HEADERS\n' +
776 ' --> HTTP/1.1 200 OK\n' +
777 ' Date: Tue, 05 Jun 2012 02:50:33 GMT\n' +
779 ' Cache-Control: private, max-age=0\n' +
780 ' Content-Type: text/html; charset=UTF-8\n' +
781 ' Content-Encoding: gzip\n' +
783 ' Content-Length: 23798\n' +
784 't=1338864633438 [st=214] -HTTP_TRANSACTION_READ_HEADERS\n' +
785 't=1338864633439 [st=215] HTTP_CACHE_WRITE_INFO [dt=30]\n' +
786 't=1338864633470 [st=246] HTTP_CACHE_WRITE_DATA [dt=38]\n' +
787 't=1338864633508 [st=284] HTTP_CACHE_WRITE_INFO [dt=13]\n' +
788 't=1338864633527 [st=303] -URL_REQUEST_START_JOB\n' +
789 't=1338864633983 [st=759] HTTP_TRANSACTION_READ_BODY [dt=1]\n' +
790 't=1338864633984 [st=760] HTTP_CACHE_WRITE_DATA [dt=3]\n' +
791 't=1338864633988 [st=764] HTTP_TRANSACTION_READ_BODY [dt=3]\n' +
792 't=1338864633992 [st=768] HTTP_CACHE_WRITE_DATA [dt=2]\n' +
793 't=1338864633994 [st=770] HTTP_TRANSACTION_READ_BODY [dt=0]\n' +
794 't=1338864633995 [st=771] HTTP_CACHE_WRITE_DATA [dt=0]\n' +
795 't=1338864633996 [st=772] HTTP_TRANSACTION_READ_BODY [dt=0]\n' +
796 't=1338864633996 [st=772] HTTP_CACHE_WRITE_DATA [dt=1]\n' +
797 't=1338864633998 [st=774] HTTP_TRANSACTION_READ_BODY [dt=1]\n' +
798 't=1338864633999 [st=775] HTTP_CACHE_WRITE_DATA [dt=3]\n' +
799 't=1338864634002 [st=778] HTTP_TRANSACTION_READ_BODY [dt=3]\n' +
800 't=1338864634005 [st=781] HTTP_CACHE_WRITE_DATA [dt=0]\n' +
801 't=1338864634013 [st=789] -REQUEST_ALIVE';
807 * Test case for a URLRequest that was not completed that did not come from a
810 function painterTestURLRequestIncomplete() {
812 testCase.tickOffset = '1337911098446';
814 testCase.logEntries = [
816 'phase': EventPhase.PHASE_BEGIN,
819 'type': EventSourceType.URL_REQUEST
822 'type': EventType.REQUEST_ALIVE
829 'url': 'http://www.google.com/'
831 'phase': EventPhase.PHASE_BEGIN,
834 'type': EventSourceType.URL_REQUEST
837 'type': EventType.URL_REQUEST_START_JOB
840 'phase': EventPhase.PHASE_END,
843 'type': EventSourceType.URL_REQUEST
846 'type': EventType.URL_REQUEST_START_JOB
850 testCase.expectedText =
851 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=?]\n' +
852 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' +
853 ' --> load_flags = 0 (NORMAL)\n' +
854 ' --> method = "GET"\n' +
855 ' --> priority = 4\n' +
856 ' --> url = "http://www.google.com/"';
862 * Test case for a URLRequest that was not completed that came from a loaded
865 function painterTestURLRequestIncompleteFromLoadedLog() {
866 var testCase = painterTestURLRequestIncomplete();
867 testCase.logCreationTime = 1338864634013;
868 testCase.expectedText =
869 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789+]\n' +
870 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' +
871 ' --> load_flags = 0 (NORMAL)\n' +
872 ' --> method = "GET"\n' +
873 ' --> priority = 4\n' +
874 ' --> url = "http://www.google.com/"\n' +
875 't=1338864634013 [st=789]';
880 * Test case for a URLRequest that was not completed that came from a loaded
881 * log file when there's only a begin event.
883 function painterTestURLRequestIncompleteFromLoadedLogSingleEvent() {
884 var testCase = painterTestURLRequestIncomplete();
885 testCase.logEntries = [testCase.logEntries[0]];
886 testCase.logCreationTime = 1338864634013;
887 testCase.expectedText =
888 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789+]\n' +
889 't=1338864634013 [st=789]';
894 * Tests the custom formatting of net_errors across several different event
897 function painterTestNetError() {
899 testCase.tickOffset = '1337911098446';
900 testCase.loadFlags = LoadFlag.MAIN_FRAME | LoadFlag.MAYBE_USER_GESTURE |
901 LoadFlag.VERIFY_EV_CERT;
903 testCase.logEntries = [
905 'phase': EventPhase.PHASE_BEGIN,
908 'type': EventSourceType.URL_REQUEST
911 'type': EventType.REQUEST_ALIVE
915 'load_flags': testCase.loadFlags,
918 'url': 'http://www.doesnotexistdomain.com/'
920 'phase': EventPhase.PHASE_BEGIN,
923 'type': EventSourceType.URL_REQUEST
926 'type': EventType.URL_REQUEST_START_JOB
929 'phase': EventPhase.PHASE_END,
932 'type': EventSourceType.URL_REQUEST
935 'type': EventType.URL_REQUEST_START_JOB
939 'load_flags': testCase.loadFlags,
942 'url': 'http://www.doesnotexistdomain.com/'
944 'phase': EventPhase.PHASE_BEGIN,
947 'type': EventSourceType.URL_REQUEST
950 'type': EventType.URL_REQUEST_START_JOB
953 'phase': EventPhase.PHASE_BEGIN,
956 'type': EventSourceType.URL_REQUEST
959 'type': EventType.HTTP_CACHE_GET_BACKEND
962 'phase': EventPhase.PHASE_END,
965 'type': EventSourceType.URL_REQUEST
968 'type': EventType.HTTP_CACHE_GET_BACKEND
971 'phase': EventPhase.PHASE_BEGIN,
974 'type': EventSourceType.URL_REQUEST
977 'type': EventType.HTTP_CACHE_OPEN_ENTRY
983 'phase': EventPhase.PHASE_END,
986 'type': EventSourceType.URL_REQUEST
989 'type': EventType.HTTP_CACHE_OPEN_ENTRY
992 'phase': EventPhase.PHASE_BEGIN,
995 'type': EventSourceType.URL_REQUEST
998 'type': EventType.HTTP_CACHE_CREATE_ENTRY
1001 'phase': EventPhase.PHASE_END,
1004 'type': EventSourceType.URL_REQUEST
1006 'time': '953675473',
1007 'type': EventType.HTTP_CACHE_CREATE_ENTRY
1010 'phase': EventPhase.PHASE_BEGIN,
1013 'type': EventSourceType.URL_REQUEST
1015 'time': '953675473',
1016 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
1019 'phase': EventPhase.PHASE_END,
1022 'type': EventSourceType.URL_REQUEST
1024 'time': '953675474',
1025 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
1028 'phase': EventPhase.PHASE_BEGIN,
1031 'type': EventSourceType.URL_REQUEST
1033 'time': '953675474',
1034 'type': EventType.HTTP_STREAM_REQUEST
1037 'phase': EventPhase.PHASE_END,
1040 'type': EventSourceType.URL_REQUEST
1042 'time': '953675699',
1043 'type': EventType.HTTP_STREAM_REQUEST
1049 'phase': EventPhase.PHASE_END,
1052 'type': EventSourceType.URL_REQUEST
1054 'time': '953675705',
1055 'type': EventType.URL_REQUEST_START_JOB
1061 'phase': EventPhase.PHASE_END,
1064 'type': EventSourceType.URL_REQUEST
1066 'time': '953675923',
1067 'type': EventType.REQUEST_ALIVE
1071 testCase.expectedText =
1072 't=1338864773894 [st= 0] +REQUEST_ALIVE [dt=475]\n' +
1073 't=1338864773901 [st= 7] URL_REQUEST_START_JOB [dt=5]\n' +
1074 ' --> load_flags = ' +
1075 testCase.loadFlags.toString() +
1076 ' (MAIN_FRAME | MAYBE_USER_GESTURE ' +
1077 '| VERIFY_EV_CERT)\n' +
1078 ' --> method = "GET"\n' +
1079 ' --> priority = 4\n' +
1080 ' --> url = "http://www.doesnotexistdomain.com/"\n' +
1081 't=1338864773906 [st= 12] +URL_REQUEST_START_JOB [dt=245]\n' +
1082 ' --> load_flags = ' +
1083 testCase.loadFlags.toString() +
1084 ' (MAIN_FRAME | MAYBE_USER_GESTURE ' +
1085 '| VERIFY_EV_CERT)\n' +
1086 ' --> method = "GET"\n' +
1087 ' --> priority = 4\n' +
1088 ' --> url = "http://www.doesnotexistdomain.com/"\n' +
1089 't=1338864773915 [st= 21] HTTP_CACHE_GET_BACKEND [dt=0]\n' +
1090 't=1338864773915 [st= 21] HTTP_CACHE_OPEN_ENTRY [dt=1]\n' +
1091 ' --> net_error = -2 (ERR_FAILED)\n' +
1092 't=1338864773917 [st= 23] HTTP_CACHE_CREATE_ENTRY [dt=2]\n' +
1093 't=1338864773919 [st= 25] HTTP_CACHE_ADD_TO_ENTRY [dt=1]\n' +
1094 't=1338864773920 [st= 26] HTTP_STREAM_REQUEST [dt=225]\n' +
1095 't=1338864774151 [st=257] -URL_REQUEST_START_JOB\n' +
1096 ' --> net_error = -105 (ERR_NAME_NOT_RESOLVED)\n' +
1097 't=1338864774369 [st=475] -REQUEST_ALIVE\n' +
1098 ' --> net_error = -105 (ERR_NAME_NOT_RESOLVED)';
1104 * Tests the custom formatting of QUIC errors across several different event
1107 function painterTestQuicError() {
1109 testCase.tickOffset = '1337911098446';
1111 testCase.logEntries = [
1114 "host": "www.example.com"
1116 'phase': EventPhase.PHASE_BEGIN,
1119 'type': EventSourceType.URL_REQUEST
1121 'time': '953675448',
1122 'type': EventType.QUIC_SESSION
1126 'details': "invalid headers",
1127 'quic_rst_stream_error':
1128 QuicRstStreamError.QUIC_BAD_APPLICATION_PAYLOAD,
1131 'phase': EventPhase.PHASE_NONE,
1134 'type': EventSourceType.URL_REQUEST
1136 'time': '953675460',
1137 'type': EventType.QUIC_SESSION_RST_STREAM_FRAME_RECEIVED
1141 'quic_error': QuicError.QUIC_CONNECTION_TIMED_OUT,
1143 'phase': EventPhase.PHASE_NONE,
1146 'type': EventSourceType.URL_REQUEST
1148 'time': '953675705',
1149 'type': EventType.QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED
1153 'quic_error': QuicError.QUIC_CONNECTION_TIMED_OUT
1155 'phase': EventPhase.PHASE_END,
1158 'type': EventSourceType.URL_REQUEST
1160 'time': '953675923',
1161 'type': EventType.QUIC_SESSION
1165 testCase.expectedText =
1166 't=1338864773894 [st= 0] +QUIC_SESSION [dt=475]\n' +
1167 ' --> host = "www.example.com"\n' +
1168 't=1338864773906 [st= 12] QUIC_SESSION_RST_STREAM_FRAME_RECEIVED\n' +
1169 ' --> details = "invalid headers"\n' +
1170 ' --> quic_rst_stream_error = ' +
1171 QuicRstStreamError.QUIC_BAD_APPLICATION_PAYLOAD + ' (' +
1172 'QUIC_BAD_APPLICATION_PAYLOAD)\n' +
1173 ' --> stream_id = 1\n' +
1174 't=1338864774151 [st=257] QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED\n' +
1175 ' --> quic_error = ' +
1176 QuicError.QUIC_CONNECTION_TIMED_OUT + ' (QUIC_CONNECTION_TIMED_OUT)\n' +
1177 't=1338864774369 [st=475] -QUIC_SESSION\n' +
1178 ' --> quic_error = ' +
1179 QuicError.QUIC_CONNECTION_TIMED_OUT + ' (QUIC_CONNECTION_TIMED_OUT)';
1185 * Tests the custom formatting of QUIC crypto handshake messages.
1187 function painterTestQuicCryptoHandshakeMessage() {
1189 testCase.tickOffset = '1337911098446';
1191 testCase.logEntries = [
1194 "host": "www.example.com"
1196 'phase': EventPhase.PHASE_BEGIN,
1199 'type': EventSourceType.URL_REQUEST
1201 'time': '953675448',
1202 'type': EventType.QUIC_SESSION
1206 'quic_crypto_handshake_message':
1218 " KEXS: C255,P256\n" +
1219 " OBIT: 7883764781F2DFD0\n" +
1220 " EXPY: FFEE725200000000\n" +
1224 'phase': EventPhase.PHASE_NONE,
1227 'type': EventSourceType.URL_REQUEST
1229 'time': '953675460',
1230 'type': EventType.QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT
1233 'phase': EventPhase.PHASE_END,
1236 'type': EventSourceType.URL_REQUEST
1238 'time': '953675923',
1239 'type': EventType.QUIC_SESSION
1243 testCase.expectedText =
1244 't=1338864773894 [st= 0] +QUIC_SESSION [dt=475]\n' +
1245 ' --> host = "www.example.com"\n' +
1246 't=1338864773906 [st= 12] QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT\n' +
1258 ' KEXS: C255,P256\n' +
1259 ' OBIT: 7883764781F2DFD0\n' +
1260 ' EXPY: FFEE725200000000\n' +
1263 't=1338864774369 [st=475] -QUIC_SESSION';
1269 * Tests the formatting of bytes sent/received as hex + ASCII. Note that the
1270 * test data was truncated which is why the byte_count doesn't quite match the
1271 * hex_encoded_bytes.
1273 function painterTestHexEncodedBytes() {
1275 testCase.tickOffset = '1337911098473';
1277 testCase.logEntries = [
1280 'source_dependency': {
1282 'type': EventSourceType.CONNECT_JOB
1285 'phase': EventPhase.PHASE_BEGIN,
1288 'type': EventSourceType.SOCKET
1290 'time': '953918459',
1291 'type': EventType.SOCKET_ALIVE
1299 'phase': EventPhase.PHASE_BEGIN,
1302 'type': EventSourceType.SOCKET
1304 'time': '953918460',
1305 'type': EventType.TCP_CONNECT
1309 'address': '184.30.253.15:80'
1311 'phase': EventPhase.PHASE_BEGIN,
1314 'type': EventSourceType.SOCKET
1316 'time': '953918461',
1317 'type': EventType.TCP_CONNECT_ATTEMPT
1320 'phase': EventPhase.PHASE_END,
1323 'type': EventSourceType.SOCKET
1325 'time': '953918464',
1326 'type': EventType.TCP_CONNECT_ATTEMPT
1330 'source_address': '127.0.0.1:54041'
1332 'phase': EventPhase.PHASE_END,
1335 'type': EventSourceType.SOCKET
1337 'time': '953918465',
1338 'type': EventType.TCP_CONNECT
1342 'source_dependency': {
1344 'type': EventSourceType.HTTP_STREAM_JOB
1347 'phase': EventPhase.PHASE_BEGIN,
1350 'type': EventSourceType.SOCKET
1352 'time': '953918472',
1353 'type': EventType.SOCKET_IN_USE
1358 'hex_encoded_bytes': '474554202F66617669636F6E2E69636F20485454502' +
1359 'F312E310D0A486F73743A207777772E6170706C652E' +
1360 '636F6D0D0A436F6E6E656374696F6E3A20'
1362 'phase': EventPhase.PHASE_NONE,
1365 'type': EventSourceType.SOCKET
1367 'time': '953918484',
1368 'type': EventType.SOCKET_BYTES_SENT
1373 'hex_encoded_bytes': '485454502F312E3120323030204F4B0D0A4C6173742' +
1374 'D4D6F6469666965643A204D6F6E2C20313920446563' +
1375 '20323031312032323A34363A353920474D'
1377 'phase': EventPhase.PHASE_NONE,
1380 'type': EventSourceType.SOCKET
1382 'time': '953918596',
1383 'type': EventType.SOCKET_BYTES_RECEIVED
1387 testCase.expectedText =
1388 't=1338865016932 [st= 0] +SOCKET_ALIVE [dt=?]\n' +
1389 ' --> source_dependency = 634 (CONNECT_JOB)\n' +
1390 't=1338865016933 [st= 1] +TCP_CONNECT [dt=5]\n' +
1391 ' --> address_list = ["184.30.253.15:80"]\n' +
1392 't=1338865016934 [st= 2] TCP_CONNECT_ATTEMPT [dt=3]\n' +
1393 ' --> address = "184.30.253.15:80"\n' +
1394 't=1338865016938 [st= 6] -TCP_CONNECT\n' +
1395 ' --> source_address = "127.0.0.1:54041"\n' +
1396 't=1338865016945 [st= 13] +SOCKET_IN_USE [dt=?]\n' +
1397 ' --> source_dependency = 628 (HTTP_STREAM_JOB)\n' +
1398 't=1338865016957 [st= 25] SOCKET_BYTES_SENT\n' +
1399 ' --> byte_count = 780\n' +
1400 ' --> hex_encoded_bytes =\n' +
1401 ' 47 45 54 20 2F 66 61 76 69 63 6F 6E 2E 69 ' +
1402 '63 6F GET /favicon.ico\n' +
1403 ' 20 48 54 54 50 2F 31 2E 31 0D 0A 48 6F 73 ' +
1404 '74 3A HTTP/1.1..Host:\n' +
1405 ' 20 77 77 77 2E 61 70 70 6C 65 2E 63 6F 6D ' +
1406 '0D 0A www.apple.com..\n' +
1407 ' 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 ' +
1409 't=1338865017069 [st=137] SOCKET_BYTES_RECEIVED\n' +
1410 ' --> byte_count = 1024\n' +
1411 ' --> hex_encoded_bytes =\n' +
1412 ' 48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F ' +
1413 '4B 0D HTTP/1.1 200 OK.\n' +
1414 ' 0A 4C 61 73 74 2D 4D 6F 64 69 66 69 65 64 ' +
1415 '3A 20 .Last-Modified: \n' +
1416 ' 4D 6F 6E 2C 20 31 39 20 44 65 63 20 32 30 ' +
1417 '31 31 Mon, 19 Dec 2011\n' +
1418 ' 20 32 32 3A 34 36 3A 35 39 20 47 4D ' +
1425 * Tests the formatting of certificates.
1427 function painterTestCertVerifierJob() {
1429 testCase.tickOffset = '1337911098481';
1431 testCase.logEntries = [
1435 '-----BEGIN CERTIFICATE-----\n1\n-----END CERTIFICATE-----\n',
1436 '-----BEGIN CERTIFICATE-----\n2\n-----END CERTIFICATE-----\n',
1439 'phase': EventPhase.PHASE_BEGIN,
1442 'type': EventSourceType.CERT_VERIFIER_JOB
1444 'time': '954124663',
1445 'type': EventType.CERT_VERIFIER_JOB
1448 'phase': EventPhase.PHASE_END,
1451 'type': EventSourceType.CERT_VERIFIER_JOB
1453 'time': '954124697',
1454 'type': EventType.CERT_VERIFIER_JOB
1458 testCase.expectedText =
1459 't=1338865223144 [st=0] CERT_VERIFIER_JOB [dt=34]\n' +
1460 ' --> certificates =\n' +
1461 ' -----BEGIN CERTIFICATE-----\n' +
1463 ' -----END CERTIFICATE-----\n' +
1465 ' -----BEGIN CERTIFICATE-----\n' +
1467 ' -----END CERTIFICATE-----';
1473 * Tests the formatting of CertVerifyResult fields.
1475 function painterTestCertVerifyResult() {
1477 testCase.tickOffset = '1337911098481';
1479 testCase.logEntries = [
1483 '-----BEGIN CERTIFICATE-----\n1\n-----END CERTIFICATE-----\n',
1484 '-----BEGIN CERTIFICATE-----\n2\n-----END CERTIFICATE-----\n',
1487 'phase': EventPhase.PHASE_BEGIN,
1490 'type': EventSourceType.CERT_VERIFIER_JOB
1492 'time': '954124663',
1493 'type': EventType.CERT_VERIFIER_JOB
1500 'is_issued_by_known_root': true,
1501 'is_issued_by_additional_trust_anchor': false,
1502 'common_name_fallback_used': true,
1506 '-----BEGIN CERTIFICATE-----\n1\n-----END CERTIFICATE-----\n',
1507 '-----BEGIN CERTIFICATE-----\n2\n-----END CERTIFICATE-----\n',
1510 'public_key_hashes': [
1515 'phase': EventPhase.PHASE_END,
1518 'type': EventSourceType.CERT_VERIFIER_JOB
1520 'time': '954124697',
1521 'type': EventType.CERT_VERIFIER_JOB
1525 testCase.expectedText =
1526 't=1338865223144 [st= 0] +CERT_VERIFIER_JOB [dt=34]\n' +
1527 ' --> certificates =\n' +
1528 ' -----BEGIN CERTIFICATE-----\n' +
1530 ' -----END CERTIFICATE-----\n' +
1532 ' -----BEGIN CERTIFICATE-----\n' +
1534 ' -----END CERTIFICATE-----\n' +
1536 't=1338865223178 [st=34] -CERT_VERIFIER_JOB\n' +
1537 ' --> verified_cert =\n' +
1538 ' -----BEGIN CERTIFICATE-----\n' +
1540 ' -----END CERTIFICATE-----\n' +
1542 ' -----BEGIN CERTIFICATE-----\n' +
1544 ' -----END CERTIFICATE-----\n' +
1546 ' --> cert_status = 5 (AUTHORITY_INVALID |' +
1547 ' COMMON_NAME_INVALID)\n' +
1548 ' --> has_md5 = true\n' +
1549 ' --> has_md2 = false\n' +
1550 ' --> has_md4 = true\n' +
1551 ' --> is_issued_by_known_root = true\n' +
1552 ' --> is_issued_by_additional_trust_anchor =' +
1553 ' false\n --> common_name_fallback_used = true\n' +
1554 ' --> public_key_hashes = ["hash1","hash2"]';
1560 * Tests the formatting of proxy configurations when using one proxy server for
1563 function painterTestProxyConfigOneProxyAllSchemes() {
1565 testCase.tickOffset = '1337911098481';
1567 testCase.logEntries = [
1571 'auto_detect': true,
1577 'pac_url': 'https://config/wpad.dat',
1578 'single_proxy': 'cache-proxy:3128',
1585 'phase': EventPhase.PHASE_NONE,
1588 'type': EventSourceType.NONE
1590 'time': '954443578',
1591 'type': EventType.PROXY_CONFIG_CHANGED
1595 testCase.expectedText =
1596 't=1338865542059 [st=0] PROXY_CONFIG_CHANGED\n' +
1597 ' --> old_config =\n' +
1599 ' --> new_config =\n' +
1600 ' (1) Auto-detect\n' +
1601 ' (2) PAC script: https://config/wpad.dat\n' +
1602 ' (3) Proxy server: cache-proxy:3128\n' +
1603 ' Bypass list: \n' +
1613 * Tests the formatting of proxy configurations when using two proxy servers for
1616 function painterTestProxyConfigTwoProxiesAllSchemes() {
1618 testCase.tickOffset = '1337911098481';
1620 testCase.logEntries = [
1624 'auto_detect': true,
1630 'pac_url': 'https://config/wpad.dat',
1631 'single_proxy': ['cache-proxy:3128', 'socks4://other:999'],
1638 'phase': EventPhase.PHASE_NONE,
1641 'type': EventSourceType.NONE
1643 'time': '954443578',
1644 'type': EventType.PROXY_CONFIG_CHANGED
1648 testCase.expectedText =
1649 't=1338865542059 [st=0] PROXY_CONFIG_CHANGED\n' +
1650 ' --> old_config =\n' +
1652 ' --> new_config =\n' +
1653 ' (1) Auto-detect\n' +
1654 ' (2) PAC script: https://config/wpad.dat\n' +
1655 ' (3) Proxy server: [cache-proxy:3128, ' +
1656 'socks4://other:999]\n' +
1657 ' Bypass list: \n' +
1667 * Tests that cookies are NOT stripped from URLRequests when stripping is
1670 function painterTestDontStripCookiesURLRequest() {
1672 testCase.tickOffset = '1337911098139';
1674 testCase.logEntries = [
1678 'HTTP/1.1 301 Moved Permanently',
1679 'Cache-Control: private',
1680 'Content-Length: 23',
1681 'Content-Type: text/html',
1682 'Location: http://msdn.microsoft.com',
1683 'Server: Microsoft-IIS/7.5',
1684 'Set-Cookie: MyMagicPony',
1686 'X-Powered-By: ASP.NET',
1687 'X-UA-Compatible: IE=EmulateIE7',
1688 'Date: Tue, 05 Jun 2012 21:06:45 GMT',
1692 'phase': EventPhase.PHASE_NONE,
1695 'type': EventSourceType.URL_REQUEST
1697 'time': '1019307339',
1698 'type': EventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS
1703 'Host: msdn.microsoft.com',
1704 'Connection: keep-alive',
1705 'User-Agent: Mozilla/5.0',
1706 'Accept: text/html',
1707 'Accept-Encoding: gzip,deflate,sdch',
1708 'Accept-Language: en-US,en;q=0.8',
1709 'Accept-Charset: ISO-8859-1',
1710 'Cookie: MyMagicPony'
1712 'line': 'GET / HTTP/1.1\r\n'
1714 'phase': EventPhase.PHASE_NONE,
1717 'type': EventSourceType.URL_REQUEST
1719 'time': '1019307458',
1720 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
1724 testCase.expectedText =
1725 't=1338930405478 [st= 0] HTTP_TRANSACTION_READ_RESPONSE_HEADERS\n' +
1726 ' --> HTTP/1.1 301 Moved Permanently\n' +
1727 ' Cache-Control: private\n' +
1728 ' Content-Length: 23\n' +
1729 ' Content-Type: text/html\n' +
1730 ' Location: http://msdn.microsoft.com\n' +
1731 ' Server: Microsoft-IIS/7.5\n' +
1732 ' Set-Cookie: MyMagicPony\n' +
1733 ' P3P: CP="ALL"\n' +
1734 ' X-Powered-By: ASP.NET\n' +
1735 ' X-UA-Compatible: IE=EmulateIE7\n' +
1736 ' Date: Tue, 05 Jun 2012 21:06:45 GMT\n' +
1737 ' Connection: close\n' +
1738 't=1338930405597 [st=119] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
1739 ' --> GET / HTTP/1.1\n' +
1740 ' Host: msdn.microsoft.com\n' +
1741 ' Connection: keep-alive\n' +
1742 ' User-Agent: Mozilla/5.0\n' +
1743 ' Accept: text/html\n' +
1744 ' Accept-Encoding: gzip,deflate,sdch\n' +
1745 ' Accept-Language: en-US,en;q=0.8\n' +
1746 ' Accept-Charset: ISO-8859-1\n' +
1747 ' Cookie: MyMagicPony';
1753 * Tests that cookies are stripped from URLRequest when stripping is enabled.
1755 function painterTestStripCookiesURLRequest() {
1756 var testCase = painterTestDontStripCookiesURLRequest();
1757 testCase.privacyStripping = true;
1758 testCase.expectedText =
1759 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]');
1764 * Tests that cookies are NOT stripped from HTTP/2 sessions when stripping is
1765 * not enabled. This test data was pieced together in order to get a "cookie"
1766 * and "set-cookie" header.
1768 function painterTestDontStripCookiesSPDYSession() {
1770 testCase.tickOffset = '1337911097783';
1772 testCase.logEntries = [
1777 ':host: mail.google.com',
1779 ':path: /a/google.com',
1781 ':version: HTTP/1.1',
1782 'accept: text/html',
1783 'accept-charset: ISO-8859-1',
1784 'accept-encoding: gzip,deflate,sdch',
1785 'accept-language: en-US,en;q=0.8',
1786 'cookie: MyMagicPony',
1787 'user-agent: Mozilla/5.0'
1791 'phase': EventPhase.PHASE_NONE,
1794 'type': EventSourceType.HTTP2_SESSION
1796 'time': '1012984638',
1797 'type': EventType.HTTP2_SESSION_SYN_STREAM
1803 ':status: 204 No Content',
1804 ':version: HTTP/1.1',
1805 'date: Tue, 05 Jun 2012 19:21:30 GMT',
1807 'set-cookie: MyMagicPony',
1808 'x-random-header: sup'
1812 'phase': EventPhase.PHASE_NONE,
1815 'type': EventSourceType.HTTP2_SESSION
1817 'time': '1012992266',
1818 'type': EventType.HTTP2_SESSION_SYN_REPLY
1822 testCase.expectedText =
1823 't=1338924082421 [st= 0] HTTP2_SESSION_SYN_STREAM\n' +
1824 ' --> flags = 1\n' +
1825 ' --> :host: mail.google.com\n' +
1827 ' :path: /a/google.com\n' +
1828 ' :scheme: https\n' +
1829 ' :version: HTTP/1.1\n' +
1830 ' accept: text/html\n' +
1831 ' accept-charset: ISO-8859-1\n' +
1832 ' accept-encoding: gzip,deflate,sdch\n' +
1833 ' accept-language: en-US,en;q=0.8\n' +
1834 ' cookie: MyMagicPony\n' +
1835 ' user-agent: Mozilla/5.0\n' +
1836 ' --> stream_id = 1\n' +
1837 't=1338924090049 [st=7628] HTTP2_SESSION_SYN_REPLY\n' +
1838 ' --> flags = 0\n' +
1839 ' --> :status: 204 No Content\n' +
1840 ' :version: HTTP/1.1\n' +
1841 ' date: Tue, 05 Jun 2012 19:21:30 GMT\n' +
1843 ' set-cookie: MyMagicPony\n' +
1844 ' x-random-header: sup\n' +
1845 ' --> stream_id = 5';
1851 * Tests that cookies are stripped from HTTP/2 sessions when stripping is
1854 function painterTestStripCookiesSPDYSession() {
1855 var testCase = painterTestDontStripCookiesSPDYSession();
1856 testCase.privacyStripping = true;
1857 testCase.expectedText =
1858 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]');
1863 * Tests that cookies are NOT stripped from HTTP/2 URL request headers when
1864 * stripping is not enabled. The difference from the above requests is that
1865 * HTTP/2 URL request headers use dictionaries rather than lists.
1867 function painterTestSpdyURLRequestDontStripCookies() {
1869 testCase.tickOffset = '1337911098481';
1871 testCase.logEntries = [
1875 ':host': 'www.google.com',
1879 ':version': 'HTTP/1.1',
1880 'cookie': 'MyMagicPony'},
1882 'phase': EventPhase.PHASE_NONE,
1883 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
1884 'time': '954124663',
1885 'type': EventType.HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS
1889 testCase.expectedText =
1890 't=1338865223144 [st=0] HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS\n' +
1891 ' --> :host: www.google.com\n' +
1894 ' :scheme: https\n' +
1895 ' :version: HTTP/1.1\n' +
1896 ' cookie: MyMagicPony';
1901 * Tests that cookies are NOT stripped from HTTP/2 URL request headers when
1902 * stripping is not enabled. The difference from the above requests is that
1904 function painterTestSpdyURLRequestStripCookies() {
1905 var testCase = painterTestSpdyURLRequestDontStripCookies();
1906 testCase.privacyStripping = true;
1907 testCase.expectedText =
1908 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]');
1913 * Tests that when there are more custom parameters than we expect for an
1914 * event type, they are printed out in addition to the custom formatting.
1916 function painterTestExtraCustomParameter() {
1918 testCase.tickOffset = '1337911098446';
1920 testCase.logEntries = [
1924 'Host: www.google.com',
1925 'Connection: keep-alive'
1927 'line': 'GET / HTTP/1.1\r\n',
1928 // This is unexpected!
1929 'hello': 'yo dawg, i heard you like strings'
1931 'phase': EventPhase.PHASE_NONE,
1934 'type': EventSourceType.URL_REQUEST
1936 'time': '953534910',
1937 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
1941 testCase.expectedText =
1942 't=1338864633356 [st=0] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
1943 ' --> GET / HTTP/1.1\n' +
1944 ' Host: www.google.com\n' +
1945 ' Connection: keep-alive\n' +
1946 ' --> hello = "yo dawg, i heard you like strings"';
1952 * Tests that when the custom parameters for an event type don't match
1953 * what we expect, we fall back to default formatting.
1955 function painterTestMissingCustomParameter() {
1957 testCase.tickOffset = '1337911098446';
1959 testCase.logEntries = [
1962 // The expectation is for this to be called "headers".
1964 'Host: www.google.com',
1965 'Connection: keep-alive'
1967 'line': 'GET / HTTP/1.1\r\n'
1969 'phase': EventPhase.PHASE_NONE,
1972 'type': EventSourceType.URL_REQUEST
1974 'time': '953534910',
1975 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
1979 testCase.expectedText =
1980 't=1338864633356 [st=0] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
1981 ' --> headersWRONG = ["Host: www.google.com",' +
1982 '"Connection: keep-alive"]\n' +
1983 ' --> line = "GET / HTTP/1.1\\r\\n"';
1989 * Tests the formatting for an SSL version fallback event.
1991 function painterTestSSLVersionFallback() {
1993 testCase.tickOffset = '1337911098400';
1995 testCase.logEntries = [
1998 'host_and_port': 'www-927.ibm.com:443',
2000 'version_after': 0x301,
2001 'version_before': 0x302
2003 'phase': EventPhase.PHASE_NONE,
2006 'type': EventSourceType.URL_REQUEST
2008 'time': '1119062679',
2009 'type': EventType.SSL_VERSION_FALLBACK
2013 'host_and_port': 'www-927.ibm.com:443',
2015 'version_after': 0x300,
2016 'version_before': 0x301
2018 'phase': EventPhase.PHASE_NONE,
2021 'type': EventSourceType.URL_REQUEST
2023 'time': '1119062850',
2024 'type': EventType.SSL_VERSION_FALLBACK
2028 'version_after': 0x123456,
2029 'version_before': 0x300
2031 'phase': EventPhase.PHASE_NONE,
2034 'type': EventSourceType.URL_REQUEST
2036 'time': '1119062850',
2037 'type': EventType.SSL_VERSION_FALLBACK
2041 testCase.expectedText =
2042 't=1339030161079 [st= 0] SSL_VERSION_FALLBACK\n' +
2043 ' --> TLS 1.1 ==> TLS 1.0\n' +
2044 ' --> host_and_port = "www-927.ibm.com:443"\n' +
2045 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' +
2046 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' +
2047 ' --> TLS 1.0 ==> SSL 3.0\n' +
2048 ' --> host_and_port = "www-927.ibm.com:443"\n' +
2049 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' +
2050 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' +
2051 ' --> SSL 3.0 ==> SSL 0x123456';
2057 * Tests the formatting of a URL request that was just finishing up when
2058 * net-internals was opened.
2060 function painterTestInProgressURLRequest() {
2062 testCase.tickOffset = '1337911098446';
2063 testCase.loadFlags = LoadFlag.MAIN_FRAME | LoadFlag.MAYBE_USER_GESTURE |
2064 LoadFlag.VERIFY_EV_CERT;
2066 testCase.logEntries = [
2069 'load_flags': testCase.loadFlags,
2070 'load_state': LoadState.READING_RESPONSE,
2072 'url': 'http://www.MagicPonyShopper.com'
2074 'phase': EventPhase.PHASE_BEGIN,
2077 'type': EventSourceType.URL_REQUEST
2079 'time': '953675548',
2080 'type': EventType.REQUEST_ALIVE
2083 'phase': EventPhase.PHASE_END,
2086 'type': EventSourceType.URL_REQUEST
2088 'time': '953675699',
2089 'type': EventType.HTTP_STREAM_REQUEST
2092 'phase': EventPhase.PHASE_END,
2095 'type': EventSourceType.URL_REQUEST
2097 'time': '953675705',
2098 'type': EventType.URL_REQUEST_START_JOB
2101 'phase': EventPhase.PHASE_END,
2104 'type': EventSourceType.URL_REQUEST
2106 'time': '953675923',
2107 'type': EventType.REQUEST_ALIVE
2111 testCase.expectedText =
2112 't=1338864773994 [st= 0] +REQUEST_ALIVE [dt=375]\n' +
2113 ' --> load_flags = ' +
2114 testCase.loadFlags.toString() +
2115 ' (MAIN_FRAME | MAYBE_USER_GESTURE ' +
2116 '| VERIFY_EV_CERT)\n' +
2117 ' --> load_state = ' + LoadState.READING_RESPONSE +
2118 ' (READING_RESPONSE)\n' +
2119 ' --> method = "GET"\n' +
2120 ' --> url = "http://www.MagicPonyShopper.com"\n' +
2121 't=1338864774145 [st=151] -HTTP_STREAM_REQUEST\n' +
2122 't=1338864774151 [st=157] -URL_REQUEST_START_JOB\n' +
2123 't=1338864774369 [st=375] -REQUEST_ALIVE';
2129 * Tests the formatting using a non-zero base time. Also has no final event,
2130 * to make sure logCreationTime is handled correctly.
2132 function painterTestBaseTime() {
2134 testCase.tickOffset = '1337911098446';
2135 testCase.logCreationTime = 1338864774783;
2136 testCase.baseTimeTicks = '953675546';
2138 testCase.logEntries = [
2140 'phase': EventPhase.PHASE_BEGIN,
2143 'type': EventSourceType.URL_REQUEST
2145 'time': '953675548',
2146 'type': EventType.REQUEST_ALIVE
2149 'phase': EventPhase.PHASE_BEGIN,
2152 'type': EventSourceType.URL_REQUEST
2154 'time': '953675698',
2155 'type': EventType.HTTP_STREAM_REQUEST
2158 'phase': EventPhase.PHASE_END,
2161 'type': EventSourceType.URL_REQUEST
2163 'time': '953675699',
2164 'type': EventType.HTTP_STREAM_REQUEST
2168 testCase.expectedText =
2169 't= 2 [st= 0] +REQUEST_ALIVE [dt=789+]\n' +
2170 't=152 [st=150] HTTP_STREAM_REQUEST [dt=1]\n' +
2176 })(); // Anonymous namespace