1 // Copyright 2013 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']);
11 TEST_F('NetInternalsTest', 'netInternalsWaterfallView', function() {
12 function runTestCase(testCase
) {
13 var eventPairs
= WaterfallRow
.findUrlRequestEvents(testCase
.sourceEntry
);
14 expectEquals(eventPairs
.length
, testCase
.expectedEventPairs
.length
);
15 for (var i
= 0; i
< eventPairs
.length
; ++i
) {
16 expectEquals(eventPairs
[i
].startEntry
.time
,
17 testCase
.expectedEventPairs
[i
].startTime
);
18 expectEquals(eventPairs
[i
].endEntry
.time
,
19 testCase
.expectedEventPairs
[i
].endTime
);
20 expectEquals(eventPairs
[i
].startEntry
.type
,
21 testCase
.expectedEventPairs
[i
].eventType
);
22 expectEquals(eventPairs
[i
].endEntry
.type
,
23 testCase
.expectedEventPairs
[i
].eventType
);
25 SourceTracker
.getInstance().clearEntries_();
28 function expectedEventPairsWithoutTcp() {
29 var expectedEventPairs
= [
31 startTime
: "369047367",
33 eventType
: EventType
.PROXY_SERVICE
36 startTime
: "369047371",
38 eventType
: EventType
.HOST_RESOLVER_IMPL_REQUEST
41 startTime
: "369047398",
43 eventType
: EventType
.SSL_CONNECT
46 startTime
: "369047444",
48 eventType
: EventType
.HTTP_TRANSACTION_READ_HEADERS
51 return expectedEventPairs
;
54 function logEntriesWithoutTcpConnection() {
57 "phase": EventPhase
.PHASE_BEGIN
,
60 "type": EventSourceType
.URL_REQUEST
63 "type": EventType
.REQUEST_ALIVE
71 "https://www.google.com/searchdomaincheck?format=url&type=chrome"
73 "phase": EventPhase
.PHASE_BEGIN
,
76 "type": EventSourceType
.URL_REQUEST
79 "type": EventType
.URL_REQUEST_START_JOB
82 "phase": EventPhase
.PHASE_BEGIN
,
85 "type": EventSourceType
.URL_REQUEST
88 "type": EventType
.HTTP_STREAM_REQUEST
92 "original_url": "https://www.google.com/",
94 "url": "https://www.google.com/"
96 "phase": EventPhase
.PHASE_BEGIN
,
99 "type": EventSourceType
.HTTP_STREAM_JOB
102 "type": EventType
.HTTP_STREAM_JOB
105 "phase": EventPhase
.PHASE_BEGIN
,
108 "type": EventSourceType
.HTTP_STREAM_JOB
111 "type": EventType
.PROXY_SERVICE
114 "phase": EventPhase
.PHASE_END
,
117 "type": EventSourceType
.HTTP_STREAM_JOB
120 "type": EventType
.PROXY_SERVICE
124 "source_dependency": {
126 "type": EventSourceType
.HOST_RESOLVER_IMPL_REQUEST
129 "phase": EventPhase
.PHASE_BEGIN
,
132 "type": EventSourceType
.HTTP_STREAM_JOB
135 "type": EventType
.HOST_RESOLVER_IMPL
140 "allow_cached_response": true,
141 "host": "www.google.com:443",
142 "is_speculative": false,
144 "source_dependency": {
146 "type": EventSourceType
.HTTP_STREAM_JOB
149 "phase": EventPhase
.PHASE_BEGIN
,
152 "type": EventSourceType
.HOST_RESOLVER_IMPL_REQUEST
155 "type": EventType
.HOST_RESOLVER_IMPL_REQUEST
158 "phase": EventPhase
.PHASE_END
,
161 "type": EventSourceType
.HOST_RESOLVER_IMPL_REQUEST
164 "type": EventType
.HOST_RESOLVER_IMPL_REQUEST
167 "phase": EventPhase
.PHASE_END
,
170 "type": EventSourceType
.HTTP_STREAM_JOB
173 "type": EventType
.HOST_RESOLVER_IMPL
177 "group_name": "ssl/www.google.com:443"
179 "phase": EventPhase
.PHASE_BEGIN
,
182 "type": EventSourceType
.CONNECT_JOB
185 "type": EventType
.SOCKET_POOL_CONNECT_JOB
188 "phase": EventPhase
.PHASE_END
,
191 "type": EventSourceType
.CONNECT_JOB
194 "type": EventType
.SOCKET_POOL_CONNECT_JOB
198 "source_dependency": {
200 "type": EventSourceType
.SOCKET
203 "phase": EventPhase
.PHASE_NONE
,
206 "type": EventSourceType
.HTTP_STREAM_JOB
209 "type": EventType
.SOCKET_POOL_BOUND_TO_SOCKET
212 "phase": EventPhase
.PHASE_END
,
215 "type": EventSourceType
.HTTP_STREAM_JOB
218 "type": EventType
.SOCKET_POOL
222 "next_proto_status": "negotiated",
226 "phase": EventPhase
.PHASE_NONE
,
229 "type": EventSourceType
.HTTP_STREAM_JOB
232 "type": EventType
.HTTP_STREAM_REQUEST_PROTO
236 "source_dependency": {
238 "type": EventSourceType
.HOST_RESOLVER_IMPL_REQUEST
241 "phase": EventPhase
.PHASE_BEGIN
,
244 "type": EventSourceType
.HTTP_STREAM_JOB
247 "type": EventType
.HOST_RESOLVER_IMPL
252 "allow_cached_response": true,
253 "host": "www.google.com:443",
254 "is_speculative": false,
256 "source_dependency": {
258 "type": EventSourceType
.HTTP_STREAM_JOB
261 "phase": EventPhase
.PHASE_BEGIN
,
264 "type": EventSourceType
.HOST_RESOLVER_IMPL_REQUEST
267 "type": EventType
.HOST_RESOLVER_IMPL_REQUEST
270 "phase": EventPhase
.PHASE_END
,
273 "type": EventSourceType
.HTTP_STREAM_JOB
276 "type": EventType
.HOST_RESOLVER_IMPL
280 "source_dependency": {
282 "type": EventSourceType
.HTTP_STREAM_JOB
285 "phase": EventPhase
.PHASE_NONE
,
288 "type": EventSourceType
.URL_REQUEST
291 "type": EventType
.HTTP_STREAM_REQUEST_BOUND_TO_JOB
294 "phase": EventPhase
.PHASE_END
,
297 "type": EventSourceType
.URL_REQUEST
300 "type": EventType
.HTTP_STREAM_REQUEST
303 "phase": EventPhase
.PHASE_END
,
306 "type": EventSourceType
.HTTP_STREAM_JOB
309 "type": EventType
.HTTP_STREAM_JOB
312 "phase": EventPhase
.PHASE_BEGIN
,
315 "type": EventSourceType
.URL_REQUEST
318 "type": EventType
.HTTP_TRANSACTION_READ_HEADERS
321 "phase": EventPhase
.PHASE_END
,
324 "type": EventSourceType
.URL_REQUEST
327 "type": EventType
.HTTP_TRANSACTION_READ_HEADERS
330 "phase": EventPhase
.PHASE_END
,
333 "type": EventSourceType
.URL_REQUEST
336 "type": EventType
.URL_REQUEST_START_JOB
339 "phase": EventPhase
.PHASE_END
,
342 "type": EventSourceType
.URL_REQUEST
345 "type": EventType
.REQUEST_ALIVE
351 function urlRequestConnectionAfterProxyService() {
352 var socketLogEntries
= [
355 "source_dependency": {
357 "type": EventSourceType
.CONNECT_JOB
,
359 "phase": EventPhase
.PHASE_BEGIN
363 "type": EventSourceType
.SOCKET
,
366 "type": EventType
.SOCKET_ALIVE
371 "[2607:f8b0:4006:802::1010]:443",
372 "74.125.226.211:443",
373 "74.125.226.212:443",
374 "74.125.226.208:443",
375 "74.125.226.209:443",
379 "phase": EventPhase
.PHASE_BEGIN
,
382 "type": EventSourceType
.SOCKET
385 "type": EventType
.TCP_CONNECT
389 "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
391 "phase": EventPhase
.PHASE_END
,
394 "type": EventSourceType
.SOCKET
397 "type": EventType
.TCP_CONNECT
401 "source_dependency": {
403 "type": EventSourceType
.SOCKET
406 "phase": EventPhase
.PHASE_NONE
,
409 "type": EventSourceType
.CONNECT_JOB
412 "type": EventType
.SOCKET_POOL_BOUND_TO_SOCKET
415 "phase": EventPhase
.PHASE_BEGIN
,
418 "type": EventSourceType
.SOCKET
421 "type": EventType
.SSL_CONNECT
424 "phase": EventPhase
.PHASE_END
,
427 "type": EventSourceType
.SOCKET
430 "type": EventType
.SSL_CONNECT
435 startTime
: "369047390",
436 endTime
: "369047397",
437 eventType
: EventType
.TCP_CONNECT
440 var logEntries
= logEntriesWithoutTcpConnection().concat(socketLogEntries
);
441 g_browser
.receivedLogEntries(logEntries
);
444 testCase
.sourceEntry
= SourceTracker
.getInstance().getSourceEntry(111);
446 var expectedEventPairs
= expectedEventPairsWithoutTcp();
447 expectedEventPairs
.splice(2, 0, tcpConnect
);
448 testCase
.expectedEventPairs
= expectedEventPairs
;
453 function urlRequestConnectionInProxyService() {
454 var socketLogEntries
= [
457 "source_dependency": {
459 "type": EventSourceType
.CONNECT_JOB
,
461 "phase": EventPhase
.PHASE_BEGIN
465 "type": EventSourceType
.SOCKET
,
468 "type": EventType
.SOCKET_ALIVE
473 "[2607:f8b0:4006:802::1010]:443",
474 "74.125.226.211:443",
475 "74.125.226.212:443",
476 "74.125.226.208:443",
477 "74.125.226.209:443",
481 "phase": EventPhase
.PHASE_BEGIN
,
484 "type": EventSourceType
.SOCKET
487 "type": EventType
.TCP_CONNECT
491 "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
493 "phase": EventPhase
.PHASE_END
,
496 "type": EventSourceType
.SOCKET
499 "type": EventType
.TCP_CONNECT
503 "source_dependency": {
505 "type": EventSourceType
.SOCKET
508 "phase": EventPhase
.PHASE_NONE
,
511 "type": EventSourceType
.CONNECT_JOB
514 "type": EventType
.SOCKET_POOL_BOUND_TO_SOCKET
517 "phase": EventPhase
.PHASE_BEGIN
,
520 "type": EventSourceType
.SOCKET
523 "type": EventType
.SSL_CONNECT
526 "phase": EventPhase
.PHASE_END
,
529 "type": EventSourceType
.SOCKET
532 "type": EventType
.SSL_CONNECT
537 startTime
: "369047371",
538 endTime
: "369047397",
539 eventType
: EventType
.TCP_CONNECT
542 var logEntries
= logEntriesWithoutTcpConnection().concat(socketLogEntries
);
543 g_browser
.receivedLogEntries(logEntries
);
546 testCase
.sourceEntry
= SourceTracker
.getInstance().getSourceEntry(111);
548 var expectedEventPairs
= expectedEventPairsWithoutTcp();
549 expectedEventPairs
.splice(2, 0, tcpConnect
);
550 testCase
.expectedEventPairs
= expectedEventPairs
;
555 function urlRequestConnectionBeforeProxyService() {
557 var socketLogEntries
= [
560 "source_dependency": {
562 "type": EventSourceType
.CONNECT_JOB
,
564 "phase": EventPhase
.PHASE_BEGIN
568 "type": EventSourceType
.SOCKET
,
571 "type": EventType
.SOCKET_ALIVE
576 "[2607:f8b0:4006:802::1010]:443",
577 "74.125.226.211:443",
578 "74.125.226.212:443",
579 "74.125.226.208:443",
580 "74.125.226.209:443",
584 "phase": EventPhase
.PHASE_BEGIN
,
587 "type": EventSourceType
.SOCKET
590 "type": EventType
.TCP_CONNECT
594 "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
596 "phase": EventPhase
.PHASE_END
,
599 "type": EventSourceType
.SOCKET
602 "type": EventType
.TCP_CONNECT
606 "source_dependency": {
608 "type": EventSourceType
.SOCKET
611 "phase": EventPhase
.PHASE_NONE
,
614 "type": EventSourceType
.CONNECT_JOB
617 "type": EventType
.SOCKET_POOL_BOUND_TO_SOCKET
620 "phase": EventPhase
.PHASE_BEGIN
,
623 "type": EventSourceType
.SOCKET
626 "type": EventType
.SSL_CONNECT
629 "phase": EventPhase
.PHASE_END
,
632 "type": EventSourceType
.SOCKET
635 "type": EventType
.SSL_CONNECT
638 var logEntries
= logEntriesWithoutTcpConnection().concat(socketLogEntries
);
639 g_browser
.receivedLogEntries(logEntries
);
642 testCase
.sourceEntry
= SourceTracker
.getInstance().getSourceEntry(111);
643 testCase
.expectedEventPairs
= expectedEventPairsWithoutTcp();
648 runTestCase(urlRequestConnectionAfterProxyService());
649 runTestCase(urlRequestConnectionInProxyService());
650 runTestCase(urlRequestConnectionBeforeProxyService());
655 })(); // Anonymous namespace