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(testCase.expectedEventPairs.length, eventPairs.length);
15 for (var i = 0; i < eventPairs.length; ++i) {
16 expectEquals(testCase.expectedEventPairs[i].startTime,
17 eventPairs[i].startEntry.time);
18 expectEquals(testCase.expectedEventPairs[i].endTime,
19 eventPairs[i].endEntry.time);
20 expectEquals(testCase.expectedEventPairs[i].eventType,
21 eventPairs[i].startEntry.type);
22 expectEquals(testCase.expectedEventPairs[i].eventType,
23 eventPairs[i].endEntry.type);
25 SourceTracker.getInstance().clearEntries_();
28 function expectedEventPairsWithoutTcp() {
29 var expectedEventPairs = [
31 startTime: "369047367",
33 eventType: EventType.PROXY_SERVICE
36 startTime: "369047398",
38 eventType: EventType.SSL_CONNECT
41 startTime: "369047444",
43 eventType: EventType.HTTP_TRANSACTION_READ_HEADERS
46 return expectedEventPairs;
49 function logEntriesWithoutTcpConnection() {
52 "phase": EventPhase.PHASE_BEGIN,
55 "type": EventSourceType.URL_REQUEST
58 "type": EventType.REQUEST_ALIVE
66 "https://www.google.com/searchdomaincheck?format=url&type=chrome"
68 "phase": EventPhase.PHASE_BEGIN,
71 "type": EventSourceType.URL_REQUEST
74 "type": EventType.URL_REQUEST_START_JOB
77 "phase": EventPhase.PHASE_BEGIN,
80 "type": EventSourceType.URL_REQUEST
83 "type": EventType.HTTP_STREAM_REQUEST
87 "original_url": "https://www.google.com/",
89 "url": "https://www.google.com/"
91 "phase": EventPhase.PHASE_BEGIN,
94 "type": EventSourceType.HTTP_STREAM_JOB
97 "type": EventType.HTTP_STREAM_JOB
100 "phase": EventPhase.PHASE_BEGIN,
103 "type": EventSourceType.HTTP_STREAM_JOB
106 "type": EventType.PROXY_SERVICE
109 "phase": EventPhase.PHASE_END,
112 "type": EventSourceType.HTTP_STREAM_JOB
115 "type": EventType.PROXY_SERVICE
120 "allow_cached_response": true,
121 "host": "www.google.com:443",
122 "is_speculative": false,
125 "phase": EventPhase.PHASE_BEGIN,
128 "type": EventSourceType.HTTP_STREAM_JOB
131 "type": EventType.HOST_RESOLVER_IMPL_REQUEST
134 "phase": EventPhase.PHASE_END,
137 "type": EventSourceType.HTTP_STREAM_JOB
140 "type": EventType.HOST_RESOLVER_IMPL_REQUEST
144 "group_name": "ssl/www.google.com:443"
146 "phase": EventPhase.PHASE_BEGIN,
149 "type": EventSourceType.CONNECT_JOB
152 "type": EventType.SOCKET_POOL_CONNECT_JOB
155 "phase": EventPhase.PHASE_END,
158 "type": EventSourceType.CONNECT_JOB
161 "type": EventType.SOCKET_POOL_CONNECT_JOB
165 "source_dependency": {
167 "type": EventSourceType.SOCKET
170 "phase": EventPhase.PHASE_NONE,
173 "type": EventSourceType.HTTP_STREAM_JOB
176 "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
179 "phase": EventPhase.PHASE_END,
182 "type": EventSourceType.HTTP_STREAM_JOB
185 "type": EventType.SOCKET_POOL
189 "next_proto_status": "negotiated",
193 "phase": EventPhase.PHASE_NONE,
196 "type": EventSourceType.HTTP_STREAM_JOB
199 "type": EventType.HTTP_STREAM_REQUEST_PROTO
204 "allow_cached_response": true,
205 "host": "www.google.com:443",
206 "is_speculative": false,
209 "phase": EventPhase.PHASE_BEGIN,
212 "type": EventSourceType.HTTP_STREAM_JOB
215 "type": EventType.HOST_RESOLVER_IMPL_REQUEST
218 "phase": EventPhase.PHASE_END,
221 "type": EventSourceType.HTTP_STREAM_JOB
224 "type": EventType.HOST_RESOLVER_IMPL_REQUEST
228 "source_dependency": {
230 "type": EventSourceType.HTTP_STREAM_JOB
233 "phase": EventPhase.PHASE_NONE,
236 "type": EventSourceType.URL_REQUEST
239 "type": EventType.HTTP_STREAM_REQUEST_BOUND_TO_JOB
242 "phase": EventPhase.PHASE_END,
245 "type": EventSourceType.URL_REQUEST
248 "type": EventType.HTTP_STREAM_REQUEST
251 "phase": EventPhase.PHASE_END,
254 "type": EventSourceType.HTTP_STREAM_JOB
257 "type": EventType.HTTP_STREAM_JOB
260 "phase": EventPhase.PHASE_BEGIN,
263 "type": EventSourceType.URL_REQUEST
266 "type": EventType.HTTP_TRANSACTION_READ_HEADERS
269 "phase": EventPhase.PHASE_END,
272 "type": EventSourceType.URL_REQUEST
275 "type": EventType.HTTP_TRANSACTION_READ_HEADERS
278 "phase": EventPhase.PHASE_END,
281 "type": EventSourceType.URL_REQUEST
284 "type": EventType.URL_REQUEST_START_JOB
287 "phase": EventPhase.PHASE_END,
290 "type": EventSourceType.URL_REQUEST
293 "type": EventType.REQUEST_ALIVE
299 function urlRequestConnectionAfterProxyService() {
300 var socketLogEntries = [
303 "source_dependency": {
305 "type": EventSourceType.CONNECT_JOB,
307 "phase": EventPhase.PHASE_BEGIN
311 "type": EventSourceType.SOCKET,
314 "type": EventType.SOCKET_ALIVE
319 "[2607:f8b0:4006:802::1010]:443",
320 "74.125.226.211:443",
321 "74.125.226.212:443",
322 "74.125.226.208:443",
323 "74.125.226.209:443",
327 "phase": EventPhase.PHASE_BEGIN,
330 "type": EventSourceType.SOCKET
333 "type": EventType.TCP_CONNECT
337 "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
339 "phase": EventPhase.PHASE_END,
342 "type": EventSourceType.SOCKET
345 "type": EventType.TCP_CONNECT
349 "source_dependency": {
351 "type": EventSourceType.SOCKET
354 "phase": EventPhase.PHASE_NONE,
357 "type": EventSourceType.CONNECT_JOB
360 "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
363 "phase": EventPhase.PHASE_BEGIN,
366 "type": EventSourceType.SOCKET
369 "type": EventType.SSL_CONNECT
372 "phase": EventPhase.PHASE_END,
375 "type": EventSourceType.SOCKET
378 "type": EventType.SSL_CONNECT
383 startTime: "369047390",
384 endTime: "369047397",
385 eventType: EventType.TCP_CONNECT
388 var logEntries = logEntriesWithoutTcpConnection().concat(socketLogEntries);
389 g_browser.receivedLogEntries(logEntries);
392 testCase.sourceEntry = SourceTracker.getInstance().getSourceEntry(111);
394 var expectedEventPairs = expectedEventPairsWithoutTcp();
395 expectedEventPairs.splice(1, 0, tcpConnect);
396 testCase.expectedEventPairs = expectedEventPairs;
401 function urlRequestConnectionInProxyService() {
402 var socketLogEntries = [
405 "source_dependency": {
407 "type": EventSourceType.CONNECT_JOB,
409 "phase": EventPhase.PHASE_BEGIN
413 "type": EventSourceType.SOCKET,
416 "type": EventType.SOCKET_ALIVE
421 "[2607:f8b0:4006:802::1010]:443",
422 "74.125.226.211:443",
423 "74.125.226.212:443",
424 "74.125.226.208:443",
425 "74.125.226.209:443",
429 "phase": EventPhase.PHASE_BEGIN,
432 "type": EventSourceType.SOCKET
435 "type": EventType.TCP_CONNECT
439 "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
441 "phase": EventPhase.PHASE_END,
444 "type": EventSourceType.SOCKET
447 "type": EventType.TCP_CONNECT
451 "source_dependency": {
453 "type": EventSourceType.SOCKET
456 "phase": EventPhase.PHASE_NONE,
459 "type": EventSourceType.CONNECT_JOB
462 "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
465 "phase": EventPhase.PHASE_BEGIN,
468 "type": EventSourceType.SOCKET
471 "type": EventType.SSL_CONNECT
474 "phase": EventPhase.PHASE_END,
477 "type": EventSourceType.SOCKET
480 "type": EventType.SSL_CONNECT
485 startTime: "369047371",
486 endTime: "369047397",
487 eventType: EventType.TCP_CONNECT
490 var logEntries = logEntriesWithoutTcpConnection().concat(socketLogEntries);
491 g_browser.receivedLogEntries(logEntries);
494 testCase.sourceEntry = SourceTracker.getInstance().getSourceEntry(111);
496 var expectedEventPairs = expectedEventPairsWithoutTcp();
497 expectedEventPairs.splice(1, 0, tcpConnect);
498 testCase.expectedEventPairs = expectedEventPairs;
503 function urlRequestConnectionBeforeProxyService() {
505 var socketLogEntries = [
508 "source_dependency": {
510 "type": EventSourceType.CONNECT_JOB,
512 "phase": EventPhase.PHASE_BEGIN
516 "type": EventSourceType.SOCKET,
519 "type": EventType.SOCKET_ALIVE
524 "[2607:f8b0:4006:802::1010]:443",
525 "74.125.226.211:443",
526 "74.125.226.212:443",
527 "74.125.226.208:443",
528 "74.125.226.209:443",
532 "phase": EventPhase.PHASE_BEGIN,
535 "type": EventSourceType.SOCKET
538 "type": EventType.TCP_CONNECT
542 "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
544 "phase": EventPhase.PHASE_END,
547 "type": EventSourceType.SOCKET
550 "type": EventType.TCP_CONNECT
554 "source_dependency": {
556 "type": EventSourceType.SOCKET
559 "phase": EventPhase.PHASE_NONE,
562 "type": EventSourceType.CONNECT_JOB
565 "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
568 "phase": EventPhase.PHASE_BEGIN,
571 "type": EventSourceType.SOCKET
574 "type": EventType.SSL_CONNECT
577 "phase": EventPhase.PHASE_END,
580 "type": EventSourceType.SOCKET
583 "type": EventType.SSL_CONNECT
586 var logEntries = logEntriesWithoutTcpConnection().concat(socketLogEntries);
587 g_browser.receivedLogEntries(logEntries);
590 testCase.sourceEntry = SourceTracker.getInstance().getSourceEntry(111);
591 testCase.expectedEventPairs = expectedEventPairsWithoutTcp();
596 runTestCase(urlRequestConnectionAfterProxyService());
597 runTestCase(urlRequestConnectionInProxyService());
598 runTestCase(urlRequestConnectionBeforeProxyService());
603 })(); // Anonymous namespace