Преглед изворни кода

Better navigation timings precision in JS timeline

Gaël Métais пре 10 година
родитељ
комит
130ae7d3f8
2 измењених фајлова са 27 додато и 2 уклоњено
  1. 2 0
      app/node_views/results.html
  2. 25 2
      app/public/scripts/resultsCtrl.js

+ 2 - 0
app/node_views/results.html

@@ -727,6 +727,8 @@
                 </div>
             </div>
             <div class="table">
+
+                <toto data-info="mavariable"></toto>
                 <div class="headers">
                     <div><!-- index --></div>
                     <div>Type</div>

+ 25 - 2
app/public/scripts/resultsCtrl.js

@@ -17,7 +17,7 @@ app.controller('ResultsCtrl', function ($scope) {
 
 
         initSummaryView();
-        initExecutionView();
+        initJSTimelineView();
         initMetricsView();
 
     }
@@ -89,7 +89,7 @@ app.controller('ResultsCtrl', function ($scope) {
         };
     }
 
-    function initExecutionView() {
+    function initJSTimelineView() {
         $scope.slowRequestsOn = false;
         $scope.slowRequestsLimit = 5;
 
@@ -97,6 +97,29 @@ app.controller('ResultsCtrl', function ($scope) {
             return;
         }
 
+        // Read the execution tree and adjust the navigation timings (cause their not very well synchronised)
+        treeRunner($scope.javascript, function(node) {
+            switch(node.data.type) {
+                case 'domInteractive':
+                    $scope.phantomasResults.metrics.domInteractive = node.data.timestamp;
+                    break;
+                case 'domContentLoaded':
+                    $scope.phantomasResults.metrics.domContentLoaded = node.data.timestamp;
+                    break;
+                case 'domContentLoadedEnd':
+                    $scope.phantomasResults.metrics.domContentLoadedEnd = node.data.timestamp;
+                    break;
+                case 'domComplete':
+                    $scope.phantomasResults.metrics.domComplete = node.data.timestamp;
+                    break;
+            }
+
+            if (node.data.type !== 'main') {
+                // Don't check the children
+                return false;
+            }
+        });
+
 
         // Now read the tree and display it on a timeline