Chromium Code Reviews| Index: LayoutTests/inspector/tracing/timeline-event-causes.html |
| diff --git a/LayoutTests/inspector/tracing/timeline-event-causes.html b/LayoutTests/inspector/tracing/timeline-event-causes.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e9e3176e53f62327a05dde0817603603567de302 |
| --- /dev/null |
| +++ b/LayoutTests/inspector/tracing/timeline-event-causes.html |
| @@ -0,0 +1,123 @@ |
| +<html> |
| +<head> |
| +<script src="../../http/tests/inspector/inspector-test.js"></script> |
| +<script src="../../http/tests/inspector/timeline-test.js"></script> |
| +<script> |
| +function test() |
| +{ |
| + function checkStringContains(string, contains) |
| + { |
| + var doesContain = string.indexOf(contains) >= 0; |
| + InspectorTest.check(doesContain, contains + " should be present in " + string); |
| + InspectorTest.addResult("PASS - record contained " + contains); |
| + } |
| + |
| + function testTimerInstall() |
| + { |
| + function setTimeoutFunction(callback) { |
|
caseq
2014/10/07 09:50:07
{ => next line
pdr.
2014/10/08 06:06:20
Done (here, and the others).
|
| + setTimeout(callback, 0); |
| + } |
| + |
| + var source = setTimeoutFunction.toString(); |
| + source += "\n//@ sourceURL=setTimeoutFunction.js"; |
| + InspectorTest.evaluateInPage(source); |
| + |
| + InspectorTest.invokeAsyncWithTimeline("setTimeoutFunction", finishAndRunNextTest); |
| + function finishAndRunNextTest() { |
|
caseq
2014/10/07 09:50:07
ditto
|
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("TimerFire"); |
| + InspectorTest.check(record, "Should receive a TimerFire record."); |
| + var causes = WebInspector.TracingTimelineUIUtils.generateCauses(record.traceEvent(), linkifier); |
| + InspectorTest.check(causes && causes.textContent, "Should generate causes"); |
| + checkStringContains(causes.textContent, "Timer installed: setTimeoutFunction @ setTimeoutFunction.js:"); |
| + testRequestAnimationFrame(); |
|
caseq
2014/10/07 09:50:07
You probably want to use InspectorTest.runTestSuit
pdr.
2014/10/08 06:06:20
Done.
|
| + } |
| + } |
| + |
| + function testRequestAnimationFrame() |
| + { |
| + function requestAnimationFrameFunction(callback) { |
|
caseq
2014/10/07 09:50:07
{ => next line
|
| + requestAnimationFrame(function() { |
|
caseq
2014/10/07 09:50:07
Drop the "function() { }", just "callback", it's c
pdr.
2014/10/08 06:06:20
Done :)
|
| + callback(); |
| + }); |
| + } |
| + |
| + var source = requestAnimationFrameFunction.toString(); |
| + source += "\n//@ sourceURL=requestAnimationFrameFunction.js"; |
| + InspectorTest.evaluateInPage(source); |
| + |
| + InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction", finishAndRunNextTest); |
| + function finishAndRunNextTest() { |
|
caseq
2014/10/07 09:50:07
{ => next line
|
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("FireAnimationFrame"); |
| + InspectorTest.check(record, "Should receive a FireAnimationFrame record."); |
| + var causes = WebInspector.TracingTimelineUIUtils.generateCauses(record.traceEvent(), linkifier); |
| + InspectorTest.check(causes && causes.textContent, "Should generate causes"); |
| + checkStringContains(causes.textContent, "Animation frame requested: requestAnimationFrameFunction @ requestAnimationFrameFunction.js:"); |
| + testStyleRecalc(); |
| + } |
| + } |
| + |
| + function testStyleRecalc() |
| + { |
| + function styleRecalcFunction(callback) { |
|
caseq
2014/10/07 09:50:07
ditto
|
| + var element = document.getElementById("testElement"); |
| + element.style.backgroundColor = "papayawhip"; |
| + callback(); |
| + } |
| + |
| + var source = styleRecalcFunction.toString(); |
| + source += "\n//@ sourceURL=styleRecalcFunction.js"; |
| + InspectorTest.evaluateInPage(source); |
| + |
| + InspectorTest.invokeAsyncWithTimeline("styleRecalcFunction", finishAndRunNextTest); |
| + function finishAndRunNextTest() { |
|
caseq
2014/10/07 09:50:07
ditto
|
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("RecalculateStyles"); |
| + InspectorTest.check(record, "Should receive a RecalculateStyles record."); |
| + var causes = WebInspector.TracingTimelineUIUtils.generateCauses(record.traceEvent(), linkifier); |
| + InspectorTest.check(causes && causes.textContent, "Should generate causes"); |
| + checkStringContains(causes.textContent, "Stack when first invalidated: styleRecalcFunction @ styleRecalcFunction.js:"); |
| + testLayout(); |
| + } |
| + } |
| + |
| + function testLayout() |
| + { |
| + function layoutFunction(callback) { |
|
caseq
2014/10/07 09:50:07
ditto
|
| + var element = document.getElementById("testElement"); |
| + element.style.width = "200px"; |
| + var forceLayout = element.offsetWidth; |
| + callback(); |
| + } |
| + |
| + var source = layoutFunction.toString(); |
| + source += "\n//@ sourceURL=layoutFunction.js"; |
| + InspectorTest.evaluateInPage(source); |
| + |
| + InspectorTest.invokeAsyncWithTimeline("layoutFunction", finishAndRunNextTest); |
| + function finishAndRunNextTest() { |
|
caseq
2014/10/07 09:50:07
ditto
|
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("Layout"); |
| + InspectorTest.check(record, "Should receive a Layout record."); |
| + var causes = WebInspector.TracingTimelineUIUtils.generateCauses(record.traceEvent(), linkifier); |
| + InspectorTest.check(causes && causes.textContent, "Should generate causes"); |
| + checkStringContains(causes.textContent, "Stack when layout was forced: layoutFunction @ layoutFunction.js:"); |
| + checkStringContains(causes.textContent, "First layout invalidation: layoutFunction @ layoutFunction.js:"); |
| + InspectorTest.completeTest(); |
| + } |
| + } |
| + |
| + // Begin the test. |
| + testTimerInstall(); |
| +} |
| +</script> |
| +</head> |
| + |
| +<body onload="runTest()"> |
| +<p> |
| +Test that causes are correctly generated for various types of events. |
| +</p> |
| +<div id="testElement"></div> |
| +</body> |
| +</html> |