Title: [143725] trunk/Source/WebKit/chromium
Revision
143725
Author
[email protected]
Date
2013-02-22 05:52:46 -0800 (Fri, 22 Feb 2013)

Log Message

Web Inspector: [Chromium] add a browser test for frames on timeline
https://bugs.webkit.org/show_bug.cgi?id=110592

- factor out timeline recording logic from testPageOverlayUpdate for reuse;
- record timeline while running a simple DOM-based animation;
- assure we have frames and Style Recalc/Layout/Paint events in between.

Reviewed by Yury Semikhatsky.

* src/js/Tests.js:
(.TestSuite.prototype.assertHasKey):
(.TestSuite.prototype.testTimelineFrames.step1):
(.TestSuite.prototype.testTimelineFrames.onTimelineRecorded):
(.TestSuite.prototype.testTimelineFrames):
(.TestSuite.prototype.testPageOverlayUpdate.step4):
(.TestSuite.prototype.testPageOverlayUpdate.onTimelineRecorded):
(.TestSuite.prototype.recordTimeline.addRecord):
(.TestSuite.prototype.recordTimeline.innerAddRecord):
(.TestSuite.prototype.recordTimeline.done):
(.TestSuite.prototype.recordTimeline):
(.TestSuite.prototype.stopTimeline):

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (143724 => 143725)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-02-22 13:50:51 UTC (rev 143724)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-02-22 13:52:46 UTC (rev 143725)
@@ -1,3 +1,27 @@
+2013-02-22  Andrey Kosyakov  <[email protected]>
+
+        Web Inspector: [Chromium] add a browser test for frames on timeline
+        https://bugs.webkit.org/show_bug.cgi?id=110592
+
+        - factor out timeline recording logic from testPageOverlayUpdate for reuse;
+        - record timeline while running a simple DOM-based animation;
+        - assure we have frames and Style Recalc/Layout/Paint events in between.
+
+        Reviewed by Yury Semikhatsky.
+
+        * src/js/Tests.js:
+        (.TestSuite.prototype.assertHasKey):
+        (.TestSuite.prototype.testTimelineFrames.step1):
+        (.TestSuite.prototype.testTimelineFrames.onTimelineRecorded):
+        (.TestSuite.prototype.testTimelineFrames):
+        (.TestSuite.prototype.testPageOverlayUpdate.step4):
+        (.TestSuite.prototype.testPageOverlayUpdate.onTimelineRecorded):
+        (.TestSuite.prototype.recordTimeline.addRecord):
+        (.TestSuite.prototype.recordTimeline.innerAddRecord):
+        (.TestSuite.prototype.recordTimeline.done):
+        (.TestSuite.prototype.recordTimeline):
+        (.TestSuite.prototype.stopTimeline):
+
 2013-02-21  Alec Flett  <[email protected]>
 
         IndexedDB: Implement SharedBuffer version of put() / onSuccess()

Modified: trunk/Source/WebKit/chromium/src/js/Tests.js (143724 => 143725)


