Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / webui / net_internals / waterfall_view.js
bloba8825d9f73f959549ada56a79d6beb07384a6748
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']);
8 // Anonymous namespace
9 (function() {
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);
24     }
25     SourceTracker.getInstance().clearEntries_();
26   }
28   function expectedEventPairsWithoutTcp() {
29     var expectedEventPairs = [
30       {
31         startTime: "369047367",
32         endTime: "369047371",
33         eventType: EventType.PROXY_SERVICE
34       },
35       {
36         startTime: "369047398",
37         endTime: "369047437",
38         eventType: EventType.SSL_CONNECT
39       },
40       {
41         startTime: "369047444",
42         endTime: "369047474",
43         eventType: EventType.HTTP_TRANSACTION_READ_HEADERS
44       }
45     ];
46     return expectedEventPairs;
47   }
49   function logEntriesWithoutTcpConnection() {
50     var logEntries = [
51       {
52         "phase": EventPhase.PHASE_BEGIN,
53         "source": {
54           "id": 111,
55           "type": EventSourceType.URL_REQUEST
56         },
57         "time": "369047366",
58         "type": EventType.REQUEST_ALIVE
59       },
60       {
61         "params": {
62           "load_flags": 16480,
63           "method": "GET",
64           "priority": 1,
65           "url":
66               "https://www.google.com/searchdomaincheck?format=url&type=chrome"
67         },
68         "phase": EventPhase.PHASE_BEGIN,
69         "source": {
70           "id": 111,
71           "type": EventSourceType.URL_REQUEST
72         },
73         "time": "369047366",
74         "type": EventType.URL_REQUEST_START_JOB
75       },
76       {
77         "phase": EventPhase.PHASE_BEGIN,
78         "source": {
79           "id": 111,
80           "type": EventSourceType.URL_REQUEST
81         },
82         "time": "369047367",
83         "type": EventType.HTTP_STREAM_REQUEST
84       },
85       {
86         "params": {
87           "original_url": "https://www.google.com/",
88           "priority": 1,
89           "url": "https://www.google.com/"
90         },
91         "phase": EventPhase.PHASE_BEGIN,
92         "source": {
93           "id": 112,
94           "type": EventSourceType.HTTP_STREAM_JOB
95         },
96         "time": "369047367",
97         "type": EventType.HTTP_STREAM_JOB
98       },
99       {
100         "phase": EventPhase.PHASE_BEGIN,
101         "source": {
102           "id": 112,
103           "type": EventSourceType.HTTP_STREAM_JOB
104         },
105         "time": "369047367",
106         "type": EventType.PROXY_SERVICE
107       },
108       {
109         "phase": EventPhase.PHASE_END,
110         "source": {
111           "id": 112,
112           "type": EventSourceType.HTTP_STREAM_JOB
113         },
114         "time": "369047371",
115         "type": EventType.PROXY_SERVICE
116       },
117       {
118         "params": {
119           "address_family": 0,
120           "allow_cached_response": true,
121           "host": "www.google.com:443",
122           "is_speculative": false,
123           "priority": 3
124         },
125         "phase": EventPhase.PHASE_BEGIN,
126         "source": {
127           "id": 112,
128           "type": EventSourceType.HTTP_STREAM_JOB
129         },
130         "time": "369047371",
131         "type": EventType.HOST_RESOLVER_IMPL_REQUEST
132       },
133       {
134         "phase": EventPhase.PHASE_END,
135         "source": {
136           "id": 112,
137           "type": EventSourceType.HTTP_STREAM_JOB
138         },
139         "time": "369047372",
140         "type": EventType.HOST_RESOLVER_IMPL_REQUEST
141       },
142       {
143         "params": {
144           "group_name": "ssl/www.google.com:443"
145         },
146         "phase": EventPhase.PHASE_BEGIN,
147         "source": {
148           "id": 115,
149           "type": EventSourceType.CONNECT_JOB
150         },
151         "time": "369047372",
152         "type": EventType.SOCKET_POOL_CONNECT_JOB
153       },
154       {
155         "phase": EventPhase.PHASE_END,
156         "source": {
157           "id": 115,
158           "type": EventSourceType.CONNECT_JOB
159         },
160         "time": "369047437",
161         "type": EventType.SOCKET_POOL_CONNECT_JOB
162       },
163       {
164         "params": {
165           "source_dependency": {
166             "id": 124,
167             "type": EventSourceType.SOCKET
168           }
169         },
170         "phase": EventPhase.PHASE_NONE,
171         "source": {
172           "id": 112,
173           "type": EventSourceType.HTTP_STREAM_JOB
174         },
175         "time": "369047438",
176         "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
177       },
178       {
179         "phase": EventPhase.PHASE_END,
180         "source": {
181           "id": 112,
182           "type": EventSourceType.HTTP_STREAM_JOB
183         },
184         "time": "369047438",
185         "type": EventType.SOCKET_POOL
186       },
187       {
188         "params": {
189           "next_proto_status": "negotiated",
190           "proto": "spdy/3",
191           "server_protos": ""
192         },
193         "phase": EventPhase.PHASE_NONE,
194         "source": {
195           "id": 112,
196           "type": EventSourceType.HTTP_STREAM_JOB
197         },
198         "time": "369047438",
199         "type": EventType.HTTP_STREAM_REQUEST_PROTO
200       },
201       {
202         "params": {
203           "address_family": 0,
204           "allow_cached_response": true,
205           "host": "www.google.com:443",
206           "is_speculative": false,
207           "priority": 3
208         },
209         "phase": EventPhase.PHASE_BEGIN,
210         "source": {
211           "id": 112,
212           "type": EventSourceType.HTTP_STREAM_JOB
213         },
214         "time": "369047438",
215         "type": EventType.HOST_RESOLVER_IMPL_REQUEST
216       },
217       {
218         "phase": EventPhase.PHASE_END,
219         "source": {
220           "id": 112,
221           "type": EventSourceType.HTTP_STREAM_JOB
222         },
223         "time": "369047439",
224         "type": EventType.HOST_RESOLVER_IMPL_REQUEST
225       },
226       {
227         "params": {
228           "source_dependency": {
229             "id": 112,
230             "type": EventSourceType.HTTP_STREAM_JOB
231           }
232         },
233         "phase": EventPhase.PHASE_NONE,
234         "source": {
235           "id": 111,
236           "type": EventSourceType.URL_REQUEST
237         },
238         "time": "369047440",
239         "type": EventType.HTTP_STREAM_REQUEST_BOUND_TO_JOB
240       },
241       {
242         "phase": EventPhase.PHASE_END,
243         "source": {
244           "id": 111,
245           "type": EventSourceType.URL_REQUEST
246         },
247         "time": "369047440",
248         "type": EventType.HTTP_STREAM_REQUEST
249       },
250       {
251         "phase": EventPhase.PHASE_END,
252         "source": {
253           "id": 112,
254           "type": EventSourceType.HTTP_STREAM_JOB
255         },
256         "time": "369047440",
257         "type": EventType.HTTP_STREAM_JOB
258       },
259       {
260         "phase": EventPhase.PHASE_BEGIN,
261         "source": {
262           "id": 111,
263           "type": EventSourceType.URL_REQUEST
264         },
265         "time": "369047444",
266         "type": EventType.HTTP_TRANSACTION_READ_HEADERS
267       },
268       {
269         "phase": EventPhase.PHASE_END,
270         "source": {
271           "id": 111,
272           "type": EventSourceType.URL_REQUEST
273         },
274         "time": "369047474",
275         "type": EventType.HTTP_TRANSACTION_READ_HEADERS
276       },
277       {
278         "phase": EventPhase.PHASE_END,
279         "source": {
280           "id": 111,
281           "type": EventSourceType.URL_REQUEST
282         },
283         "time": "369047475",
284         "type": EventType.URL_REQUEST_START_JOB
285       },
286       {
287         "phase": EventPhase.PHASE_END,
288         "source": {
289           "id": 111,
290           "type": EventSourceType.URL_REQUEST
291         },
292         "time": "369047476",
293         "type": EventType.REQUEST_ALIVE
294       }
295     ];
296     return logEntries;
297   }
299   function urlRequestConnectionAfterProxyService() {
300     var socketLogEntries = [
301       {
302         "params": {
303           "source_dependency": {
304             "id": 115,
305             "type": EventSourceType.CONNECT_JOB,
306           },
307           "phase": EventPhase.PHASE_BEGIN
308         },
309         "source": {
310           "id": 124,
311           "type": EventSourceType.SOCKET,
312         },
313         "time": "369047210",
314         "type": EventType.SOCKET_ALIVE
315       },
316       {
317         "params": {
318           "address_list": [
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",
324             "74.125.226.210:443"
325           ]
326         },
327         "phase": EventPhase.PHASE_BEGIN,
328         "source": {
329           "id": 124,
330           "type": EventSourceType.SOCKET
331         },
332         "time": "369047390",
333         "type": EventType.TCP_CONNECT
334       },
335       {
336         "params": {
337           "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
338         },
339         "phase": EventPhase.PHASE_END,
340         "source": {
341           "id": 124,
342           "type": EventSourceType.SOCKET
343         },
344         "time": "369047397",
345         "type": EventType.TCP_CONNECT
346       },
347       {
348         "params": {
349           "source_dependency": {
350             "id": 124,
351             "type": EventSourceType.SOCKET
352           }
353         },
354         "phase": EventPhase.PHASE_NONE,
355         "source": {
356           "id": 115,
357           "type": EventSourceType.CONNECT_JOB
358         },
359         "time": "369047398",
360         "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
361       },
362       {
363         "phase": EventPhase.PHASE_BEGIN,
364         "source": {
365           "id": 124,
366           "type": EventSourceType.SOCKET
367         },
368         "time": "369047398",
369         "type": EventType.SSL_CONNECT
370       },
371       {
372         "phase": EventPhase.PHASE_END,
373         "source": {
374           "id": 124,
375           "type": EventSourceType.SOCKET
376         },
377         "time": "369047437",
378         "type": EventType.SSL_CONNECT
379       }
380     ];
382     var tcpConnect = {
383       startTime: "369047390",
384       endTime: "369047397",
385       eventType: EventType.TCP_CONNECT
386     };
388     var logEntries = logEntriesWithoutTcpConnection().concat(socketLogEntries);
389     g_browser.receivedLogEntries(logEntries);
391     var testCase = {};
392     testCase.sourceEntry = SourceTracker.getInstance().getSourceEntry(111);
394     var expectedEventPairs = expectedEventPairsWithoutTcp();
395     expectedEventPairs.splice(1, 0, tcpConnect);
396     testCase.expectedEventPairs = expectedEventPairs;
398     return testCase;
399   }
401   function urlRequestConnectionInProxyService() {
402     var socketLogEntries = [
403       {
404         "params": {
405           "source_dependency": {
406             "id": 115,
407             "type": EventSourceType.CONNECT_JOB,
408           },
409           "phase": EventPhase.PHASE_BEGIN
410         },
411         "source": {
412           "id": 124,
413           "type": EventSourceType.SOCKET,
414         },
415         "time": "369047210",
416         "type": EventType.SOCKET_ALIVE
417       },
418       {
419         "params": {
420           "address_list": [
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",
426             "74.125.226.210:443"
427           ]
428         },
429         "phase": EventPhase.PHASE_BEGIN,
430         "source": {
431           "id": 124,
432           "type": EventSourceType.SOCKET
433         },
434         "time": "369047370",
435         "type": EventType.TCP_CONNECT
436       },
437       {
438         "params": {
439           "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
440         },
441         "phase": EventPhase.PHASE_END,
442         "source": {
443           "id": 124,
444           "type": EventSourceType.SOCKET
445         },
446         "time": "369047397",
447         "type": EventType.TCP_CONNECT
448       },
449       {
450         "params": {
451           "source_dependency": {
452             "id": 124,
453             "type": EventSourceType.SOCKET
454           }
455         },
456         "phase": EventPhase.PHASE_NONE,
457         "source": {
458           "id": 115,
459           "type": EventSourceType.CONNECT_JOB
460         },
461         "time": "369047398",
462         "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
463       },
464       {
465         "phase": EventPhase.PHASE_BEGIN,
466         "source": {
467           "id": 124,
468           "type": EventSourceType.SOCKET
469         },
470         "time": "369047398",
471         "type": EventType.SSL_CONNECT
472       },
473       {
474         "phase": EventPhase.PHASE_END,
475         "source": {
476           "id": 124,
477           "type": EventSourceType.SOCKET
478         },
479         "time": "369047437",
480         "type": EventType.SSL_CONNECT
481       }
482     ];
484     var tcpConnect = {
485       startTime: "369047371",
486       endTime: "369047397",
487       eventType: EventType.TCP_CONNECT
488     };
490     var logEntries = logEntriesWithoutTcpConnection().concat(socketLogEntries);
491     g_browser.receivedLogEntries(logEntries);
493     var testCase = {};
494     testCase.sourceEntry = SourceTracker.getInstance().getSourceEntry(111);
496     var expectedEventPairs = expectedEventPairsWithoutTcp();
497     expectedEventPairs.splice(1, 0, tcpConnect);
498     testCase.expectedEventPairs = expectedEventPairs;
500     return testCase;
501   }
503   function urlRequestConnectionBeforeProxyService() {
505     var socketLogEntries = [
506       {
507         "params": {
508           "source_dependency": {
509             "id": 115,
510             "type": EventSourceType.CONNECT_JOB,
511           },
512           "phase": EventPhase.PHASE_BEGIN
513         },
514         "source": {
515           "id": 124,
516           "type": EventSourceType.SOCKET,
517         },
518         "time": "369047210",
519         "type": EventType.SOCKET_ALIVE
520       },
521       {
522         "params": {
523           "address_list": [
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",
529             "74.125.226.210:443"
530           ]
531         },
532         "phase": EventPhase.PHASE_BEGIN,
533         "source": {
534           "id": 124,
535           "type": EventSourceType.SOCKET
536         },
537         "time": "369047350",
538         "type": EventType.TCP_CONNECT
539       },
540       {
541         "params": {
542           "source_address": "[2620:0:1004:2:be30:5bff:fedb:49b2]:42259"
543         },
544         "phase": EventPhase.PHASE_END,
545         "source": {
546           "id": 124,
547           "type": EventSourceType.SOCKET
548         },
549         "time": "369047357",
550         "type": EventType.TCP_CONNECT
551       },
552       {
553         "params": {
554           "source_dependency": {
555             "id": 124,
556             "type": EventSourceType.SOCKET
557           }
558         },
559         "phase": EventPhase.PHASE_NONE,
560         "source": {
561           "id": 115,
562           "type": EventSourceType.CONNECT_JOB
563         },
564         "time": "369047398",
565         "type": EventType.SOCKET_POOL_BOUND_TO_SOCKET
566       },
567       {
568         "phase": EventPhase.PHASE_BEGIN,
569         "source": {
570           "id": 124,
571           "type": EventSourceType.SOCKET
572         },
573         "time": "369047398",
574         "type": EventType.SSL_CONNECT
575       },
576       {
577         "phase": EventPhase.PHASE_END,
578         "source": {
579           "id": 124,
580           "type": EventSourceType.SOCKET
581         },
582         "time": "369047437",
583         "type": EventType.SSL_CONNECT
584       }
585     ];
586     var logEntries = logEntriesWithoutTcpConnection().concat(socketLogEntries);
587     g_browser.receivedLogEntries(logEntries);
589     var testCase = {};
590     testCase.sourceEntry = SourceTracker.getInstance().getSourceEntry(111);
591     testCase.expectedEventPairs = expectedEventPairsWithoutTcp();
593     return testCase;
594   }
596   runTestCase(urlRequestConnectionAfterProxyService());
597   runTestCase(urlRequestConnectionInProxyService());
598   runTestCase(urlRequestConnectionBeforeProxyService());
600   testDone();
603 })();  // Anonymous namespace