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..4fc20b25384a3a8d31135ff468d011d356f92138 |
| --- /dev/null |
| +++ b/LayoutTests/inspector/tracing/timeline-event-causes.html |
| @@ -0,0 +1,119 @@ |
| +<html> |
| +<head> |
| +<script src="../../http/tests/inspector/inspector-test.js"></script> |
| +<script src="../../http/tests/inspector/timeline-test.js"></script> |
| +<script> |
| +function test() { |
|
caseq
2014/10/06 12:47:47
style: here and below, { => next line.
pdr.
2014/10/07 04:36:13
Done.
|
| + 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) { |
| + setTimeout(function() { |
|
caseq
2014/10/06 12:47:47
just setTimeout(callback, 0) perhaps?
pdr.
2014/10/07 04:36:13
Done.
|
| + callback(); |
| + }, 0); |
| + } |
| + |
| + var source = setTimeoutFunction.toString(); |
| + source += "\n//@ sourceURL=setTimeoutFunction.js"; |
| + InspectorTest.evaluateInPage(source); |
| + |
| + InspectorTest.invokeAsyncWithTimeline("setTimeoutFunction", finishAndRunNextTest); |
| + function finishAndRunNextTest() { |
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("TimerFire"); |
| + InspectorTest.check(record, "Should receive a TimerFire record."); |
| + WebInspector.TracingTimelineUIUtils.generateCausesContent(record.traceEvent(), linkifier, function(result) { |
| + checkStringContains(result.textContent, "Timer installed: setTimeoutFunction @ setTimeoutFunction.js:"); |
| + testRequestAnimationFrame(); |
| + }); |
| + } |
| + } |
| + |
| + function testRequestAnimationFrame() { |
| + function requestAnimationFrameFunction(callback) { |
| + requestAnimationFrame(function() { |
| + callback(); |
| + }); |
| + } |
| + |
| + var source = requestAnimationFrameFunction.toString(); |
| + source += "\n//@ sourceURL=requestAnimationFrameFunction.js"; |
| + InspectorTest.evaluateInPage(source); |
| + |
| + InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction", finishAndRunNextTest); |
| + function finishAndRunNextTest() { |
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("FireAnimationFrame"); |
| + InspectorTest.check(record, "Should receive a FireAnimationFrame record."); |
| + WebInspector.TracingTimelineUIUtils.generateCausesContent(record.traceEvent(), linkifier, function(result) { |
| + checkStringContains(result.textContent, "Animation frame requested: requestAnimationFrameFunction @ requestAnimationFrameFunction.js:"); |
| + testStyleRecalc(); |
| + }); |
| + } |
| + } |
| + |
| + function testStyleRecalc() { |
| + function styleRecalcFunction(callback) { |
| + 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() { |
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("RecalculateStyles"); |
| + InspectorTest.check(record, "Should receive a RecalculateStyles record."); |
| + WebInspector.TracingTimelineUIUtils.generateCausesContent(record.traceEvent(), linkifier, function(result) { |
| + checkStringContains(result.textContent, "Stack when first invalidated: styleRecalcFunction @ styleRecalcFunction.js:"); |
| + testLayout(); |
| + }); |
| + } |
| + } |
| + |
| + function testLayout() { |
| + function layoutFunction(callback) { |
| + 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() { |
| + var linkifier = new WebInspector.Linkifier(); |
| + var record = InspectorTest.findFirstTimelineRecord("Layout"); |
| + InspectorTest.check(record, "Should receive a Layout record."); |
| + WebInspector.TracingTimelineUIUtils.generateCausesContent(record.traceEvent(), linkifier, function(result) { |
| + checkStringContains(result.textContent, "Stack when layout was forced: layoutFunction @ layoutFunction.js:"); |
| + checkStringContains(result.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> |