Move Webstore URL concepts to //extensions and out
[chromium-blink-merge.git] / chrome / test / data / webui / net_internals / log_view_painter.js
blobd9621ef3da24101983770d89c0f3d72f29a893b9
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']);
8 // Anonymous namespace
9 (function() {
11 /**
12 * Check that stripCookiesAndLoginInfo correctly removes cookies and login
13 * information.
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.
19 var expectations = [
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) {
72 var entry = {
73 'params': {
74 'headers': [
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},
83 'time': '22468349',
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
90 // information.
91 expectNotEquals(stripped, entry);
92 if (expectation[1] == null) {
93 expectEquals(expectation[0], stripped.params.headers[position]);
94 } else {
95 expectEquals(expectation[1], stripped.params.headers[position]);
100 // Test with SPDY request headers, which use an object rather than an array.
101 var spdyRequestHeadersEntry = {
102 'params': {
103 'headers': {
104 ':host': 'clients1.google.com',
105 ':method': 'GET',
106 ':path': '/cute/cat/pictures/',
107 'cookie': 'blah'
109 'line': 'GET / HTTP/1.1\r\n'
111 'phase': EventPhase.PHASE_BEGIN,
112 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
113 'time': '22468349',
114 'type': EventSourceType.HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS
116 var strippedSpdyRequestHeadersEntry =
117 stripCookiesAndLoginInfo(spdyRequestHeadersEntry);
118 expectEquals('cookie: [4 bytes were stripped]',
119 strippedSpdyRequestHeadersEntry.params.headers[3]);
121 testDone();
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) {
134 div.innerHTML = '';
135 timeutil.setTimeTickOffset(testCase.tickOffset);
137 var baseTime = 0;
138 if (typeof testCase.baseTimeTicks != 'undefined')
139 baseTime = timeutil.convertTimeTicksToTime(testCase.baseTimeTicks);
141 var tablePrinter =
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());
179 testDone();
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() {
189 var testCase = {};
190 testCase.tickOffset = '1337911098446';
191 testCase.logCreationTime = 1338864634013;
193 testCase.logEntries = [
195 'phase': EventPhase.PHASE_BEGIN,
196 'source': {
197 'id': 146,
198 'type': EventSourceType.URL_REQUEST
200 'time': '953534778',
201 'type': EventType.REQUEST_ALIVE
204 'params': {
205 'load_flags': 68222976,
206 'method': 'GET',
207 'priority': 4,
208 'url': 'http://www.google.com/'
210 'phase': EventPhase.PHASE_BEGIN,
211 'source': {
212 'id': 146,
213 'type': EventSourceType.URL_REQUEST
215 'time': '953534792',
216 'type': EventType.URL_REQUEST_START_JOB
219 'phase': EventPhase.PHASE_END,
220 'source': {
221 'id': 146,
222 'type': EventSourceType.URL_REQUEST
224 'time': '953534800',
225 'type': EventType.URL_REQUEST_START_JOB
228 'params': {
229 'load_flags': 68222976,
230 'method': 'GET',
231 'priority': 4,
232 'url': 'http://www.google.com/'
234 'phase': EventPhase.PHASE_BEGIN,
235 'source': {
236 'id': 146,
237 'type': EventSourceType.URL_REQUEST
239 'time': '953534802',
240 'type': EventType.URL_REQUEST_START_JOB
243 'phase': EventPhase.PHASE_BEGIN,
244 'source': {
245 'id': 146,
246 'type': EventSourceType.URL_REQUEST
248 'time': '953534809',
249 'type': EventType.HTTP_CACHE_GET_BACKEND
252 'phase': EventPhase.PHASE_END,
253 'source': {
254 'id': 146,
255 'type': EventSourceType.URL_REQUEST
257 'time': '953534810',
258 'type': EventType.HTTP_CACHE_GET_BACKEND
261 'phase': EventPhase.PHASE_BEGIN,
262 'source': {
263 'id': 146,
264 'type': EventSourceType.URL_REQUEST
266 'time': '953534811',
267 'type': EventType.HTTP_CACHE_OPEN_ENTRY
270 'phase': EventPhase.PHASE_END,
271 'source': {
272 'id': 146,
273 'type': EventSourceType.URL_REQUEST
275 'time': '953534816',
276 'type': EventType.HTTP_CACHE_OPEN_ENTRY
279 'phase': EventPhase.PHASE_BEGIN,
280 'source': {
281 'id': 146,
282 'type': EventSourceType.URL_REQUEST
284 'time': '953534817',
285 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
288 'phase': EventPhase.PHASE_END,
289 'source': {
290 'id': 146,
291 'type': EventSourceType.URL_REQUEST
293 'time': '953534818',
294 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
297 'phase': EventPhase.PHASE_BEGIN,
298 'source': {
299 'id': 146,
300 'type': EventSourceType.URL_REQUEST
302 'time': '953534823',
303 'type': EventType.HTTP_CACHE_READ_INFO
306 'phase': EventPhase.PHASE_END,
307 'source': {
308 'id': 146,
309 'type': EventSourceType.URL_REQUEST
311 'time': '953534827',
312 'type': EventType.HTTP_CACHE_READ_INFO
315 'phase': EventPhase.PHASE_BEGIN,
316 'source': {
317 'id': 146,
318 'type': EventSourceType.URL_REQUEST
320 'time': '953534830',
321 'type': EventType.HTTP_STREAM_REQUEST
324 'params': {
325 'source_dependency': {
326 'id': 149,
327 'type': EventSourceType.HTTP_STREAM_JOB
330 'phase': EventPhase.PHASE_NONE,
331 'source': {
332 'id': 146,
333 'type': EventSourceType.URL_REQUEST
335 'time': '953534898',
336 'type': EventType.HTTP_STREAM_REQUEST_BOUND_TO_JOB
339 'phase': EventPhase.PHASE_END,
340 'source': {
341 'id': 146,
342 'type': EventSourceType.URL_REQUEST
344 'time': '953534902',
345 'type': EventType.HTTP_STREAM_REQUEST
348 'phase': EventPhase.PHASE_BEGIN,
349 'source': {
350 'id': 146,
351 'type': EventSourceType.URL_REQUEST
353 'time': '953534906',
354 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST
357 'params': {
358 'headers': [
359 'Host: www.google.com',
360 'Connection: keep-alive',
361 'User-Agent: Mozilla/5.0',
362 'Accept: text/html',
363 'Accept-Encoding: gzip,deflate,sdch',
364 'Accept-Language: en-US,en;q=0.8',
365 'Accept-Charset: ISO-8859-1'
367 'line': 'GET / HTTP/1.1\r\n'
369 'phase': EventPhase.PHASE_NONE,
370 'source': {
371 'id': 146,
372 'type': EventSourceType.URL_REQUEST
374 'time': '953534910',
375 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
378 'phase': EventPhase.PHASE_END,
379 'source': {
380 'id': 146,
381 'type': EventSourceType.URL_REQUEST
383 'time': '953534915',
384 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST
387 'phase': EventPhase.PHASE_BEGIN,
388 'source': {
389 'id': 146,
390 'type': EventSourceType.URL_REQUEST
392 'time': '953534916',
393 'type': EventType.HTTP_TRANSACTION_READ_HEADERS
396 'phase': EventPhase.PHASE_BEGIN,
397 'source': {
398 'id': 146,
399 'type': EventSourceType.URL_REQUEST
401 'time': '953534917',
402 'type': EventType.HTTP_STREAM_PARSER_READ_HEADERS
405 'phase': EventPhase.PHASE_END,
406 'source': {
407 'id': 146,
408 'type': EventSourceType.URL_REQUEST
410 'time': '953534987',
411 'type': EventType.HTTP_STREAM_PARSER_READ_HEADERS
414 'params': {
415 'headers': [
416 'HTTP/1.1 200 OK',
417 'Date: Tue, 05 Jun 2012 02:50:33 GMT',
418 'Expires: -1',
419 'Cache-Control: private, max-age=0',
420 'Content-Type: text/html; charset=UTF-8',
421 'Content-Encoding: gzip',
422 'Server: gws',
423 'Content-Length: 23798',
426 'phase': EventPhase.PHASE_NONE,
427 'source': {
428 'id': 146,
429 'type': EventSourceType.URL_REQUEST
431 'time': '953534989',
432 'type': EventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS
435 'phase': EventPhase.PHASE_END,
436 'source': {
437 'id': 146,
438 'type': EventSourceType.URL_REQUEST
440 'time': '953534992',
441 'type': EventType.HTTP_TRANSACTION_READ_HEADERS
444 'phase': EventPhase.PHASE_BEGIN,
445 'source': {
446 'id': 146,
447 'type': EventSourceType.URL_REQUEST
449 'time': '953534993',
450 'type': EventType.HTTP_CACHE_WRITE_INFO
453 'phase': EventPhase.PHASE_END,
454 'source': {
455 'id': 146,
456 'type': EventSourceType.URL_REQUEST
458 'time': '953535023',
459 'type': EventType.HTTP_CACHE_WRITE_INFO
462 'phase': EventPhase.PHASE_BEGIN,
463 'source': {
464 'id': 146,
465 'type': EventSourceType.URL_REQUEST
467 'time': '953535024',
468 'type': EventType.HTTP_CACHE_WRITE_DATA
471 'phase': EventPhase.PHASE_END,
472 'source': {
473 'id': 146,
474 'type': EventSourceType.URL_REQUEST
476 'time': '953535062',
477 'type': EventType.HTTP_CACHE_WRITE_DATA
480 'phase': EventPhase.PHASE_BEGIN,
481 'source': {
482 'id': 146,
483 'type': EventSourceType.URL_REQUEST
485 'time': '953535062',
486 'type': EventType.HTTP_CACHE_WRITE_INFO
489 'phase': EventPhase.PHASE_END,
490 'source': {
491 'id': 146,
492 'type': EventSourceType.URL_REQUEST
494 'time': '953535075',
495 'type': EventType.HTTP_CACHE_WRITE_INFO
498 'phase': EventPhase.PHASE_END,
499 'source': {
500 'id': 146,
501 'type': EventSourceType.URL_REQUEST
503 'time': '953535081',
504 'type': EventType.URL_REQUEST_START_JOB
507 'phase': EventPhase.PHASE_BEGIN,
508 'source': {
509 'id': 146,
510 'type': EventSourceType.URL_REQUEST
512 'time': '953535537',
513 'type': EventType.HTTP_TRANSACTION_READ_BODY
516 'phase': EventPhase.PHASE_END,
517 'source': {
518 'id': 146,
519 'type': EventSourceType.URL_REQUEST
521 'time': '953535538',
522 'type': EventType.HTTP_TRANSACTION_READ_BODY
525 'phase': EventPhase.PHASE_BEGIN,
526 'source': {
527 'id': 146,
528 'type': EventSourceType.URL_REQUEST
530 'time': '953535538',
531 'type': EventType.HTTP_CACHE_WRITE_DATA
534 'phase': EventPhase.PHASE_END,
535 'source': {
536 'id': 146,
537 'type': EventSourceType.URL_REQUEST
539 'time': '953535541',
540 'type': EventType.HTTP_CACHE_WRITE_DATA
543 'phase': EventPhase.PHASE_BEGIN,
544 'source': {
545 'id': 146,
546 'type': EventSourceType.URL_REQUEST
548 'time': '953535542',
549 'type': EventType.HTTP_TRANSACTION_READ_BODY
552 'phase': EventPhase.PHASE_END,
553 'source': {
554 'id': 146,
555 'type': EventSourceType.URL_REQUEST
557 'time': '953535545',
558 'type': EventType.HTTP_TRANSACTION_READ_BODY
561 'phase': EventPhase.PHASE_BEGIN,
562 'source': {
563 'id': 146,
564 'type': EventSourceType.URL_REQUEST
566 'time': '953535546',
567 'type': EventType.HTTP_CACHE_WRITE_DATA
570 'phase': EventPhase.PHASE_END,
571 'source': {
572 'id': 146,
573 'type': EventSourceType.URL_REQUEST
575 'time': '953535548',
576 'type': EventType.HTTP_CACHE_WRITE_DATA
579 'phase': EventPhase.PHASE_BEGIN,
580 'source': {
581 'id': 146,
582 'type': EventSourceType.URL_REQUEST
584 'time': '953535548',
585 'type': EventType.HTTP_TRANSACTION_READ_BODY
588 'phase': EventPhase.PHASE_END,
589 'source': {
590 'id': 146,
591 'type': EventSourceType.URL_REQUEST
593 'time': '953535548',
594 'type': EventType.HTTP_TRANSACTION_READ_BODY
597 'phase': EventPhase.PHASE_BEGIN,
598 'source': {
599 'id': 146,
600 'type': EventSourceType.URL_REQUEST
602 'time': '953535549',
603 'type': EventType.HTTP_CACHE_WRITE_DATA
606 'phase': EventPhase.PHASE_END,
607 'source': {
608 'id': 146,
609 'type': EventSourceType.URL_REQUEST
611 'time': '953535549',
612 'type': EventType.HTTP_CACHE_WRITE_DATA
615 'phase': EventPhase.PHASE_BEGIN,
616 'source': {
617 'id': 146,
618 'type': EventSourceType.URL_REQUEST
620 'time': '953535550',
621 'type': EventType.HTTP_TRANSACTION_READ_BODY
624 'phase': EventPhase.PHASE_END,
625 'source': {
626 'id': 146,
627 'type': EventSourceType.URL_REQUEST
629 'time': '953535550',
630 'type': EventType.HTTP_TRANSACTION_READ_BODY
633 'phase': EventPhase.PHASE_BEGIN,
634 'source': {
635 'id': 146,
636 'type': EventSourceType.URL_REQUEST
638 'time': '953535550',
639 'type': EventType.HTTP_CACHE_WRITE_DATA
642 'phase': EventPhase.PHASE_END,
643 'source': {
644 'id': 146,
645 'type': EventSourceType.URL_REQUEST
647 'time': '953535551',
648 'type': EventType.HTTP_CACHE_WRITE_DATA
651 'phase': EventPhase.PHASE_BEGIN,
652 'source': {
653 'id': 146,
654 'type': EventSourceType.URL_REQUEST
656 'time': '953535552',
657 'type': EventType.HTTP_TRANSACTION_READ_BODY
660 'phase': EventPhase.PHASE_END,
661 'source': {
662 'id': 146,
663 'type': EventSourceType.URL_REQUEST
665 'time': '953535553',
666 'type': EventType.HTTP_TRANSACTION_READ_BODY
669 'phase': EventPhase.PHASE_BEGIN,
670 'source': {
671 'id': 146,
672 'type': EventSourceType.URL_REQUEST
674 'time': '953535553',
675 'type': EventType.HTTP_CACHE_WRITE_DATA
678 'phase': EventPhase.PHASE_END,
679 'source': {
680 'id': 146,
681 'type': EventSourceType.URL_REQUEST
683 'time': '953535556',
684 'type': EventType.HTTP_CACHE_WRITE_DATA
687 'phase': EventPhase.PHASE_BEGIN,
688 'source': {
689 'id': 146,
690 'type': EventSourceType.URL_REQUEST
692 'time': '953535556',
693 'type': EventType.HTTP_TRANSACTION_READ_BODY
696 'phase': EventPhase.PHASE_END,
697 'source': {
698 'id': 146,
699 'type': EventSourceType.URL_REQUEST
701 'time': '953535559',
702 'type': EventType.HTTP_TRANSACTION_READ_BODY
705 'phase': EventPhase.PHASE_BEGIN,
706 'source': {
707 'id': 146,
708 'type': EventSourceType.URL_REQUEST
710 'time': '953535559',
711 'type': EventType.HTTP_CACHE_WRITE_DATA
714 'phase': EventPhase.PHASE_END,
715 'source': {
716 'id': 146,
717 'type': EventSourceType.URL_REQUEST
719 'time': '953535559',
720 'type': EventType.HTTP_CACHE_WRITE_DATA
723 'phase': EventPhase.PHASE_END,
724 'source': {
725 'id': 146,
726 'type': EventSourceType.URL_REQUEST
728 'time': '953535567',
729 'type': EventType.REQUEST_ALIVE
733 testCase.expectedText =
734 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789]\n' +
735 't=1338864633238 [st= 14] URL_REQUEST_START_JOB [dt=8]\n' +
736 ' --> load_flags = 68222976 ' +
737 '(MAIN_FRAME | MAYBE_USER_GESTURE ' +
738 '| VERIFY_EV_CERT)\n' +
739 ' --> method = "GET"\n' +
740 ' --> priority = 4\n' +
741 ' --> url = "http://www.google.com/"\n' +
742 't=1338864633248 [st= 24] +URL_REQUEST_START_JOB [dt=279]\n' +
743 ' --> load_flags = 68222976 ' +
744 '(MAIN_FRAME | MAYBE_USER_GESTURE ' +
745 '| VERIFY_EV_CERT)\n' +
746 ' --> method = "GET"\n' +
747 ' --> priority = 4\n' +
748 ' --> url = "http://www.google.com/"\n' +
749 't=1338864633255 [st= 31] HTTP_CACHE_GET_BACKEND [dt=1]\n' +
750 't=1338864633257 [st= 33] HTTP_CACHE_OPEN_ENTRY [dt=5]\n' +
751 't=1338864633263 [st= 39] HTTP_CACHE_ADD_TO_ENTRY [dt=1]\n' +
752 't=1338864633269 [st= 45] HTTP_CACHE_READ_INFO [dt=4]\n' +
753 't=1338864633276 [st= 52] +HTTP_STREAM_REQUEST [dt=72]\n' +
754 't=1338864633344 [st=120] HTTP_STREAM_REQUEST_BOUND_TO_JOB\n' +
755 ' --> source_dependency = 149 ' +
756 '(HTTP_STREAM_JOB)\n' +
757 't=1338864633348 [st=124] -HTTP_STREAM_REQUEST\n' +
758 't=1338864633352 [st=128] +HTTP_TRANSACTION_SEND_REQUEST [dt=9]\n' +
759 't=1338864633356 [st=132] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
760 ' --> GET / HTTP/1.1\n' +
761 ' Host: www.google.com\n' +
762 ' Connection: keep-alive\n' +
763 ' User-Agent: Mozilla/5.0\n' +
764 ' Accept: text/html\n' +
765 ' Accept-Encoding: gzip,deflate,sdch\n' +
766 ' Accept-Language: en-US,en;q=0.8\n' +
767 ' Accept-Charset: ISO-8859-1\n' +
768 't=1338864633361 [st=137] -HTTP_TRANSACTION_SEND_REQUEST\n' +
769 't=1338864633362 [st=138] +HTTP_TRANSACTION_READ_HEADERS [dt=76]\n' +
770 't=1338864633363 [st=139] HTTP_STREAM_PARSER_READ_HEADERS [dt=70]\n' +
771 't=1338864633435 [st=211] HTTP_TRANSACTION_READ_RESPONSE_HEADERS\n' +
772 ' --> HTTP/1.1 200 OK\n' +
773 ' Date: Tue, 05 Jun 2012 02:50:33 GMT\n' +
774 ' Expires: -1\n' +
775 ' Cache-Control: private, max-age=0\n' +
776 ' Content-Type: text/html; charset=UTF-8\n' +
777 ' Content-Encoding: gzip\n' +
778 ' Server: gws\n' +
779 ' Content-Length: 23798\n' +
780 't=1338864633438 [st=214] -HTTP_TRANSACTION_READ_HEADERS\n' +
781 't=1338864633439 [st=215] HTTP_CACHE_WRITE_INFO [dt=30]\n' +
782 't=1338864633470 [st=246] HTTP_CACHE_WRITE_DATA [dt=38]\n' +
783 't=1338864633508 [st=284] HTTP_CACHE_WRITE_INFO [dt=13]\n' +
784 't=1338864633527 [st=303] -URL_REQUEST_START_JOB\n' +
785 't=1338864633983 [st=759] HTTP_TRANSACTION_READ_BODY [dt=1]\n' +
786 't=1338864633984 [st=760] HTTP_CACHE_WRITE_DATA [dt=3]\n' +
787 't=1338864633988 [st=764] HTTP_TRANSACTION_READ_BODY [dt=3]\n' +
788 't=1338864633992 [st=768] HTTP_CACHE_WRITE_DATA [dt=2]\n' +
789 't=1338864633994 [st=770] HTTP_TRANSACTION_READ_BODY [dt=0]\n' +
790 't=1338864633995 [st=771] HTTP_CACHE_WRITE_DATA [dt=0]\n' +
791 't=1338864633996 [st=772] HTTP_TRANSACTION_READ_BODY [dt=0]\n' +
792 't=1338864633996 [st=772] HTTP_CACHE_WRITE_DATA [dt=1]\n' +
793 't=1338864633998 [st=774] HTTP_TRANSACTION_READ_BODY [dt=1]\n' +
794 't=1338864633999 [st=775] HTTP_CACHE_WRITE_DATA [dt=3]\n' +
795 't=1338864634002 [st=778] HTTP_TRANSACTION_READ_BODY [dt=3]\n' +
796 't=1338864634005 [st=781] HTTP_CACHE_WRITE_DATA [dt=0]\n' +
797 't=1338864634013 [st=789] -REQUEST_ALIVE';
799 return testCase;
803 * Test case for a URLRequest that was not completed that did not come from a
804 * loaded log file.
806 function painterTestURLRequestIncomplete() {
807 var testCase = {};
808 testCase.tickOffset = '1337911098446';
810 testCase.logEntries = [
812 'phase': EventPhase.PHASE_BEGIN,
813 'source': {
814 'id': 146,
815 'type': EventSourceType.URL_REQUEST
817 'time': '953534778',
818 'type': EventType.REQUEST_ALIVE
821 'params': {
822 'load_flags': 0,
823 'method': 'GET',
824 'priority': 4,
825 'url': 'http://www.google.com/'
827 'phase': EventPhase.PHASE_BEGIN,
828 'source': {
829 'id': 146,
830 'type': EventSourceType.URL_REQUEST
832 'time': '953534910',
833 'type': EventType.URL_REQUEST_START_JOB
836 'phase': EventPhase.PHASE_END,
837 'source': {
838 'id': 146,
839 'type': EventSourceType.URL_REQUEST
841 'time': '953534970',
842 'type': EventType.URL_REQUEST_START_JOB
846 testCase.expectedText =
847 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=?]\n' +
848 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' +
849 ' --> load_flags = 0 (NORMAL)\n' +
850 ' --> method = "GET"\n' +
851 ' --> priority = 4\n' +
852 ' --> url = "http://www.google.com/"';
854 return testCase;
858 * Test case for a URLRequest that was not completed that came from a loaded
859 * log file.
861 function painterTestURLRequestIncompleteFromLoadedLog() {
862 var testCase = painterTestURLRequestIncomplete();
863 testCase.logCreationTime = 1338864634013;
864 testCase.expectedText =
865 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789+]\n' +
866 't=1338864633356 [st=132] URL_REQUEST_START_JOB [dt=60]\n' +
867 ' --> load_flags = 0 (NORMAL)\n' +
868 ' --> method = "GET"\n' +
869 ' --> priority = 4\n' +
870 ' --> url = "http://www.google.com/"\n' +
871 't=1338864634013 [st=789]';
872 return testCase;
876 * Test case for a URLRequest that was not completed that came from a loaded
877 * log file when there's only a begin event.
879 function painterTestURLRequestIncompleteFromLoadedLogSingleEvent() {
880 var testCase = painterTestURLRequestIncomplete();
881 testCase.logEntries = [testCase.logEntries[0]];
882 testCase.logCreationTime = 1338864634013;
883 testCase.expectedText =
884 't=1338864633224 [st= 0] +REQUEST_ALIVE [dt=789+]\n' +
885 't=1338864634013 [st=789]';
886 return testCase;
890 * Tests the custom formatting of net_errors across several different event
891 * types.
893 function painterTestNetError() {
894 var testCase = {};
895 testCase.tickOffset = '1337911098446';
897 testCase.logEntries = [
899 'phase': EventPhase.PHASE_BEGIN,
900 'source': {
901 'id': 318,
902 'type': EventSourceType.URL_REQUEST
904 'time': '953675448',
905 'type': EventType.REQUEST_ALIVE
908 'params': {
909 'load_flags': 68222976,
910 'method': 'GET',
911 'priority': 4,
912 'url': 'http://www.doesnotexistdomain.com/'
914 'phase': EventPhase.PHASE_BEGIN,
915 'source': {
916 'id': 318,
917 'type': EventSourceType.URL_REQUEST
919 'time': '953675455',
920 'type': EventType.URL_REQUEST_START_JOB
923 'phase': EventPhase.PHASE_END,
924 'source': {
925 'id': 318,
926 'type': EventSourceType.URL_REQUEST
928 'time': '953675460',
929 'type': EventType.URL_REQUEST_START_JOB
932 'params': {
933 'load_flags': 68222976,
934 'method': 'GET',
935 'priority': 4,
936 'url': 'http://www.doesnotexistdomain.com/'
938 'phase': EventPhase.PHASE_BEGIN,
939 'source': {
940 'id': 318,
941 'type': EventSourceType.URL_REQUEST
943 'time': '953675460',
944 'type': EventType.URL_REQUEST_START_JOB
947 'phase': EventPhase.PHASE_BEGIN,
948 'source': {
949 'id': 318,
950 'type': EventSourceType.URL_REQUEST
952 'time': '953675469',
953 'type': EventType.HTTP_CACHE_GET_BACKEND
956 'phase': EventPhase.PHASE_END,
957 'source': {
958 'id': 318,
959 'type': EventSourceType.URL_REQUEST
961 'time': '953675469',
962 'type': EventType.HTTP_CACHE_GET_BACKEND
965 'phase': EventPhase.PHASE_BEGIN,
966 'source': {
967 'id': 318,
968 'type': EventSourceType.URL_REQUEST
970 'time': '953675469',
971 'type': EventType.HTTP_CACHE_OPEN_ENTRY
974 'params': {
975 'net_error': -2
977 'phase': EventPhase.PHASE_END,
978 'source': {
979 'id': 318,
980 'type': EventSourceType.URL_REQUEST
982 'time': '953675470',
983 'type': EventType.HTTP_CACHE_OPEN_ENTRY
986 'phase': EventPhase.PHASE_BEGIN,
987 'source': {
988 'id': 318,
989 'type': EventSourceType.URL_REQUEST
991 'time': '953675471',
992 'type': EventType.HTTP_CACHE_CREATE_ENTRY
995 'phase': EventPhase.PHASE_END,
996 'source': {
997 'id': 318,
998 'type': EventSourceType.URL_REQUEST
1000 'time': '953675473',
1001 'type': EventType.HTTP_CACHE_CREATE_ENTRY
1004 'phase': EventPhase.PHASE_BEGIN,
1005 'source': {
1006 'id': 318,
1007 'type': EventSourceType.URL_REQUEST
1009 'time': '953675473',
1010 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
1013 'phase': EventPhase.PHASE_END,
1014 'source': {
1015 'id': 318,
1016 'type': EventSourceType.URL_REQUEST
1018 'time': '953675474',
1019 'type': EventType.HTTP_CACHE_ADD_TO_ENTRY
1022 'phase': EventPhase.PHASE_BEGIN,
1023 'source': {
1024 'id': 318,
1025 'type': EventSourceType.URL_REQUEST
1027 'time': '953675474',
1028 'type': EventType.HTTP_STREAM_REQUEST
1031 'phase': EventPhase.PHASE_END,
1032 'source': {
1033 'id': 318,
1034 'type': EventSourceType.URL_REQUEST
1036 'time': '953675699',
1037 'type': EventType.HTTP_STREAM_REQUEST
1040 'params': {
1041 'net_error': -105
1043 'phase': EventPhase.PHASE_END,
1044 'source': {
1045 'id': 318,
1046 'type': EventSourceType.URL_REQUEST
1048 'time': '953675705',
1049 'type': EventType.URL_REQUEST_START_JOB
1052 'params': {
1053 'net_error': -105
1055 'phase': EventPhase.PHASE_END,
1056 'source': {
1057 'id': 318,
1058 'type': EventSourceType.URL_REQUEST
1060 'time': '953675923',
1061 'type': EventType.REQUEST_ALIVE
1065 testCase.expectedText =
1066 't=1338864773894 [st= 0] +REQUEST_ALIVE [dt=475]\n' +
1067 't=1338864773901 [st= 7] URL_REQUEST_START_JOB [dt=5]\n' +
1068 ' --> load_flags = 68222976 (' +
1069 'MAIN_FRAME | MAYBE_USER_GESTURE ' +
1070 '| VERIFY_EV_CERT)\n' +
1071 ' --> method = "GET"\n' +
1072 ' --> priority = 4\n' +
1073 ' --> url = "http://www.doesnotexistdomain.com/"\n' +
1074 't=1338864773906 [st= 12] +URL_REQUEST_START_JOB [dt=245]\n' +
1075 ' --> load_flags = 68222976 (' +
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=1338864773915 [st= 21] HTTP_CACHE_GET_BACKEND [dt=0]\n' +
1082 't=1338864773915 [st= 21] HTTP_CACHE_OPEN_ENTRY [dt=1]\n' +
1083 ' --> net_error = -2 (ERR_FAILED)\n' +
1084 't=1338864773917 [st= 23] HTTP_CACHE_CREATE_ENTRY [dt=2]\n' +
1085 't=1338864773919 [st= 25] HTTP_CACHE_ADD_TO_ENTRY [dt=1]\n' +
1086 't=1338864773920 [st= 26] HTTP_STREAM_REQUEST [dt=225]\n' +
1087 't=1338864774151 [st=257] -URL_REQUEST_START_JOB\n' +
1088 ' --> net_error = -105 (ERR_NAME_NOT_RESOLVED)\n' +
1089 't=1338864774369 [st=475] -REQUEST_ALIVE\n' +
1090 ' --> net_error = -105 (ERR_NAME_NOT_RESOLVED)';
1092 return testCase;
1096 * Tests the custom formatting of QUIC errors across several different event
1097 * types.
1099 function painterTestQuicError() {
1100 var testCase = {};
1101 testCase.tickOffset = '1337911098446';
1103 testCase.logEntries = [
1105 'params': {
1106 "host": "www.example.com"
1108 'phase': EventPhase.PHASE_BEGIN,
1109 'source': {
1110 'id': 318,
1111 'type': EventSourceType.URL_REQUEST
1113 'time': '953675448',
1114 'type': EventType.QUIC_SESSION
1117 'params': {
1118 'details': "invalid headers",
1119 'quic_rst_stream_error':
1120 QuicRstStreamError.QUIC_BAD_APPLICATION_PAYLOAD,
1121 'stream_id': 1
1123 'phase': EventPhase.PHASE_NONE,
1124 'source': {
1125 'id': 318,
1126 'type': EventSourceType.URL_REQUEST
1128 'time': '953675460',
1129 'type': EventType.QUIC_SESSION_RST_STREAM_FRAME_RECEIVED
1132 'params': {
1133 'quic_error': QuicError.QUIC_CONNECTION_TIMED_OUT,
1135 'phase': EventPhase.PHASE_NONE,
1136 'source': {
1137 'id': 318,
1138 'type': EventSourceType.URL_REQUEST
1140 'time': '953675705',
1141 'type': EventType.QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED
1144 'params': {
1145 'quic_error': QuicError.QUIC_CONNECTION_TIMED_OUT
1147 'phase': EventPhase.PHASE_END,
1148 'source': {
1149 'id': 318,
1150 'type': EventSourceType.URL_REQUEST
1152 'time': '953675923',
1153 'type': EventType.QUIC_SESSION
1157 testCase.expectedText =
1158 't=1338864773894 [st= 0] +QUIC_SESSION [dt=475]\n' +
1159 ' --> host = "www.example.com"\n' +
1160 't=1338864773906 [st= 12] QUIC_SESSION_RST_STREAM_FRAME_RECEIVED\n' +
1161 ' --> details = "invalid headers"\n' +
1162 ' --> quic_rst_stream_error = ' +
1163 QuicRstStreamError.QUIC_BAD_APPLICATION_PAYLOAD + ' (' +
1164 'QUIC_BAD_APPLICATION_PAYLOAD)\n' +
1165 ' --> stream_id = 1\n' +
1166 't=1338864774151 [st=257] QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED\n' +
1167 ' --> quic_error = ' +
1168 QuicError.QUIC_CONNECTION_TIMED_OUT + ' (QUIC_CONNECTION_TIMED_OUT)\n' +
1169 't=1338864774369 [st=475] -QUIC_SESSION\n' +
1170 ' --> quic_error = ' +
1171 QuicError.QUIC_CONNECTION_TIMED_OUT + ' (QUIC_CONNECTION_TIMED_OUT)';
1173 return testCase;
1177 * Tests the custom formatting of QUIC crypto handshake messages.
1179 function painterTestQuicCryptoHandshakeMessage() {
1180 var testCase = {};
1181 testCase.tickOffset = '1337911098446';
1183 testCase.logEntries = [
1185 'params': {
1186 "host": "www.example.com"
1188 'phase': EventPhase.PHASE_BEGIN,
1189 'source': {
1190 'id': 318,
1191 'type': EventSourceType.URL_REQUEST
1193 'time': '953675448',
1194 'type': EventType.QUIC_SESSION
1197 'params': {
1198 'quic_crypto_handshake_message':
1199 "REJ <\n" +
1200 " STK : 4FDE\n" +
1201 " SNO : A228\n" +
1202 " PROF: 3045\n" +
1203 " SCFG:\n" +
1204 " SCFG<\n" +
1205 " AEAD: AESG\n" +
1206 " SCID: FED7\n" +
1207 " PDMD: CHID\n" +
1208 " PUBS: 2000\n" +
1209 " VERS: 0000\n" +
1210 " KEXS: C255,P256\n" +
1211 " OBIT: 7883764781F2DFD0\n" +
1212 " EXPY: FFEE725200000000\n" +
1213 " >\n" +
1214 " >"
1216 'phase': EventPhase.PHASE_NONE,
1217 'source': {
1218 'id': 318,
1219 'type': EventSourceType.URL_REQUEST
1221 'time': '953675460',
1222 'type': EventType.QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT
1225 'phase': EventPhase.PHASE_END,
1226 'source': {
1227 'id': 318,
1228 'type': EventSourceType.URL_REQUEST
1230 'time': '953675923',
1231 'type': EventType.QUIC_SESSION
1235 testCase.expectedText =
1236 't=1338864773894 [st= 0] +QUIC_SESSION [dt=475]\n' +
1237 ' --> host = "www.example.com"\n' +
1238 't=1338864773906 [st= 12] QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT\n' +
1239 ' --> REJ <\n' +
1240 ' STK : 4FDE\n' +
1241 ' SNO : A228\n' +
1242 ' PROF: 3045\n' +
1243 ' SCFG:\n' +
1244 ' SCFG<\n' +
1245 ' AEAD: AESG\n' +
1246 ' SCID: FED7\n' +
1247 ' PDMD: CHID\n' +
1248 ' PUBS: 2000\n' +
1249 ' VERS: 0000\n' +
1250 ' KEXS: C255,P256\n' +
1251 ' OBIT: 7883764781F2DFD0\n' +
1252 ' EXPY: FFEE725200000000\n' +
1253 ' >\n' +
1254 ' >\n' +
1255 't=1338864774369 [st=475] -QUIC_SESSION';
1257 return testCase;
1261 * Tests the formatting of bytes sent/received as hex + ASCII. Note that the
1262 * test data was truncated which is why the byte_count doesn't quite match the
1263 * hex_encoded_bytes.
1265 function painterTestHexEncodedBytes() {
1266 var testCase = {};
1267 testCase.tickOffset = '1337911098473';
1269 testCase.logEntries = [
1271 'params': {
1272 'source_dependency': {
1273 'id': 634,
1274 'type': EventSourceType.CONNECT_JOB
1277 'phase': EventPhase.PHASE_BEGIN,
1278 'source': {
1279 'id': 637,
1280 'type': EventSourceType.SOCKET
1282 'time': '953918459',
1283 'type': EventType.SOCKET_ALIVE
1286 'params': {
1287 'address_list': [
1288 '184.30.253.15:80'
1291 'phase': EventPhase.PHASE_BEGIN,
1292 'source': {
1293 'id': 637,
1294 'type': EventSourceType.SOCKET
1296 'time': '953918460',
1297 'type': EventType.TCP_CONNECT
1300 'params': {
1301 'address': '184.30.253.15:80'
1303 'phase': EventPhase.PHASE_BEGIN,
1304 'source': {
1305 'id': 637,
1306 'type': EventSourceType.SOCKET
1308 'time': '953918461',
1309 'type': EventType.TCP_CONNECT_ATTEMPT
1312 'phase': EventPhase.PHASE_END,
1313 'source': {
1314 'id': 637,
1315 'type': EventSourceType.SOCKET
1317 'time': '953918464',
1318 'type': EventType.TCP_CONNECT_ATTEMPT
1321 'params': {
1322 'source_address': '127.0.0.1:54041'
1324 'phase': EventPhase.PHASE_END,
1325 'source': {
1326 'id': 637,
1327 'type': EventSourceType.SOCKET
1329 'time': '953918465',
1330 'type': EventType.TCP_CONNECT
1333 'params': {
1334 'source_dependency': {
1335 'id': 628,
1336 'type': EventSourceType.HTTP_STREAM_JOB
1339 'phase': EventPhase.PHASE_BEGIN,
1340 'source': {
1341 'id': 637,
1342 'type': EventSourceType.SOCKET
1344 'time': '953918472',
1345 'type': EventType.SOCKET_IN_USE
1348 'params': {
1349 'byte_count': 780,
1350 'hex_encoded_bytes': '474554202F66617669636F6E2E69636F20485454502' +
1351 'F312E310D0A486F73743A207777772E6170706C652E' +
1352 '636F6D0D0A436F6E6E656374696F6E3A20'
1354 'phase': EventPhase.PHASE_NONE,
1355 'source': {
1356 'id': 637,
1357 'type': EventSourceType.SOCKET
1359 'time': '953918484',
1360 'type': EventType.SOCKET_BYTES_SENT
1363 'params': {
1364 'byte_count': 1024,
1365 'hex_encoded_bytes': '485454502F312E3120323030204F4B0D0A4C6173742' +
1366 'D4D6F6469666965643A204D6F6E2C20313920446563' +
1367 '20323031312032323A34363A353920474D'
1369 'phase': EventPhase.PHASE_NONE,
1370 'source': {
1371 'id': 637,
1372 'type': EventSourceType.SOCKET
1374 'time': '953918596',
1375 'type': EventType.SOCKET_BYTES_RECEIVED
1379 testCase.expectedText =
1380 't=1338865016932 [st= 0] +SOCKET_ALIVE [dt=?]\n' +
1381 ' --> source_dependency = 634 (CONNECT_JOB)\n' +
1382 't=1338865016933 [st= 1] +TCP_CONNECT [dt=5]\n' +
1383 ' --> address_list = ["184.30.253.15:80"]\n' +
1384 't=1338865016934 [st= 2] TCP_CONNECT_ATTEMPT [dt=3]\n' +
1385 ' --> address = "184.30.253.15:80"\n' +
1386 't=1338865016938 [st= 6] -TCP_CONNECT\n' +
1387 ' --> source_address = "127.0.0.1:54041"\n' +
1388 't=1338865016945 [st= 13] +SOCKET_IN_USE [dt=?]\n' +
1389 ' --> source_dependency = 628 (HTTP_STREAM_JOB)\n' +
1390 't=1338865016957 [st= 25] SOCKET_BYTES_SENT\n' +
1391 ' --> byte_count = 780\n' +
1392 ' --> hex_encoded_bytes =\n' +
1393 ' 47 45 54 20 2F 66 61 76 69 63 6F 6E 2E 69 ' +
1394 '63 6F 20 48 54 54 GET /favicon.ico HTT\n' +
1395 ' 50 2F 31 2E 31 0D 0A 48 6F 73 74 3A 20 77 ' +
1396 '77 77 2E 61 70 70 P/1.1..Host: www.app\n' +
1397 ' 6C 65 2E 63 6F 6D 0D 0A 43 6F 6E 6E 65 63 ' +
1398 '74 69 6F 6E 3A 20 le.com..Connection: \n' +
1399 't=1338865017069 [st=137] SOCKET_BYTES_RECEIVED\n' +
1400 ' --> byte_count = 1024\n' +
1401 ' --> hex_encoded_bytes =\n' +
1402 ' 48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F ' +
1403 '4B 0D 0A 4C 61 73 HTTP/1.1 200 OK..Las\n' +
1404 ' 74 2D 4D 6F 64 69 66 69 65 64 3A 20 4D 6F ' +
1405 '6E 2C 20 31 39 20 t-Modified: Mon, 19 \n' +
1406 ' 44 65 63 20 32 30 31 31 20 32 32 3A 34 36 ' +
1407 '3A 35 39 20 47 4D Dec 2011 22:46:59 GM';
1409 return testCase;
1413 * Tests the formatting of certificates.
1415 function painterTestCertVerifierJob() {
1416 var testCase = {};
1417 testCase.tickOffset = '1337911098481';
1419 testCase.logEntries = [
1421 'params': {
1422 'certificates': [
1423 '-----BEGIN CERTIFICATE-----\n1\n-----END CERTIFICATE-----\n',
1424 '-----BEGIN CERTIFICATE-----\n2\n-----END CERTIFICATE-----\n',
1427 'phase': EventPhase.PHASE_BEGIN,
1428 'source': {
1429 'id': 752,
1430 'type': EventSourceType.CERT_VERIFIER_JOB
1432 'time': '954124663',
1433 'type': EventType.CERT_VERIFIER_JOB
1436 'phase': EventPhase.PHASE_END,
1437 'source': {
1438 'id': 752,
1439 'type': EventSourceType.CERT_VERIFIER_JOB
1441 'time': '954124697',
1442 'type': EventType.CERT_VERIFIER_JOB
1446 testCase.expectedText =
1447 't=1338865223144 [st=0] CERT_VERIFIER_JOB [dt=34]\n' +
1448 ' --> certificates =\n' +
1449 ' -----BEGIN CERTIFICATE-----\n' +
1450 ' 1\n' +
1451 ' -----END CERTIFICATE-----\n' +
1452 ' \n' +
1453 ' -----BEGIN CERTIFICATE-----\n' +
1454 ' 2\n' +
1455 ' -----END CERTIFICATE-----';
1456 return testCase;
1461 * Tests the formatting of CertVerifyResult fields.
1463 function painterTestCertVerifyResult() {
1464 var testCase = {};
1465 testCase.tickOffset = '1337911098481';
1467 testCase.logEntries = [
1469 'params': {
1470 'certificates': [
1471 '-----BEGIN CERTIFICATE-----\n1\n-----END CERTIFICATE-----\n',
1472 '-----BEGIN CERTIFICATE-----\n2\n-----END CERTIFICATE-----\n',
1475 'phase': EventPhase.PHASE_BEGIN,
1476 'source': {
1477 'id': 752,
1478 'type': EventSourceType.CERT_VERIFIER_JOB
1480 'time': '954124663',
1481 'type': EventType.CERT_VERIFIER_JOB
1484 'params': {
1485 'has_md5': true,
1486 'has_md2': false,
1487 'has_md4': true,
1488 'is_issued_by_known_root': true,
1489 'is_issued_by_additional_trust_anchor': false,
1490 'common_name_fallback_used': true,
1491 'cert_status': 5,
1492 'verified_cert': {
1493 'certificates': [
1494 '-----BEGIN CERTIFICATE-----\n1\n-----END CERTIFICATE-----\n',
1495 '-----BEGIN CERTIFICATE-----\n2\n-----END CERTIFICATE-----\n',
1498 'public_key_hashes': [
1499 'hash1',
1500 'hash2',
1503 'phase': EventPhase.PHASE_END,
1504 'source': {
1505 'id': 752,
1506 'type': EventSourceType.CERT_VERIFIER_JOB
1508 'time': '954124697',
1509 'type': EventType.CERT_VERIFIER_JOB
1513 testCase.expectedText =
1514 't=1338865223144 [st= 0] +CERT_VERIFIER_JOB [dt=34]\n' +
1515 ' --> certificates =\n' +
1516 ' -----BEGIN CERTIFICATE-----\n' +
1517 ' 1\n' +
1518 ' -----END CERTIFICATE-----\n' +
1519 ' \n' +
1520 ' -----BEGIN CERTIFICATE-----\n' +
1521 ' 2\n' +
1522 ' -----END CERTIFICATE-----\n' +
1523 ' \n' +
1524 't=1338865223178 [st=34] -CERT_VERIFIER_JOB\n' +
1525 ' --> verified_cert =\n' +
1526 ' -----BEGIN CERTIFICATE-----\n' +
1527 ' 1\n' +
1528 ' -----END CERTIFICATE-----\n' +
1529 ' \n' +
1530 ' -----BEGIN CERTIFICATE-----\n' +
1531 ' 2\n' +
1532 ' -----END CERTIFICATE-----\n' +
1533 ' \n' +
1534 ' --> cert_status = 5 (AUTHORITY_INVALID |' +
1535 ' COMMON_NAME_INVALID)\n' +
1536 ' --> has_md5 = true\n' +
1537 ' --> has_md2 = false\n' +
1538 ' --> has_md4 = true\n' +
1539 ' --> is_issued_by_known_root = true\n' +
1540 ' --> is_issued_by_additional_trust_anchor =' +
1541 ' false\n --> common_name_fallback_used = true\n' +
1542 ' --> public_key_hashes = ["hash1","hash2"]';
1544 return testCase;
1548 * Tests the formatting of proxy configurations when using one proxy server for
1549 * all URL schemes.
1551 function painterTestProxyConfigOneProxyAllSchemes() {
1552 var testCase = {};
1553 testCase.tickOffset = '1337911098481';
1555 testCase.logEntries = [
1557 'params': {
1558 'new_config': {
1559 'auto_detect': true,
1560 'bypass_list': [
1561 '*.local',
1562 'foo',
1563 '<local>'
1565 'pac_url': 'https://config/wpad.dat',
1566 'single_proxy': 'cache-proxy:3128',
1567 'source': 'SYSTEM'
1569 'old_config': {
1570 'auto_detect': true
1573 'phase': EventPhase.PHASE_NONE,
1574 'source': {
1575 'id': 814,
1576 'type': EventSourceType.NONE
1578 'time': '954443578',
1579 'type': EventType.PROXY_CONFIG_CHANGED
1583 testCase.expectedText =
1584 't=1338865542059 [st=0] PROXY_CONFIG_CHANGED\n' +
1585 ' --> old_config =\n' +
1586 ' Auto-detect\n' +
1587 ' --> new_config =\n' +
1588 ' (1) Auto-detect\n' +
1589 ' (2) PAC script: https://config/wpad.dat\n' +
1590 ' (3) Proxy server: cache-proxy:3128\n' +
1591 ' Bypass list: \n' +
1592 ' *.local\n' +
1593 ' foo\n' +
1594 ' <local>\n' +
1595 ' Source: SYSTEM';
1597 return testCase;
1601 * Tests the formatting of proxy configurations when using two proxy servers for
1602 * all URL schemes.
1604 function painterTestProxyConfigTwoProxiesAllSchemes() {
1605 var testCase = {};
1606 testCase.tickOffset = '1337911098481';
1608 testCase.logEntries = [
1610 'params': {
1611 'new_config': {
1612 'auto_detect': true,
1613 'bypass_list': [
1614 '*.local',
1615 'foo',
1616 '<local>'
1618 'pac_url': 'https://config/wpad.dat',
1619 'single_proxy': ['cache-proxy:3128', 'socks4://other:999'],
1620 'source': 'SYSTEM'
1622 'old_config': {
1623 'auto_detect': true
1626 'phase': EventPhase.PHASE_NONE,
1627 'source': {
1628 'id': 814,
1629 'type': EventSourceType.NONE
1631 'time': '954443578',
1632 'type': EventType.PROXY_CONFIG_CHANGED
1636 testCase.expectedText =
1637 't=1338865542059 [st=0] PROXY_CONFIG_CHANGED\n' +
1638 ' --> old_config =\n' +
1639 ' Auto-detect\n' +
1640 ' --> new_config =\n' +
1641 ' (1) Auto-detect\n' +
1642 ' (2) PAC script: https://config/wpad.dat\n' +
1643 ' (3) Proxy server: [cache-proxy:3128, ' +
1644 'socks4://other:999]\n' +
1645 ' Bypass list: \n' +
1646 ' *.local\n' +
1647 ' foo\n' +
1648 ' <local>\n' +
1649 ' Source: SYSTEM';
1651 return testCase;
1655 * Tests that cookies are NOT stripped from URLRequests when stripping is
1656 * disabled.
1658 function painterTestDontStripCookiesURLRequest() {
1659 var testCase = {};
1660 testCase.tickOffset = '1337911098139';
1662 testCase.logEntries = [
1664 'params': {
1665 'headers': [
1666 'HTTP/1.1 301 Moved Permanently',
1667 'Cache-Control: private',
1668 'Content-Length: 23',
1669 'Content-Type: text/html',
1670 'Location: http://msdn.microsoft.com',
1671 'Server: Microsoft-IIS/7.5',
1672 'Set-Cookie: MyMagicPony',
1673 'P3P: CP=\"ALL\"',
1674 'X-Powered-By: ASP.NET',
1675 'X-UA-Compatible: IE=EmulateIE7',
1676 'Date: Tue, 05 Jun 2012 21:06:45 GMT',
1677 'Connection: close'
1680 'phase': EventPhase.PHASE_NONE,
1681 'source': {
1682 'id': 829,
1683 'type': EventSourceType.URL_REQUEST
1685 'time': '1019307339',
1686 'type': EventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS
1689 'params': {
1690 'headers': [
1691 'Host: msdn.microsoft.com',
1692 'Connection: keep-alive',
1693 'User-Agent: Mozilla/5.0',
1694 'Accept: text/html',
1695 'Accept-Encoding: gzip,deflate,sdch',
1696 'Accept-Language: en-US,en;q=0.8',
1697 'Accept-Charset: ISO-8859-1',
1698 'Cookie: MyMagicPony'
1700 'line': 'GET / HTTP/1.1\r\n'
1702 'phase': EventPhase.PHASE_NONE,
1703 'source': {
1704 'id': 829,
1705 'type': EventSourceType.URL_REQUEST
1707 'time': '1019307458',
1708 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
1712 testCase.expectedText =
1713 't=1338930405478 [st= 0] HTTP_TRANSACTION_READ_RESPONSE_HEADERS\n' +
1714 ' --> HTTP/1.1 301 Moved Permanently\n' +
1715 ' Cache-Control: private\n' +
1716 ' Content-Length: 23\n' +
1717 ' Content-Type: text/html\n' +
1718 ' Location: http://msdn.microsoft.com\n' +
1719 ' Server: Microsoft-IIS/7.5\n' +
1720 ' Set-Cookie: MyMagicPony\n' +
1721 ' P3P: CP="ALL"\n' +
1722 ' X-Powered-By: ASP.NET\n' +
1723 ' X-UA-Compatible: IE=EmulateIE7\n' +
1724 ' Date: Tue, 05 Jun 2012 21:06:45 GMT\n' +
1725 ' Connection: close\n' +
1726 't=1338930405597 [st=119] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
1727 ' --> GET / HTTP/1.1\n' +
1728 ' Host: msdn.microsoft.com\n' +
1729 ' Connection: keep-alive\n' +
1730 ' User-Agent: Mozilla/5.0\n' +
1731 ' Accept: text/html\n' +
1732 ' Accept-Encoding: gzip,deflate,sdch\n' +
1733 ' Accept-Language: en-US,en;q=0.8\n' +
1734 ' Accept-Charset: ISO-8859-1\n' +
1735 ' Cookie: MyMagicPony';
1737 return testCase;
1741 * Tests that cookies are stripped from URLRequest when stripping is enabled.
1743 function painterTestStripCookiesURLRequest() {
1744 var testCase = painterTestDontStripCookiesURLRequest();
1745 testCase.privacyStripping = true;
1746 testCase.expectedText =
1747 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]');
1748 return testCase;
1752 * Tests that cookies are NOT stripped from SPDY sessions when stripping is not
1753 * enabled. This test data was pieced together in order to get a "cookie" and
1754 * "set-cookie" header.
1756 function painterTestDontStripCookiesSPDYSession() {
1757 var testCase = {};
1758 testCase.tickOffset = '1337911097783';
1760 testCase.logEntries = [
1762 'params': {
1763 'flags': 1,
1764 'headers': [
1765 ':host: mail.google.com',
1766 ':method: GET',
1767 ':path: /a/google.com',
1768 ':scheme: https',
1769 ':version: HTTP/1.1',
1770 'accept: text/html',
1771 'accept-charset: ISO-8859-1',
1772 'accept-encoding: gzip,deflate,sdch',
1773 'accept-language: en-US,en;q=0.8',
1774 'cookie: MyMagicPony',
1775 'user-agent: Mozilla/5.0'
1777 'stream_id': 1
1779 'phase': EventPhase.PHASE_NONE,
1780 'source': {
1781 'id': 153,
1782 'type': EventSourceType.SPDY_SESSION
1784 'time': '1012984638',
1785 'type': EventType.SPDY_SESSION_SYN_STREAM
1788 'params': {
1789 'flags': 0,
1790 'headers': [
1791 ':status: 204 No Content',
1792 ':version: HTTP/1.1',
1793 'date: Tue, 05 Jun 2012 19:21:30 GMT',
1794 'server: GSE',
1795 'set-cookie: MyMagicPony',
1796 'x-random-header: sup'
1798 'stream_id': 5
1800 'phase': EventPhase.PHASE_NONE,
1801 'source': {
1802 'id': 153,
1803 'type': EventSourceType.SPDY_SESSION
1805 'time': '1012992266',
1806 'type': EventType.SPDY_SESSION_SYN_REPLY
1810 testCase.expectedText =
1811 't=1338924082421 [st= 0] SPDY_SESSION_SYN_STREAM\n' +
1812 ' --> flags = 1\n' +
1813 ' --> :host: mail.google.com\n' +
1814 ' :method: GET\n' +
1815 ' :path: /a/google.com\n' +
1816 ' :scheme: https\n' +
1817 ' :version: HTTP/1.1\n' +
1818 ' accept: text/html\n' +
1819 ' accept-charset: ISO-8859-1\n' +
1820 ' accept-encoding: gzip,deflate,sdch\n' +
1821 ' accept-language: en-US,en;q=0.8\n' +
1822 ' cookie: MyMagicPony\n' +
1823 ' user-agent: Mozilla/5.0\n' +
1824 ' --> stream_id = 1\n' +
1825 't=1338924090049 [st=7628] SPDY_SESSION_SYN_REPLY\n' +
1826 ' --> flags = 0\n' +
1827 ' --> :status: 204 No Content\n' +
1828 ' :version: HTTP/1.1\n' +
1829 ' date: Tue, 05 Jun 2012 19:21:30 GMT\n' +
1830 ' server: GSE\n' +
1831 ' set-cookie: MyMagicPony\n' +
1832 ' x-random-header: sup\n' +
1833 ' --> stream_id = 5';
1835 return testCase;
1839 * Tests that cookies are stripped from SPDY sessions when stripping is enabled.
1841 function painterTestStripCookiesSPDYSession() {
1842 var testCase = painterTestDontStripCookiesSPDYSession();
1843 testCase.privacyStripping = true;
1844 testCase.expectedText =
1845 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]');
1846 return testCase;
1850 * Tests that cookies are NOT stripped from SPDY URL request headers when
1851 * stripping is not enabled. The difference from the above requests is that SPDY
1852 * URL request headers use dictionaries rather than lists.
1854 function painterTestSpdyURLRequestDontStripCookies() {
1855 var testCase = {};
1856 testCase.tickOffset = '1337911098481';
1858 testCase.logEntries = [
1860 'params': {
1861 'headers': {
1862 ':host': 'www.google.com',
1863 ':method': 'GET',
1864 ':path': '/',
1865 ':scheme': 'https',
1866 ':version': 'HTTP/1.1',
1867 'cookie': 'MyMagicPony'},
1869 'phase': EventPhase.PHASE_NONE,
1870 'source': {'id': 329, 'type': EventSourceType.URL_REQUEST},
1871 'time': '954124663',
1872 'type': EventType.HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS
1876 testCase.expectedText =
1877 't=1338865223144 [st=0] HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS\n' +
1878 ' --> :host: www.google.com\n' +
1879 ' :method: GET\n' +
1880 ' :path: /\n' +
1881 ' :scheme: https\n' +
1882 ' :version: HTTP/1.1\n' +
1883 ' cookie: MyMagicPony';
1884 return testCase;
1888 * Tests that cookies are NOT stripped from SPDY URL request headers when
1889 * stripping is not enabled. The difference from the above requests is that
1891 function painterTestSpdyURLRequestStripCookies() {
1892 var testCase = painterTestSpdyURLRequestDontStripCookies();
1893 testCase.privacyStripping = true;
1894 testCase.expectedText =
1895 testCase.expectedText.replace(/MyMagicPony/g, '[11 bytes were stripped]');
1896 return testCase;
1900 * Tests that when there are more custom parameters than we expect for an
1901 * event type, they are printed out in addition to the custom formatting.
1903 function painterTestExtraCustomParameter() {
1904 var testCase = {};
1905 testCase.tickOffset = '1337911098446';
1907 testCase.logEntries = [
1909 'params': {
1910 'headers': [
1911 'Host: www.google.com',
1912 'Connection: keep-alive'
1914 'line': 'GET / HTTP/1.1\r\n',
1915 // This is unexpected!
1916 'hello': 'yo dawg, i heard you like strings'
1918 'phase': EventPhase.PHASE_NONE,
1919 'source': {
1920 'id': 146,
1921 'type': EventSourceType.URL_REQUEST
1923 'time': '953534910',
1924 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
1928 testCase.expectedText =
1929 't=1338864633356 [st=0] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
1930 ' --> GET / HTTP/1.1\n' +
1931 ' Host: www.google.com\n' +
1932 ' Connection: keep-alive\n' +
1933 ' --> hello = "yo dawg, i heard you like strings"';
1935 return testCase;
1939 * Tests that when the custom parameters for an event type don't match
1940 * what we expect, we fall back to default formatting.
1942 function painterTestMissingCustomParameter() {
1943 var testCase = {};
1944 testCase.tickOffset = '1337911098446';
1946 testCase.logEntries = [
1948 'params': {
1949 // The expectation is for this to be called "headers".
1950 'headersWRONG': [
1951 'Host: www.google.com',
1952 'Connection: keep-alive'
1954 'line': 'GET / HTTP/1.1\r\n'
1956 'phase': EventPhase.PHASE_NONE,
1957 'source': {
1958 'id': 146,
1959 'type': EventSourceType.URL_REQUEST
1961 'time': '953534910',
1962 'type': EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS
1966 testCase.expectedText =
1967 't=1338864633356 [st=0] HTTP_TRANSACTION_SEND_REQUEST_HEADERS\n' +
1968 ' --> headersWRONG = ["Host: www.google.com",' +
1969 '"Connection: keep-alive"]\n' +
1970 ' --> line = "GET / HTTP/1.1\\r\\n"';
1972 return testCase;
1976 * Tests the formatting for an SSL version fallback event.
1978 function painterTestSSLVersionFallback() {
1979 var testCase = {};
1980 testCase.tickOffset = '1337911098400';
1982 testCase.logEntries = [
1984 'params': {
1985 'host_and_port': 'www-927.ibm.com:443',
1986 'net_error': -107,
1987 'version_after': 0x301,
1988 'version_before': 0x302
1990 'phase': EventPhase.PHASE_NONE,
1991 'source': {
1992 'id': 124,
1993 'type': EventSourceType.URL_REQUEST
1995 'time': '1119062679',
1996 'type': EventType.SSL_VERSION_FALLBACK
1999 'params': {
2000 'host_and_port': 'www-927.ibm.com:443',
2001 'net_error': -107,
2002 'version_after': 0x300,
2003 'version_before': 0x301
2005 'phase': EventPhase.PHASE_NONE,
2006 'source': {
2007 'id': 124,
2008 'type': EventSourceType.URL_REQUEST
2010 'time': '1119062850',
2011 'type': EventType.SSL_VERSION_FALLBACK
2014 'params': {
2015 'version_after': 0x123456,
2016 'version_before': 0x300
2018 'phase': EventPhase.PHASE_NONE,
2019 'source': {
2020 'id': 124,
2021 'type': EventSourceType.URL_REQUEST
2023 'time': '1119062850',
2024 'type': EventType.SSL_VERSION_FALLBACK
2028 testCase.expectedText =
2029 't=1339030161079 [st= 0] SSL_VERSION_FALLBACK\n' +
2030 ' --> TLS 1.1 ==> TLS 1.0\n' +
2031 ' --> host_and_port = "www-927.ibm.com:443"\n' +
2032 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' +
2033 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' +
2034 ' --> TLS 1.0 ==> SSL 3.0\n' +
2035 ' --> host_and_port = "www-927.ibm.com:443"\n' +
2036 ' --> net_error = -107 (ERR_SSL_PROTOCOL_ERROR)\n' +
2037 't=1339030161250 [st=171] SSL_VERSION_FALLBACK\n' +
2038 ' --> SSL 3.0 ==> SSL 0x123456';
2040 return testCase;
2044 * Tests the formatting of a URL request that was just finishing up when
2045 * net-internals was opened.
2047 function painterTestInProgressURLRequest() {
2048 var testCase = {};
2049 testCase.tickOffset = '1337911098446';
2051 testCase.logEntries = [
2053 'params': {
2054 'load_flags': 68222976,
2055 'load_state': LoadState.READING_RESPONSE,
2056 'method': 'GET',
2057 'url': 'http://www.MagicPonyShopper.com'
2059 'phase': EventPhase.PHASE_BEGIN,
2060 'source': {
2061 'id': 318,
2062 'type': EventSourceType.URL_REQUEST
2064 'time': '953675548',
2065 'type': EventType.REQUEST_ALIVE
2068 'phase': EventPhase.PHASE_END,
2069 'source': {
2070 'id': 318,
2071 'type': EventSourceType.URL_REQUEST
2073 'time': '953675699',
2074 'type': EventType.HTTP_STREAM_REQUEST
2077 'phase': EventPhase.PHASE_END,
2078 'source': {
2079 'id': 318,
2080 'type': EventSourceType.URL_REQUEST
2082 'time': '953675705',
2083 'type': EventType.URL_REQUEST_START_JOB
2086 'phase': EventPhase.PHASE_END,
2087 'source': {
2088 'id': 318,
2089 'type': EventSourceType.URL_REQUEST
2091 'time': '953675923',
2092 'type': EventType.REQUEST_ALIVE
2096 testCase.expectedText =
2097 't=1338864773994 [st= 0] +REQUEST_ALIVE [dt=375]\n' +
2098 ' --> load_flags = 68222976 ' +
2099 '(MAIN_FRAME | MAYBE_USER_GESTURE ' +
2100 '| VERIFY_EV_CERT)\n' +
2101 ' --> load_state = ' + LoadState.READING_RESPONSE +
2102 ' (READING_RESPONSE)\n' +
2103 ' --> method = "GET"\n' +
2104 ' --> url = "http://www.MagicPonyShopper.com"\n' +
2105 't=1338864774145 [st=151] -HTTP_STREAM_REQUEST\n' +
2106 't=1338864774151 [st=157] -URL_REQUEST_START_JOB\n' +
2107 't=1338864774369 [st=375] -REQUEST_ALIVE';
2109 return testCase;
2113 * Tests the formatting using a non-zero base time. Also has no final event,
2114 * to make sure logCreationTime is handled correctly.
2116 function painterTestBaseTime() {
2117 var testCase = {};
2118 testCase.tickOffset = '1337911098446';
2119 testCase.logCreationTime = 1338864774783;
2120 testCase.baseTimeTicks = '953675546';
2122 testCase.logEntries = [
2124 'phase': EventPhase.PHASE_BEGIN,
2125 'source': {
2126 'id': 318,
2127 'type': EventSourceType.URL_REQUEST
2129 'time': '953675548',
2130 'type': EventType.REQUEST_ALIVE
2133 'phase': EventPhase.PHASE_BEGIN,
2134 'source': {
2135 'id': 318,
2136 'type': EventSourceType.URL_REQUEST
2138 'time': '953675698',
2139 'type': EventType.HTTP_STREAM_REQUEST
2142 'phase': EventPhase.PHASE_END,
2143 'source': {
2144 'id': 318,
2145 'type': EventSourceType.URL_REQUEST
2147 'time': '953675699',
2148 'type': EventType.HTTP_STREAM_REQUEST
2152 testCase.expectedText =
2153 't= 2 [st= 0] +REQUEST_ALIVE [dt=789+]\n' +
2154 't=152 [st=150] HTTP_STREAM_REQUEST [dt=1]\n' +
2155 't=791 [st=789]';
2157 return testCase;
2160 })(); // Anonymous namespace