Modify pageloader to use TalosParentProfiler draft
authorMike Conley <mconley@mozilla.com>
Mon, 25 Jan 2016 12:47:43 -0500
changeset 331554 9df706f553505f832a925c344a309f98c7a1574e
parent 331553 f1d59f0ce2de1835db2abf7a966bd3024b4d3045
child 514408 05d727732ce52ade260d034c33ed7069a136cca4
push id11012
push usermconley@mozilla.com
push dateWed, 17 Feb 2016 16:09:58 +0000
milestone47.0a1
Modify pageloader to use TalosParentProfiler MozReview-Commit-ID: GSuHeWWo7ui
testing/talos/talos/pageloader/chrome/pageloader.js
testing/talos/talos/pageloader/chrome/pageloader.xul
testing/talos/talos/tests/tabswitch/bootstrap.js
--- a/testing/talos/talos/pageloader/chrome/pageloader.js
+++ b/testing/talos/talos/pageloader/chrome/pageloader.js
@@ -147,17 +147,17 @@ function plInit() {
     if (args.mozafterpaint) useMozAfterPaint = true;
     if (args.rss) reportRSS = true;
     if (args.loadnocache) loadNoCache = true;
     if (args.scrolltest) scrollTest = true;
     if (args.disableE10S) gDisableE10S = true;
     if (args.profilinginfo) profilingInfo = JSON.parse(args.profilinginfo)
 
     if (profilingInfo) {
-      Profiler.initFromObject(profilingInfo);
+      TalosParentProfiler.initFromObject(profilingInfo);
     }
 
     forceCC = !args.noForceCC;
     doRenderTest = args.doRender;
 
     if (forceCC &&
         !window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                .getInterface(Components.interfaces.nsIDOMWindowUtils)
@@ -195,17 +195,17 @@ function plInit() {
     pageUrls = pages.map(function(p) { return p.url.spec.toString(); });
     report = new Report();
 
     if (doRenderTest)
       renderReport = new Report();
 
     pageIndex = 0;
     if (profilingInfo) {
-      Profiler.beginTest(getCurrentPageShortName());
+      TalosParentProfiler.beginTest(getCurrentPageShortName());
     }
   
     if (args.useBrowserChrome) {
       // Create a new chromed browser window for content
       var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"]
         .getService(Ci.nsIWindowWatcher);
       var blank = Cc["@mozilla.org/supports-string;1"]
         .createInstance(Ci.nsISupportsString);
@@ -384,31 +384,31 @@ function plLoadPage() {
       mm.removeMessageListener('PageLoader:LoadEvent', ContentListener);
       mm.removeMessageListener('PageLoader:RecordTime', ContentListener);
     };
   }
 
   failTimeout.register(loadFail, timeout);
 
   // record which page we are about to open
-  Profiler.mark("Opening " + pages[pageIndex].url.path);
+  TalosParentProfiler.mark("Opening " + pages[pageIndex].url.path);
 
   if (reportRSS) {
     collectMemory(startAndLoadURI, pageName);
   } else {
     startAndLoadURI(pageName);
   }
 }
 
 function startAndLoadURI(pageName) {
   if (!(plPageFlags() & TEST_DOES_OWN_TIMING)) {
     // Resume the profiler because we're really measuring page load time.
     // If the test is doing its own timing, it'll also need to do its own
     // profiler pausing / resuming.
-    Profiler.resume("Starting to load URI " + pageName, true);
+    TalosParentProfiler.resume("Starting to load URI " + pageName, true);
   }
   start_time = Date.now();
   if (loadNoCache) {
     content.loadURIWithFlags(pageName, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
   } else {
     content.loadURI(pageName);
   }
 }
@@ -433,18 +433,19 @@ function getCurrentPageShortName() {
 
 function loadFail() {
   var pageName = pages[pageIndex].url.spec;
   numRetries++;
 
   if (numRetries >= maxRetries) {
     dumpLine('__FAILTimeout in ' + getTestName() + '__FAIL');
     dumpLine('__FAILTimeout (' + numRetries + '/' + maxRetries + ') exceeded on ' + pageName + '__FAIL');
-    Profiler.finishTest();
-    plStop(true);
+    TalosParentProfiler.finishTest().then(() => {
+      plStop(true);
+    });
   } else {
     dumpLine('__WARNTimeout (' + numRetries + '/' + maxRetries + ') exceeded on ' + pageName + '__WARN');
     // TODO: make this a cleaner cleanup
     pageCycle--;
     content.removeEventListener('load', plLoadHandler, true);
     content.removeEventListener('load', plLoadHandlerCapturing, true);
     content.removeEventListener("MozAfterPaint", plPaintedCapturing, true);
     content.removeEventListener("MozAfterPaint", plPainted, true);
@@ -461,23 +462,23 @@ function loadFail() {
 
 var plNextPage = Task.async(function*() {
   var doNextPage = false;
   if (pageCycle < numPageCycles) {
     pageCycle++;
     doNextPage = true;
   } else {
     if (profilingInfo) {
-      yield Profiler.finishTest();
+      yield TalosParentProfiler.finishTest();
     }
 
     if (pageIndex < pages.length-1) {
       pageIndex++;
       if (profilingInfo) {
-        Profiler.beginTest(getCurrentPageShortName());
+        TalosParentProfiler.beginTest(getCurrentPageShortName());
       }
       recordedName = null;
       pageCycle = 1;
       doNextPage = true;
     }
   }
 
   if (doNextPage == true) {
@@ -615,17 +616,17 @@ function _loadHandlerCapturing() {
     if (gStartTime != null && gStartTime >= 0) {
       gTime = (new Date()) - gStartTime;
       gStartTime = -1;
     }
   }
 
   if (gTime !== -1) {
     plRecordTime(gTime);
-    Profiler.pause("capturing load handler fired", true);
+    TalosParentProfiler.pause("capturing load handler fired", true);
     gTime = -1;
     recordedName = null;
     setTimeout(plNextPage, delay);
   }
 }
 
 // the onload handler
 function plLoadHandler(evt) {
@@ -661,17 +662,17 @@ function plPainted() {
 }
 
 function _loadHandler() {
   failTimeout.clear();
 
   var end_time = Date.now();
   var time = (end_time - start_time);
 
-  Profiler.pause("Bubbling load handler fired.", true);
+  TalosParentProfiler.pause("Bubbling load handler fired.");
 
   // does this page want to do its own timing?
   // if so, we shouldn't be here
   if (plPageFlags() & TEST_DOES_OWN_TIMING) {
     dumpLine("tp: Bubbling onload handler used with page that does its own timing?");
     plStop(true);
   }
 
--- a/testing/talos/talos/pageloader/chrome/pageloader.xul
+++ b/testing/talos/talos/pageloader/chrome/pageloader.xul
@@ -41,17 +41,17 @@
 <window
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   title="pageloader"
   screenX="0" screenY="0"
   onload="plInit()">
 
   <script type="application/x-javascript" 
           src="chrome://global/content/globalOverlay.js"/>
-  <script type="application/x-javascript" src="Profiler.js"></script>
+  <script type="application/x-javascript" src="chrome://talos-powers-content/content/TalosParentProfiler.js"></script>
   <script type="application/x-javascript" src="MozillaFileLogger.js"></script>
   <script type="application/x-javascript" src="report.js"></script>
   <script type="application/x-javascript" src="pageloader.js"></script>
   <script type="application/x-javascript" src="quit.js"></script>
   <script type="application/x-javascript" src="memory.js"></script>
 
   <browser id="contentPageloader" src="about:blank" 
     type="content" flex="1"/>
--- a/testing/talos/talos/tests/tabswitch/bootstrap.js
+++ b/testing/talos/talos/tests/tabswitch/bootstrap.js
@@ -5,17 +5,17 @@ var { classes: Cc, interfaces: Ci, utils
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let aboutNewTabService = Cc["@mozilla.org/browser/aboutnewtab-service;1"]
                            .getService(Ci.nsIAboutNewTabService);
 
 var aboutBlankTab = null;
-var Profiler = null;
+var TalosParentProfiler = null;
 
 var windowListener = {
   onOpenWindow: function(aWindow) {
     // Ensure we don't get tiles which contact the network
     aboutNewTabService.newTabURL = "about:blank";
 
     // Wait for the window to finish loading
     let window = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
@@ -92,18 +92,18 @@ function waitForTabLoads(browser, urls, 
     onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {},
     onSecurityChange: function(aWebProgress, aRequest, aState) {}
   }
   browser.addTabsProgressListener(listener);
 }
 
 function loadTabs(urls, win, callback) {
   let context = {};
-  Services.scriptloader.loadSubScript("chrome://pageloader/content/Profiler.js", context);
-  Profiler = context.Profiler;
+  Services.scriptloader.loadSubScript("chrome://talos-powers-content/content/TalosContentProfiler.js", context);
+  TalosParentProfiler = context.TalosParentProfiler;
 
   // We don't want to catch scrolling the tabstrip in our tests
   win.gBrowser.tabContainer.style.visibility = "hidden";
 
   let initialTab = win.gBrowser.selectedTab;
   // Set about:blank to be the first tab. This will allow us to use about:blank
   // to let paint event stabilize and make all tab switch more even.
   initialTab.linkedBrowser.loadURI("about:blank", null, null);
@@ -145,35 +145,35 @@ function runTestHelper(startTab, tabs, i
 
   // Clean up garbage so GC/CC doesn't randomly occur during our test
   // making the results noisy
   win.QueryInterface(Ci.nsIInterfaceRequestor)
      .getInterface(Ci.nsIDOMWindowUtils)
      .garbageCollect();
 
   forceContentGC(tab.linkedBrowser).then(function() {
-    if (typeof(Profiler) !== "undefined") {
-      Profiler.resume(tab.linkedBrowser.currentURI.spec);
+    if (typeof(TalosParentProfiler) !== "undefined") {
+      TalosParentProfiler.resume(tab.linkedBrowser.currentURI.spec);
     }
     let start = win.performance.now();
     win.gBrowser.selectedTab = tab;
 
     waitForTabSwitchDone(win, function() {
       // This will fire when we're about to paint the tab switch
       win.requestAnimationFrame(function() {
         // This will fire on the next vsync tick after the tab has switched.
         // If we have a sync transaction on the compositor, that time will
         // be included here. It will not accuratly capture the composite time
         // or the time of async transaction.
         // XXX: This will need to be adjusted for e10s since we need to block
         //      on the child/content having painted.
         win.requestAnimationFrame(function() {
           times.push(win.performance.now() - start);
-          if (typeof(Profiler) !== "undefined") {
-            Profiler.pause(tab.linkedBrowser.currentURI.spec);
+          if (typeof(TalosParentProfiler) !== "undefined") {
+            TalosParentProfiler.pause(tab.linkedBrowser.currentURI.spec);
           }
 
           // Select about:blank which will let the browser reach a steady no
           // painting state
           win.gBrowser.selectedTab = aboutBlankTab;
 
           win.requestAnimationFrame(function() {
             win.requestAnimationFrame(function() {