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.backgroundColor = "salmon"; | |
12 if (window.testRunner) | |
13 testRunner.displayAsyncThen(callback); | |
14 }); | |
15 } | |
16 | |
17 function updateSubframeAndDisplay(callback) | |
18 { | |
19 requestAnimationFrame(function() { | |
20 frames[0].document.body.children[0].style.backgroundColor = "green"; | |
21 if (window.testRunner) | |
22 testRunner.displayAsyncThen(callback); | |
23 }); | |
24 } | |
25 | |
26 function test() | |
27 { | |
28 var currentPanel = WebInspector.inspectorView.currentPanel(); | |
29 InspectorTest.assertEquals(currentPanel._panelName, "timeline", "Current pan
el should be the timeline."); | |
30 Runtime.experiments.enableForTest("timelineInvalidationTracking"); | |
31 | |
32 InspectorTest.runTestSuite([ | |
33 function testLocalFrame(next) | |
34 { | |
35 InspectorTest.invokeAsyncWithTimeline("display", function() { | |
36 var record = InspectorTest.findFirstTimelineRecord(WebInspector.
TimelineModel.RecordType.Paint); | |
37 var invalidations = record._event.invalidationTrackingEvents; | |
38 InspectorTest.assertEquals(invalidations.length, 2); | |
39 InspectorTest.assertEquals(invalidations[0].type, WebInspector.T
racingTimelineModel.RecordType.StyleRecalcInvalidationTracking); | |
40 InspectorTest.assertEquals(invalidations[0].nodeName, "BODY"); | |
41 InspectorTest.assertEquals(invalidations[0].reason, "StyleSheetC
hange"); | |
42 InspectorTest.assertEquals(invalidations[1].type, WebInspector.T
racingTimelineModel.RecordType.StyleRecalcInvalidationTracking); | |
43 InspectorTest.assertEquals(invalidations[1].nodeName, "DIV id='t
estElement'"); | |
44 InspectorTest.assertEquals(invalidations[1].reason, "StyleSheetC
hange"); | |
45 InspectorTest.invokeAsyncWithTimeline("updateSubframeAndDisplay"
, next); | |
46 }); | |
47 }, | |
48 | |
49 function testSubframe(next) | |
50 { | |
51 var firstPaintRecord = InspectorTest.findFirstTimelineRecord(WebInsp
ector.TimelineModel.RecordType.Paint); | |
52 var secondPaintRecord = undefined; | |
53 | |
54 function findSecondPaint(record) | |
55 { | |
56 if (record.type() !== WebInspector.TimelineModel.RecordType.Pain
t) | |
57 return false; | |
58 if (record === firstPaintRecord) | |
59 return false; | |
60 secondPaintRecord = record; | |
61 return true; | |
62 } | |
63 | |
64 InspectorTest.timelineModel().forAllRecords(findSecondPaint); | |
65 | |
66 // The first paint corresponds to the local frame and should have no
invalidations. | |
67 var firstInvalidations = firstPaintRecord._event.invalidationTrackin
gEvents; | |
68 InspectorTest.assertEquals(firstInvalidations, undefined); | |
69 | |
70 // The second paint corresponds to the subframe and should have our
style invalidations. | |
71 var secondInvalidations = secondPaintRecord._event.invalidationTrack
ingEvents; | |
72 InspectorTest.assertEquals(secondInvalidations.length, 1); | |
73 InspectorTest.assertEquals(secondInvalidations[0].type, WebInspector
.TracingTimelineModel.RecordType.StyleRecalcInvalidationTracking); | |
74 InspectorTest.assertEquals(secondInvalidations[0].nodeName, "DIV"); | |
75 InspectorTest.assertEquals(secondInvalidations[0].reason, "StyleShee
tChange"); | |
76 next(); | |
77 } | |
78 ]); | |
79 } | |
80 </script> | |
81 </head> | |
82 <body onload="runTest()"> | |
83 <p>Tests the Timeline API instrumentation of style recalc invalidations.</p> | |
84 <div id="testElement">PASS</div> | |
85 <iframe src="resources/timeline-iframe-paint.html" style="position: absolute; le
ft: 40px; top: 40px; width: 100px; height: 100px; border: none"></iframe> | |
86 </body> | |
87 </html> | |
OLD | NEW |