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

Side by Side Diff: LayoutTests/inspector/tracing/timeline-layout-invalidations.html

Issue 465223002: [ Do not submit ] Prototype for invalidation analysis Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update for review: cleanup sloppy algorithms, update tests Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../http/tests/inspector/timeline-test.js"></script>
6 <script>
7 function display(callback)
8 {
9 requestAnimationFrame(function() {
10 document.body.style.backgroundColor = "blue";
11 document.getElementsByTagName('p')[0].style.width = "100px";
12 var forceLayout = document.body.offsetTop;
13 if (window.testRunner)
14 testRunner.displayAsyncThen(callback);
15 });
16 }
17
18 function updateSubframeAndDisplay(callback)
19 {
20 requestAnimationFrame(function() {
21 frames[0].document.body.children[0].style.width = "200px";
22 var forceLayout = document.body.offsetTop;
23 if (window.testRunner)
24 testRunner.displayAsyncThen(callback);
25 });
26 }
27
28 function test()
29 {
30 var currentPanel = WebInspector.inspectorView.currentPanel();
31 InspectorTest.assertEquals(currentPanel._panelName, "timeline", "Current pan el should be the timeline.");
32 Runtime.experiments.enableForTest("timelineInvalidationTracking");
33
34 InspectorTest.runTestSuite([
35 function testLocalFrame(next)
36 {
37 InspectorTest.invokeAsyncWithTimeline("display", function() {
38 var record = InspectorTest.findFirstTimelineRecord(WebInspector. TimelineModel.RecordType.Paint);
39 var invalidations = record._event.invalidationTrackingEvents;
40 InspectorTest.assertEquals(invalidations.length, 3);
41 InspectorTest.assertEquals(invalidations[0].type, WebInspector.T racingTimelineModel.RecordType.StyleRecalcInvalidationTracking);
42 InspectorTest.assertEquals(invalidations[0].nodeName, "BODY");
43 InspectorTest.assertEquals(invalidations[1].type, WebInspector.T racingTimelineModel.RecordType.StyleRecalcInvalidationTracking);
44 InspectorTest.assertEquals(invalidations[1].nodeName, "P");
45 InspectorTest.assertEquals(invalidations[2].type, WebInspector.T racingTimelineModel.RecordType.LayoutInvalidationTracking);
46 InspectorTest.assertEquals(invalidations[2].nodeName, "P");
47 InspectorTest.assertGreaterOrEqual(invalidations[2].callstack.le ngth, 1);
48 InspectorTest.invokeAsyncWithTimeline("updateSubframeAndDisplay" , next);
49 });
50 },
51
52 function testSubframe(next)
53 {
54 var firstPaintRecord = InspectorTest.findFirstTimelineRecord(WebInsp ector.TimelineModel.RecordType.Paint);
55 var secondPaintRecord = undefined;
56
57 function findSecondPaint(record)
58 {
59 if (record.type() !== WebInspector.TimelineModel.RecordType.Pain t)
60 return false;
61 if (record === firstPaintRecord)
62 return false;
63 secondPaintRecord = record;
64 return true;
65 }
66 InspectorTest.timelineModel().forAllRecords(findSecondPaint);
67
68 // The first paint corresponds to the local frame and should have no invalidations.
69 var firstInvalidations = firstPaintRecord._event.invalidationTrackin gEvents;
70 InspectorTest.assertEquals(firstInvalidations, undefined);
71
72 // The second paint corresponds to the subframe and should have our layout/style invalidations.
73 var secondInvalidations = secondPaintRecord._event.invalidationTrack ingEvents;
74 InspectorTest.assertEquals(secondInvalidations.length, 3);
75 InspectorTest.assertEquals(secondInvalidations[0].type, WebInspector .TracingTimelineModel.RecordType.StyleRecalcInvalidationTracking);
76 InspectorTest.assertEquals(secondInvalidations[0].nodeName, "DIV");
77 InspectorTest.assertEquals(secondInvalidations[1].type, WebInspector .TracingTimelineModel.RecordType.LayoutInvalidationTracking);
78 InspectorTest.assertEquals(secondInvalidations[1].nodeName, "DIV");
79 InspectorTest.assertGreaterOrEqual(secondInvalidations[1].callstack. length, 1);
80 InspectorTest.assertEquals(secondInvalidations[2].type, WebInspector .TracingTimelineModel.RecordType.LayoutInvalidationTracking);
81 InspectorTest.assertEquals(secondInvalidations[2].nodeName, "#docume nt");
82 InspectorTest.assertGreaterOrEqual(secondInvalidations[2].callstack. length, 1);
83 next();
84 }
85 ]);
86 }
87 </script>
88 </head>
89 <body onload="runTest()">
90 <p>Tests the Timeline API instrumentation of layout invalidations.</p>
91 <iframe src="resources/timeline-iframe-paint.html" style="position: absolute; le ft: 40px; top: 40px; width: 100px; height: 100px; border: none"></iframe>
92 </body>
93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698