Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: tracing/tracing/metrics/system_health/loading_metric_test.html

Issue 2883233002: Revert of Fix main frame detection in loading metrics. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2016 The Chromium Authors. All rights reserved. 3 Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/core/test_utils.html"> 8 <link rel="import" href="/tracing/core/test_utils.html">
9 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html"> 9 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html">
10 <link rel="import" href="/tracing/value/histogram_set.html"> 10 <link rel="import" href="/tracing/value/histogram_set.html">
(...skipping 14 matching lines...) Expand all
25 duration: 0.0, 25 duration: 0.0,
26 args: {frame: '0xdeadbeef'} 26 args: {frame: '0xdeadbeef'}
27 })); 27 }));
28 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 28 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
29 { 29 {
30 isLoadingMainFrame: true, 30 isLoadingMainFrame: true,
31 frame: {id_ref: '0xdeadbeef'}, 31 frame: {id_ref: '0xdeadbeef'},
32 documentLoaderURL: 'http://example.com' 32 documentLoaderURL: 'http://example.com'
33 }); 33 });
34 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 34 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
35 cat: 'loading',
36 title: 'markAsMainFrame',
37 start: 300,
38 duration: 0.0,
39 args: {frame: '0xdeadbeef'}
40 }));
41 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
42 cat: 'loading,rail,devtools.timeline', 35 cat: 'loading,rail,devtools.timeline',
43 title: 'firstContentfulPaint', 36 title: 'firstContentfulPaint',
44 start: 1000, 37 start: 1000,
45 duration: 0.0, 38 duration: 0.0,
46 args: {frame: '0xdeadbeef'} 39 args: {frame: '0xdeadbeef'}
47 })); 40 }));
48 }); 41 });
49 const histograms = new tr.v.HistogramSet(); 42 const histograms = new tr.v.HistogramSet();
50 tr.metrics.sh.loadingMetric(histograms, model); 43 tr.metrics.sh.loadingMetric(histograms, model);
51 const hist = histograms.getHistogramNamed('timeToFirstContentfulPaint'); 44 const hist = histograms.getHistogramNamed('timeToFirstContentfulPaint');
(...skipping 21 matching lines...) Expand all
73 start: 250, 66 start: 250,
74 duration: 0.0 67 duration: 0.0
75 })); 68 }));
76 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 69 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
77 { 70 {
78 isLoadingMainFrame: true, 71 isLoadingMainFrame: true,
79 frame: {id_ref: '0xdeadbeef'}, 72 frame: {id_ref: '0xdeadbeef'},
80 documentLoaderURL: 'http://example.com' 73 documentLoaderURL: 'http://example.com'
81 }); 74 });
82 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 75 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
83 cat: 'loading',
84 title: 'markAsMainFrame',
85 start: 300,
86 duration: 0.0,
87 args: {frame: '0xdeadbeef'}
88 }));
89 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
90 cat: 'loading,rail,devtools.timeline', 76 cat: 'loading,rail,devtools.timeline',
91 title: 'firstContentfulPaint', 77 title: 'firstContentfulPaint',
92 start: 1000, 78 start: 1000,
93 duration: 0.0, 79 duration: 0.0,
94 args: {frame: '0xdeadbeef'} 80 args: {frame: '0xdeadbeef'}
95 })); 81 }));
96 mainThread.asyncSliceGroup.push(tr.c.TestUtils.newAsyncSliceEx({ 82 mainThread.asyncSliceGroup.push(tr.c.TestUtils.newAsyncSliceEx({
97 cat: 'blink.console', 83 cat: 'blink.console',
98 title: 'telemetry.internal.warmCache.end', 84 title: 'telemetry.internal.warmCache.end',
99 start: 1250, 85 start: 1250,
100 duration: 0.0 86 duration: 0.0
101 })); 87 }));
102 88
103 // measurement navigation 89 // measurement navigation
104 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 90 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
105 cat: 'blink.user_timing', 91 cat: 'blink.user_timing',
106 title: 'navigationStart', 92 title: 'navigationStart',
107 start: 2000, 93 start: 2000,
108 duration: 0.0, 94 duration: 0.0,
109 args: {frame: '0xdeadbeef'} 95 args: {frame: '0xdeadbeef'}
110 })); 96 }));
111 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 2100, 97 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 2100,
112 { 98 {
113 isLoadingMainFrame: true, 99 isLoadingMainFrame: true,
114 frame: {id_ref: '0xdeadbeef'}, 100 frame: {id_ref: '0xdeadbeef'},
115 documentLoaderURL: 'http://example.com' 101 documentLoaderURL: 'http://example.com'
116 }); 102 });
117 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 103 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
118 cat: 'loading',
119 title: 'markAsMainFrame',
120 start: 2100,
121 duration: 0.0,
122 args: {frame: '0xdeadbeef'}
123 }));
124 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
125 cat: 'loading,rail,devtools.timeline', 104 cat: 'loading,rail,devtools.timeline',
126 title: 'firstContentfulPaint', 105 title: 'firstContentfulPaint',
127 start: 2400, 106 start: 2400,
128 duration: 0.0, 107 duration: 0.0,
129 args: {frame: '0xdeadbeef'} 108 args: {frame: '0xdeadbeef'}
130 })); 109 }));
131 }); 110 });
132 const histograms = new tr.v.HistogramSet(); 111 const histograms = new tr.v.HistogramSet();
133 tr.metrics.sh.loadingMetric(histograms, model); 112 tr.metrics.sh.loadingMetric(histograms, model);
134 const hist = histograms.getHistogramNamed('timeToFirstContentfulPaint'); 113 const hist = histograms.getHistogramNamed('timeToFirstContentfulPaint');
(...skipping 14 matching lines...) Expand all
149 args: {frame: '0xdeadbeef'} 128 args: {frame: '0xdeadbeef'}
150 })); 129 }));
151 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 130 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
152 { 131 {
153 isLoadingMainFrame: true, 132 isLoadingMainFrame: true,
154 frame: {id_ref: '0xdeadbeef'}, 133 frame: {id_ref: '0xdeadbeef'},
155 documentLoaderURL: 'http://example.com' 134 documentLoaderURL: 'http://example.com'
156 }); 135 });
157 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 136 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
158 cat: 'loading', 137 cat: 'loading',
159 title: 'markAsMainFrame',
160 start: 300,
161 duration: 0.0,
162 args: {frame: '0xdeadbeef'}
163 }));
164 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
165 cat: 'loading',
166 title: 'firstMeaningfulPaintCandidate', 138 title: 'firstMeaningfulPaintCandidate',
167 start: 600, 139 start: 600,
168 duration: 0.0, 140 duration: 0.0,
169 args: {frame: '0xdeadbeef'} 141 args: {frame: '0xdeadbeef'}
170 })); 142 }));
171 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 143 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
172 cat: 'loading', 144 cat: 'loading',
173 title: 'firstMeaningfulPaintCandidate', 145 title: 'firstMeaningfulPaintCandidate',
174 start: 1000, 146 start: 1000,
175 duration: 0.0, 147 duration: 0.0,
(...skipping 29 matching lines...) Expand all
205 args: {frame: '0xdeadbeef'} 177 args: {frame: '0xdeadbeef'}
206 })); 178 }));
207 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 179 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
208 { 180 {
209 isLoadingMainFrame: true, 181 isLoadingMainFrame: true,
210 frame: {id_ref: '0xdeadbeef'}, 182 frame: {id_ref: '0xdeadbeef'},
211 documentLoaderURL: 'http://example.com' 183 documentLoaderURL: 'http://example.com'
212 }); 184 });
213 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 185 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
214 cat: 'loading', 186 cat: 'loading',
215 title: 'markAsMainFrame',
216 start: 300,
217 duration: 0.0,
218 args: {frame: '0xdeadbeef'}
219 }));
220 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
221 cat: 'loading',
222 title: 'firstMeaningfulPaintCandidate', 187 title: 'firstMeaningfulPaintCandidate',
223 start: 600, 188 start: 600,
224 duration: 0.0, 189 duration: 0.0,
225 cpuStart: 1480, 190 cpuStart: 1480,
226 cpuDuration: 0, 191 cpuDuration: 0,
227 args: {frame: '0xdeadbeef'} 192 args: {frame: '0xdeadbeef'}
228 })); 193 }));
229 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 194 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
230 cat: 'toplevel', 195 cat: 'toplevel',
231 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', 196 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 args: {frame: '0xdeadbeef'} 240 args: {frame: '0xdeadbeef'}
276 })); 241 }));
277 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 242 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
278 { 243 {
279 isLoadingMainFrame: true, 244 isLoadingMainFrame: true,
280 frame: {id_ref: '0xdeadbeef'}, 245 frame: {id_ref: '0xdeadbeef'},
281 documentLoaderURL: 'http://example.com' 246 documentLoaderURL: 'http://example.com'
282 }); 247 });
283 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 248 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
284 cat: 'loading', 249 cat: 'loading',
285 title: 'markAsMainFrame',
286 start: 300,
287 duration: 0.0,
288 args: {frame: '0xdeadbeef'}
289 }));
290 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
291 cat: 'loading',
292 title: 'firstMeaningfulPaintCandidate', 250 title: 'firstMeaningfulPaintCandidate',
293 start: 600, 251 start: 600,
294 duration: 0.0, 252 duration: 0.0,
295 cpuStart: 1280, 253 cpuStart: 1280,
296 cpuDuration: 0, 254 cpuDuration: 0,
297 args: {frame: '0xdeadbeef'} 255 args: {frame: '0xdeadbeef'}
298 })); 256 }));
299 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 257 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
300 cat: 'toplevel', 258 cat: 'toplevel',
301 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', 259 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 args: {frame: '0xdeadbeef'} 310 args: {frame: '0xdeadbeef'}
353 })); 311 }));
354 rendererProcess1.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 312 rendererProcess1.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
355 { 313 {
356 isLoadingMainFrame: true, 314 isLoadingMainFrame: true,
357 frame: {id_ref: '0xdeadbeef'}, 315 frame: {id_ref: '0xdeadbeef'},
358 documentLoaderURL: 'http://example.com' 316 documentLoaderURL: 'http://example.com'
359 }); 317 });
360 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 318 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
361 cat: 'loading', 319 cat: 'loading',
362 title: 'markAsMainFrame',
363 start: 300,
364 duration: 0.0,
365 args: {frame: '0xdeadbeef'}
366 }));
367 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
368 cat: 'loading',
369 title: 'firstMeaningfulPaintCandidate', 320 title: 'firstMeaningfulPaintCandidate',
370 start: 600, 321 start: 600,
371 duration: 0.0, 322 duration: 0.0,
372 cpuStart: 1280, 323 cpuStart: 1280,
373 cpuDuration: 0, 324 cpuDuration: 0,
374 args: {frame: '0xdeadbeef'} 325 args: {frame: '0xdeadbeef'}
375 })); 326 }));
376 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 327 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
377 cat: 'loader', 328 cat: 'loader',
378 title: 'ResourceDispatcher::OnRequestComplete', 329 title: 'ResourceDispatcher::OnRequestComplete',
(...skipping 16 matching lines...) Expand all
395 args: {frame: '0xdeadbeef'} 346 args: {frame: '0xdeadbeef'}
396 })); 347 }));
397 rendererProcess2.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 348 rendererProcess2.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
398 { 349 {
399 isLoadingMainFrame: true, 350 isLoadingMainFrame: true,
400 frame: {id_ref: '0xdeadbeef'}, 351 frame: {id_ref: '0xdeadbeef'},
401 documentLoaderURL: 'http://example.com' 352 documentLoaderURL: 'http://example.com'
402 }); 353 });
403 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 354 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
404 cat: 'loading', 355 cat: 'loading',
405 title: 'markAsMainFrame',
406 start: 300,
407 duration: 0.0,
408 args: {frame: '0xdeadbeef'}
409 }));
410 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
411 cat: 'loading',
412 title: 'firstMeaningfulPaintCandidate', 356 title: 'firstMeaningfulPaintCandidate',
413 start: 600, 357 start: 600,
414 duration: 0.0, 358 duration: 0.0,
415 cpuStart: 1280, 359 cpuStart: 1280,
416 cpuDuration: 0, 360 cpuDuration: 0,
417 args: {frame: '0xdeadbeef'} 361 args: {frame: '0xdeadbeef'}
418 })); 362 }));
419 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 363 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
420 cat: 'toplevel', 364 cat: 'toplevel',
421 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', 365 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 start: 200, 400 start: 200,
457 duration: 0.0, 401 duration: 0.0,
458 args: {frame: '0xdeadbeef'} 402 args: {frame: '0xdeadbeef'}
459 })); 403 }));
460 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 404 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
461 { 405 {
462 isLoadingMainFrame: true, 406 isLoadingMainFrame: true,
463 frame: {id_ref: '0xdeadbeef'}, 407 frame: {id_ref: '0xdeadbeef'},
464 documentLoaderURL: 'http://example.com' 408 documentLoaderURL: 'http://example.com'
465 }); 409 });
466 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
467 cat: 'loading',
468 title: 'markAsMainFrame',
469 start: 300,
470 duration: 0.0,
471 args: {frame: '0xdeadbeef'}
472 }));
473 410
474 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 411 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
475 cat: 'loading', 412 cat: 'loading',
476 title: 'firstMeaningfulPaintCandidate', 413 title: 'firstMeaningfulPaintCandidate',
477 start: 9180, 414 start: 9180,
478 duration: 0.0, 415 duration: 0.0,
479 args: {frame: '0xdeadbeef'} 416 args: {frame: '0xdeadbeef'}
480 })); 417 }));
481 418
482 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 419 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 args: {frame: '0xdeadbeef'} 494 args: {frame: '0xdeadbeef'}
558 })); 495 }));
559 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 496 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
560 { 497 {
561 isLoadingMainFrame: true, 498 isLoadingMainFrame: true,
562 frame: {id_ref: '0xdeadbeef'}, 499 frame: {id_ref: '0xdeadbeef'},
563 documentLoaderURL: 'http://example.com' 500 documentLoaderURL: 'http://example.com'
564 }); 501 });
565 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 502 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
566 cat: 'loading', 503 cat: 'loading',
567 title: 'markAsMainFrame',
568 start: 300,
569 duration: 0.0,
570 args: {frame: '0xdeadbeef'}
571 }));
572 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
573 cat: 'loading',
574 title: 'firstMeaningfulPaintCandidate', 504 title: 'firstMeaningfulPaintCandidate',
575 start: 9180, 505 start: 9180,
576 duration: 0.0, 506 duration: 0.0,
577 args: {frame: '0xdeadbeef'} 507 args: {frame: '0xdeadbeef'}
578 })); 508 }));
579 509
580 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 510 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
581 cat: 'loading', 511 cat: 'loading',
582 title: 'firstMeaningfulPaintCandidate', 512 title: 'firstMeaningfulPaintCandidate',
583 start: 9200, 513 start: 9200,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 duration: 0.0, 586 duration: 0.0,
657 args: {frame: '0xdeadbeef'} 587 args: {frame: '0xdeadbeef'}
658 })); 588 }));
659 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, 589 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
660 { 590 {
661 isLoadingMainFrame: true, 591 isLoadingMainFrame: true,
662 frame: {id_ref: '0xdeadbeef'}, 592 frame: {id_ref: '0xdeadbeef'},
663 documentLoaderURL: 'http://example.com' 593 documentLoaderURL: 'http://example.com'
664 }); 594 });
665 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 595 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
666 cat: 'loading',
667 title: 'markAsMainFrame',
668 start: 300,
669 duration: 0.0,
670 args: {frame: '0xdeadbeef'}
671 }));
672 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
673 cat: 'loading,rail,devtools.timeline', 596 cat: 'loading,rail,devtools.timeline',
674 title: 'firstContentfulPaint', 597 title: 'firstContentfulPaint',
675 start: 600, 598 start: 600,
676 duration: 0.0, 599 duration: 0.0,
677 args: {frame: '0xdeadbeef'} 600 args: {frame: '0xdeadbeef'}
678 })); 601 }));
679 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 602 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
680 cat: 'loading', 603 cat: 'loading',
681 title: 'firstMeaningfulPaintCandidate', 604 title: 'firstMeaningfulPaintCandidate',
682 start: 1000, 605 start: 1000,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 [netEvent1, netEvent2], 708 [netEvent1, netEvent2],
786 partialNetworkEvents); 709 partialNetworkEvents);
787 710
788 const networkEventsWithIntersecting = 711 const networkEventsWithIntersecting =
789 tr.metrics.sh.getNetworkEventsInRange( 712 tr.metrics.sh.getNetworkEventsInRange(
790 rendererHelper.process, tr.b.math.Range.fromExplicitRange(0, 410)); 713 rendererHelper.process, tr.b.math.Range.fromExplicitRange(0, 410));
791 assert.sameDeepMembers( 714 assert.sameDeepMembers(
792 [netEvent1, netEvent2], 715 [netEvent1, netEvent2],
793 partialNetworkEvents); 716 partialNetworkEvents);
794 }); 717 });
795
796 test('MainFrameHelper_isMainFrame_inLiveRange', function() {
797 // The FrameLoader loads a frame 0xdeadbeef at 300ms.
798 // The frame 0xdeadbeef is marked as the main frame at 300ms.
799 // The isMainFrame('0xdeadbeef', 300) check is expected to succeed.
800 const model = tr.c.TestUtils.newModel(function(model) {
801 const process = model.getOrCreateProcess(1);
802 const rendererThread = process.getOrCreateThread(2);
803 rendererThread.name = 'CrRendererMain';
804 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
805 {
806 isLoadingMainFrame: true,
807 frame: {id_ref: '0xdeadbeef'},
808 documentLoaderURL: 'http://example.com'
809 });
810 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
811 cat: 'loading',
812 title: 'markAsMainFrame',
813 start: 300,
814 duration: 0.0,
815 args: {frame: '0xdeadbeef'}
816 }));
817 });
818 const rendererHelper = model.getOrCreateHelper(
819 tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
820 const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
821 assert(mainFrameHelper.isMainFrame('0xdeadbeef', 300));
822 });
823
824 test('MainFrameHelper_isMainFrame_outsideLiveRange', function() {
825 // The FrameLoader loads a frame 0xdeadbeef at 300ms.
826 // The frame 0xdeadbeef is marked as the main frame at 300ms.
827 // The isMainFrame('0xdeadbeef', 500) check is expected to fail.
828 const model = tr.c.TestUtils.newModel(function(model) {
829 const process = model.getOrCreateProcess(1);
830 const rendererThread = process.getOrCreateThread(2);
831 rendererThread.name = 'CrRendererMain';
832 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
833 {
834 isLoadingMainFrame: true,
835 frame: {id_ref: '0xdeadbeef'},
836 documentLoaderURL: 'http://example.com'
837 });
838 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
839 cat: 'loading',
840 title: 'markAsMainFrame',
841 start: 300,
842 duration: 0.0,
843 args: {frame: '0xdeadbeef'}
844 }));
845 });
846 const rendererHelper = model.getOrCreateHelper(
847 tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
848 const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
849 assert.isFalse(mainFrameHelper.isMainFrame('0xdeadbeef', 500));
850 });
851
852 test('MainFrameHelper_isMainFrame_pluginFrame', function() {
853 // The FrameLoader loads a plugin frame 0xdeadbeef at 300ms.
854 // The frame 0xdeadbeef is marked as the main frame at 300ms.
855 // The isMainFrame('0xdeadbeef', 300) check is expected to fail because the
856 // frame is a plugin frame.
857 const model = tr.c.TestUtils.newModel(function(model) {
858 const process = model.getOrCreateProcess(1);
859 const rendererThread = process.getOrCreateThread(2);
860 rendererThread.name = 'CrRendererMain';
861 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
862 {
863 isLoadingMainFrame: true,
864 frame: {id_ref: '0xdeadbeef'},
865 documentLoaderURL: 'data:text/html,pluginplaceholderdata'
866 });
867 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
868 cat: 'loading',
869 title: 'markAsMainFrame',
870 start: 300,
871 duration: 0.0,
872 args: {frame: '0xdeadbeef'}
873 }));
874 });
875 const rendererHelper = model.getOrCreateHelper(
876 tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
877 const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
878 assert.isFalse(mainFrameHelper.isMainFrame('0xdeadbeef', 300));
879 });
880
881 test('MainFrameHelper_isMainFrame_unmarked', function() {
882 // The FrameLoader loads a frame 0xdeadbeef at 300ms.
883 // A frame 0x00000000 is marked as the main frame at 300ms.
884 // The isMainFrame('0xdeadbeef', 300) check is expected to fail.
885 const model = tr.c.TestUtils.newModel(function(model) {
886 const process = model.getOrCreateProcess(1);
887 const rendererThread = process.getOrCreateThread(2);
888 rendererThread.name = 'CrRendererMain';
889 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
890 {
891 isLoadingMainFrame: true,
892 frame: {id_ref: '0xdeadbeef'},
893 documentLoaderURL: 'http://example.com'
894 });
895 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
896 cat: 'loading',
897 title: 'markAsMainFrame',
898 start: 300,
899 duration: 0.0,
900 args: {frame: '0x00000000'}
901 }));
902 });
903 const rendererHelper = model.getOrCreateHelper(
904 tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
905 const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
906 assert.isFalse(mainFrameHelper.isMainFrame('0xdeadbeef', 300));
907 });
908
909 test('MainFrameHelper_getURL', function() {
910 // The FrameLoader loads http://example.com to frame 0xdeadbeef at 300ms.
911 // The frame 0xdeadbeef is marked as the main frame at 300ms.
912 // getURL('0xdeadbeef', 300) is expected to return http://example.com.
913 const model = tr.c.TestUtils.newModel(function(model) {
914 const process = model.getOrCreateProcess(1);
915 const rendererThread = process.getOrCreateThread(2);
916 rendererThread.name = 'CrRendererMain';
917 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
918 {
919 isLoadingMainFrame: true,
920 frame: {id_ref: '0xdeadbeef'},
921 documentLoaderURL: 'http://example.com'
922 });
923 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
924 cat: 'loading',
925 title: 'markAsMainFrame',
926 start: 300,
927 duration: 0.0,
928 args: {frame: '0xdeadbeef'}
929 }));
930 });
931 const rendererHelper = model.getOrCreateHelper(
932 tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
933 const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
934 assert.strictEqual(mainFrameHelper.getURL('0xdeadbeef', 300),
935 'http://example.com');
936 });
937
938 test('MainFrameHelper_getURL_undefined', function() {
939 // The FrameLoader loads http://example.com to frame 0xdeadbeef at 300ms.
940 // The frame 0xdeadbeef is marked as the main frame at 300ms.
941 // getURL('0x00000000', 300) is expected to return the undefined value.
942 const model = tr.c.TestUtils.newModel(function(model) {
943 const process = model.getOrCreateProcess(1);
944 const rendererThread = process.getOrCreateThread(2);
945 rendererThread.name = 'CrRendererMain';
946 process.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
947 {
948 isLoadingMainFrame: true,
949 frame: {id_ref: '0xdeadbeef'},
950 documentLoaderURL: 'http://example.com'
951 });
952 rendererThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
953 cat: 'loading',
954 title: 'markAsMainFrame',
955 start: 300,
956 duration: 0.0,
957 args: {frame: '0xdeadbeef'}
958 }));
959 });
960 const rendererHelper = model.getOrCreateHelper(
961 tr.model.helpers.ChromeModelHelper).rendererHelpers[1];
962 const mainFrameHelper = new tr.metrics.sh.MainFrameHelper(rendererHelper);
963 assert.strictEqual(mainFrameHelper.getURL('0x00000000', 300), undefined);
964 });
965 }); 718 });
966 </script> 719 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698