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.getElementsByTagName('p')[0].style.borderWidth = "1px"; |
| 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, 1); |
| 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.invokeAsyncWithTimeline("updateSubframeAndDisplay"
, next); |
| 43 }); |
| 44 }, |
| 45 |
| 46 function testSubframe(next) |
| 47 { |
| 48 var firstPaintRecord = InspectorTest.findFirstTimelineRecord(WebInsp
ector.TimelineModel.RecordType.Paint); |
| 49 var secondPaintRecord = undefined; |
| 50 |
| 51 function findSecondPaint(record) |
| 52 { |
| 53 if (record.type() !== WebInspector.TimelineModel.RecordType.Pain
t) |
| 54 return false; |
| 55 if (record === firstPaintRecord) |
| 56 return false; |
| 57 secondPaintRecord = record; |
| 58 return true; |
| 59 } |
| 60 |
| 61 InspectorTest.timelineModel().forAllRecords(findSecondPaint); |
| 62 |
| 63 // The first paint corresponds to the local frame and should have no
invalidations. |
| 64 var firstInvalidations = firstPaintRecord._event.invalidationTrackin
gEvents; |
| 65 InspectorTest.assertEquals(firstInvalidations, undefined); |
| 66 |
| 67 // The second paint corresponds to the subframe and should have our
style invalidations. |
| 68 var secondInvalidations = secondPaintRecord._event.invalidationTrack
ingEvents; |
| 69 InspectorTest.assertEquals(secondInvalidations.length, 1); |
| 70 InspectorTest.assertEquals(secondInvalidations[0].type, WebInspector
.TracingTimelineModel.RecordType.StyleRecalcInvalidationTracking); |
| 71 InspectorTest.assertEquals(secondInvalidations[0].nodeName, "DIV"); |
| 72 InspectorTest.assertEquals(secondInvalidations[0].reason, "StyleShee
tChange"); |
| 73 next(); |
| 74 } |
| 75 ]); |
| 76 } |
| 77 </script> |
| 78 </head> |
| 79 <body onload="runTest()"> |
| 80 <p>Tests the Timeline API instrumentation of style recalc invalidations.</p> |
| 81 <iframe src="resources/timeline-iframe-paint.html" style="position: absolute; le
ft: 40px; top: 40px; width: 100px; height: 100px; border: none"></iframe> |
| 82 </body> |
| 83 </html> |
OLD | NEW |