OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../http/tests/inspector/timeline-test.js"></script> |
| 5 <script> |
| 6 function test() |
| 7 { |
| 8 function checkStringContains(string, contains) |
| 9 { |
| 10 var doesContain = string.indexOf(contains) >= 0; |
| 11 InspectorTest.check(doesContain, contains + " should be present in " + s
tring); |
| 12 InspectorTest.addResult("PASS - record contained " + contains); |
| 13 } |
| 14 |
| 15 InspectorTest.runTestSuite([ |
| 16 function testTimerInstall(next) |
| 17 { |
| 18 function setTimeoutFunction(callback) |
| 19 { |
| 20 setTimeout(callback, 0); |
| 21 } |
| 22 |
| 23 var source = setTimeoutFunction.toString(); |
| 24 source += "\n//@ sourceURL=setTimeoutFunction.js"; |
| 25 InspectorTest.evaluateInPage(source); |
| 26 |
| 27 InspectorTest.invokeAsyncWithTimeline("setTimeoutFunction", finishAn
dRunNextTest); |
| 28 function finishAndRunNextTest() |
| 29 { |
| 30 var linkifier = new WebInspector.Linkifier(); |
| 31 var record = InspectorTest.findFirstTimelineRecord("TimerFire"); |
| 32 InspectorTest.check(record, "Should receive a TimerFire record."
); |
| 33 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(record.traceEvent().thread.target(), linkifier, true); |
| 34 WebInspector.TracingTimelineUIUtils._generateCauses(record.trace
Event(), contentHelper); |
| 35 var causes = contentHelper.element.textContent; |
| 36 InspectorTest.check(causes, "Should generate causes"); |
| 37 checkStringContains(causes, "Timer installed: setTimeoutFunction
@ setTimeoutFunction.js:"); |
| 38 next(); |
| 39 } |
| 40 }, |
| 41 |
| 42 function testRequestAnimationFrame(next) |
| 43 { |
| 44 function requestAnimationFrameFunction(callback) |
| 45 { |
| 46 requestAnimationFrame(callback); |
| 47 } |
| 48 |
| 49 var source = requestAnimationFrameFunction.toString(); |
| 50 source += "\n//@ sourceURL=requestAnimationFrameFunction.js"; |
| 51 InspectorTest.evaluateInPage(source); |
| 52 |
| 53 InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction
", finishAndRunNextTest); |
| 54 function finishAndRunNextTest() |
| 55 { |
| 56 var linkifier = new WebInspector.Linkifier(); |
| 57 var record = InspectorTest.findFirstTimelineRecord("FireAnimatio
nFrame"); |
| 58 InspectorTest.check(record, "Should receive a FireAnimationFrame
record."); |
| 59 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(record.traceEvent().thread.target(), linkifier, true); |
| 60 WebInspector.TracingTimelineUIUtils._generateCauses(record.trace
Event(), contentHelper); |
| 61 var causes = contentHelper.element.textContent; |
| 62 InspectorTest.check(causes, "Should generate causes"); |
| 63 checkStringContains(causes, "Animation frame requested: requestA
nimationFrameFunction @ requestAnimationFrameFunction.js:"); |
| 64 next(); |
| 65 } |
| 66 }, |
| 67 |
| 68 function testStyleRecalc(next) |
| 69 { |
| 70 function styleRecalcFunction(callback) |
| 71 { |
| 72 var element = document.getElementById("testElement"); |
| 73 element.style.backgroundColor = "papayawhip"; |
| 74 callback(); |
| 75 } |
| 76 |
| 77 var source = styleRecalcFunction.toString(); |
| 78 source += "\n//@ sourceURL=styleRecalcFunction.js"; |
| 79 InspectorTest.evaluateInPage(source); |
| 80 |
| 81 InspectorTest.invokeAsyncWithTimeline("styleRecalcFunction", finishA
ndRunNextTest); |
| 82 function finishAndRunNextTest() |
| 83 { |
| 84 var linkifier = new WebInspector.Linkifier(); |
| 85 var record = InspectorTest.findFirstTimelineRecord("RecalculateS
tyles"); |
| 86 InspectorTest.check(record, "Should receive a RecalculateStyles
record."); |
| 87 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(record.traceEvent().thread.target(), linkifier, true); |
| 88 WebInspector.TracingTimelineUIUtils._generateCauses(record.trace
Event(), contentHelper); |
| 89 var causes = contentHelper.element.textContent; |
| 90 InspectorTest.check(causes, "Should generate causes"); |
| 91 checkStringContains(causes, "Stack when first invalidated: style
RecalcFunction @ styleRecalcFunction.js:"); |
| 92 next(); |
| 93 } |
| 94 }, |
| 95 |
| 96 function testLayout(next) |
| 97 { |
| 98 function layoutFunction(callback) |
| 99 { |
| 100 var element = document.getElementById("testElement"); |
| 101 element.style.width = "200px"; |
| 102 var forceLayout = element.offsetWidth; |
| 103 callback(); |
| 104 } |
| 105 |
| 106 var source = layoutFunction.toString(); |
| 107 source += "\n//@ sourceURL=layoutFunction.js"; |
| 108 InspectorTest.evaluateInPage(source); |
| 109 |
| 110 InspectorTest.invokeAsyncWithTimeline("layoutFunction", finishAndRun
NextTest); |
| 111 function finishAndRunNextTest() |
| 112 { |
| 113 var linkifier = new WebInspector.Linkifier(); |
| 114 var record = InspectorTest.findFirstTimelineRecord("Layout"); |
| 115 InspectorTest.check(record, "Should receive a Layout record."); |
| 116 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(record.traceEvent().thread.target(), linkifier, true); |
| 117 WebInspector.TracingTimelineUIUtils._generateCauses(record.trace
Event(), contentHelper); |
| 118 var causes = contentHelper.element.textContent; |
| 119 InspectorTest.check(causes, "Should generate causes"); |
| 120 checkStringContains(causes, "Stack when layout was forced: layou
tFunction @ layoutFunction.js:"); |
| 121 checkStringContains(causes, "First layout invalidation: layoutFu
nction @ layoutFunction.js:"); |
| 122 next(); |
| 123 } |
| 124 } |
| 125 ]); |
| 126 } |
| 127 </script> |
| 128 </head> |
| 129 |
| 130 <body onload="runTest()"> |
| 131 <p> |
| 132 Test that causes are correctly generated for various types of events. |
| 133 </p> |
| 134 <div id="testElement"></div> |
| 135 </body> |
| 136 </html> |
OLD | NEW |