OLD | NEW |
| (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.getElementById("testElement").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 = frames[0].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, "DIV id='t
estElement'"); | |
45 InspectorTest.assertEquals(invalidations[2].type, WebInspector.T
racingTimelineModel.RecordType.LayoutInvalidationTracking); | |
46 InspectorTest.assertEquals(invalidations[2].nodeName, "DIV id='t
estElement'"); | |
47 InspectorTest.assertGreaterOrEqual(invalidations[2].stackTrace.l
ength, 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].stackTrace
.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].stackTrace
.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 <div id="testElement">PASS</div> | |
92 <iframe src="resources/timeline-iframe-paint.html" style="position: absolute; le
ft: 40px; top: 40px; width: 100px; height: 100px; border: none"></iframe> | |
93 </body> | |
94 </html> | |
OLD | NEW |