Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: LayoutTests/inspector/tracing/timeline-event-causes.html

Issue 631573002: [Devtools] Replace "Stacks" with "Causes" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Minor cleanup Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698