--- trunk/Source/WebKit/chromium/src/js/Tests.js	2013-02-22 13:50:51 UTC (rev 143724)
+++ trunk/Source/WebKit/chromium/src/js/Tests.js	2013-02-22 13:52:46 UTC (rev 143725)
@@ -93,6 +93,18 @@
 
 
 /**
+ * HasKey assertion tests that object has given key.
+ * @param {Object} object
+ * @param {string} key
+ */
+TestSuite.prototype.assertHasKey = function(object, key)
+{
+    if (!object.hasOwnProperty(key))
+        this.fail("Expected object to contain key '" + key + "'");
+};
+
+
+/**
  * Contains assertion tests that string contains substring.
  * @param {string} string Outer.
  * @param {string} substring Inner.
@@ -554,29 +566,52 @@
     this.takeControl();
 };
 
-
-// Regression test for http://webk.it/97466
-TestSuite.prototype.testPageOverlayUpdate = function()
+/**
+ * Tests that timeline receives frame signals.
+ */
+TestSuite.prototype.testTimelineFrames = function()
 {
     var test = this;
-    var records = [];
-    var dispatchOnRecordType = {}
 
-    function addRecord(event)
+    function step1()
     {
-        innerAddRecord(event.data);
+        test.recordTimeline(onTimelineRecorded);
+        test.evaluateInConsole_("runTest()", function(){});
     }
 
-    function innerAddRecord(record)
+    function onTimelineRecorded(records)
     {
-        records.push(record);
-        if (typeof dispatchOnRecordType[record.type] === "function")
-            dispatchOnRecordType[record.type](record);
+        var frameCount = 0;
+        var recordsInFrame = {};
 
-        if (record.children)
-            record.children.forEach(innerAddRecord);
+        for (var i = 0; i < records.length; ++i) {
+            var record = records[i];
+            if (record.type !== "BeginFrame") {
+                recordsInFrame[record.type] = (recordsInFrame[record.type] || 0) + 1;
+                continue;
+            }
+            if (!frameCount++)
+                continue;
+            
+            test.assertHasKey(recordsInFrame, "FireAnimationFrame");
+            test.assertHasKey(recordsInFrame, "Layout");
+            test.assertHasKey(recordsInFrame, "RecalculateStyles");
+            test.assertHasKey(recordsInFrame, "Paint");
+            recordsInFrame = {};
+        }
+        test.assertTrue(frameCount >= 5, "Not enough frames");
+        test.releaseControl();
     }
 
+    step1();
+    test.takeControl();
+}
+
+// Regression test for http://webk.it/97466
+TestSuite.prototype.testPageOverlayUpdate = function()
+{
+    var test = this;
+
     function populatePage()
     {
         var div1 = document.createElement("div");
@@ -591,9 +626,7 @@
 
     function step1()
     {
-        WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addRecord);
-        WebInspector.timelineManager.start();
-
+        test.recordTimeline(onTimelineRecorded);
         test.evaluateInConsole_(populatePage.toString() + "; populatePage();" +
                                 "inspect(document.getElementById('div1'))", function() {});
         WebInspector.notifications.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, step2);
@@ -614,15 +647,12 @@
     function step4()
     {
         WebInspector.notifications.removeEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, step4);
-        dispatchOnRecordType.TimeStamp = step5;
-        test.evaluateInConsole_("console.timeStamp('ready')", function() {});
+        test.stopTimeline();
     }
 
-    function step5()
+    function onTimelineRecorded(records)
     {
         var types = {};
-        WebInspector.timelineManager.stop();
-        WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addRecord);
         for (var i = 0; i < records.length; ++i)
             types[records[i].type] = (types[records[i].type] || 0) + 1;
 
@@ -639,6 +669,48 @@
     this.takeControl();
 }
 
+
+/**
+ * Records timeline till console.timeStamp("ready"), invokes callback with resulting records.
+ * @param {function(Array.<Object>)} callback
+ */
+TestSuite.prototype.recordTimeline = function(callback)
+{
+    var records = [];
+    var dispatchOnRecordType = {}
+
+    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addRecord);
+    WebInspector.timelineManager.start();
+
+    function addRecord(event)
+    {
+        innerAddRecord(event.data);
+    }
+
+    function innerAddRecord(record)
+    {
+        records.push(record);
+        if (record.type === "TimeStamp" && record.data.message === "ready")
+            done();
+
+        if (record.children)
+            record.children.forEach(innerAddRecord);
+    }
+
+    function done()
+    {
+        WebInspector.timelineManager.stop();
+        WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addRecord);
+        callback(records);
+    }
+}
+
+
+TestSuite.prototype.stopTimeline = function()
+{
+    this.evaluateInConsole_("console.timeStamp('ready')", function() {});
+}
+
 TestSuite.prototype.waitForTestResultsInConsole = function()
 {
     var messages = WebInspector.console.messages;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to