Bug 1372292 - Update sessionrestore Talos test profiling support. r?Yoric draft
authorMike Conley <mconley@mozilla.com>
Mon, 12 Jun 2017 13:51:47 -0400
changeset 596720 69d42f0b6811a35600b97804867f9fc84b0895d1
parent 596719 73e8ce21d39daf9c32dc41a0ddf15e434118562c
child 596721 064ea162834b30aa4e8b8f58748e6a83614b1b07
child 596729 69d62e1ef729704b9b0e01f592c4048dc08ede0f
push id64733
push usermconley@mozilla.com
push dateMon, 19 Jun 2017 17:24:13 +0000
reviewersYoric
bugs1372292
milestone56.0a1
Bug 1372292 - Update sessionrestore Talos test profiling support. r?Yoric MozReview-Commit-ID: Hct701O3R8C
testing/talos/talos/startup_test/sessionrestore/addon/SessionRestoreTalosTest.js
testing/talos/talos/startup_test/sessionrestore/addon/content/index.html
testing/talos/talos/startup_test/sessionrestore/addon/content/main.js
--- a/testing/talos/talos/startup_test/sessionrestore/addon/SessionRestoreTalosTest.js
+++ b/testing/talos/talos/startup_test/sessionrestore/addon/SessionRestoreTalosTest.js
@@ -125,16 +125,33 @@ nsSessionRestoreTalosTest.prototype = {
       dump("\n");
     }
   },
 
   /**
    * A window is ready for us to open the result tab in.
    */
   onWindow(win) {
-    win.gBrowser.addTab("chrome://session-restore-test/content/index.html");
+    let args = win.arguments[0];
+    let queryString = "";
+
+    if (args && args instanceof Ci.nsIArray) {
+      // For start-up tests Gecko Profiler arguments are passed to the first URL in
+      // the query string, with the presumption that the tab that is being loaded at
+      // start-up will want to use those arguments with the TalosContentProfiler scripts.
+      //
+      // Because we're actually loading the results (and the content that reports
+      // the results) in a new tab _after_ the window has opened, we need to send
+      // those arguments over to the new tab that we open so that the profiler scripts
+      // will continue to work.
+      Cu.importGlobalProperties(["URL"]);
+      let url = new URL(args.queryElementAt(0, Ci.nsISupportsString).data);
+      queryString = url.search;
+    }
+
+    win.gBrowser.addTab("chrome://session-restore-test/content/index.html" + queryString);
   }
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Module
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSessionRestoreTalosTest]);
--- a/testing/talos/talos/startup_test/sessionrestore/addon/content/index.html
+++ b/testing/talos/talos/startup_test/sessionrestore/addon/content/index.html
@@ -1,17 +1,17 @@
 <html>
 <head>
 
 <meta charset="UTF-8"/>
 <title>Session Restore Regression Test</title>
 
 <script type="text/javascript" src="chrome://pageloader/content/MozillaFileLogger.js"></script>
 <script type="text/javascript" src="chrome://pageloader/content/quit.js"></script>
-<script type="text/javascript" src="chrome://pageloader/content/Profiler.js"></script>
+<script type="text/javascript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
 <script type="text/javascript" src="chrome://session-restore-test/content/main.js">
 </script>
 
 <div>
   <strong>Time between sessionRestoreInit and sessionRestored</strong>
   <span id="sessionRestoreInit-to-sessionRestored">
   (in progress)
   </span>
--- a/testing/talos/talos/startup_test/sessionrestore/addon/content/main.js
+++ b/testing/talos/talos/startup_test/sessionrestore/addon/content/main.js
@@ -6,23 +6,23 @@ var Services = Components.utils.import("
 const MSG_REQUEST = "session-restore-test?duration";
 const MSG_PROVIDE = "session-restore-test:duration";
 
 addEventListener("load", function() {
   Services.cpmm.addMessageListener(MSG_PROVIDE,
     /**
      * Display the result, send it to the harness and quit.
      */
-    function finish(msg) {
+    async function finish(msg) {
       console.log(`main.js: received data on ${MSG_PROVIDE}`, msg);
       Services.cpmm.removeMessageListener(MSG_PROVIDE, finish);
       var duration = msg.data.duration;
-      Profiler.pause("This test measures the time between sessionRestoreInit and sessionRestored, ignore everything around that");
-      Profiler.initFromURLQueryParams(location.search);
-      Profiler.finishStartupProfiling();
+      TalosContentProfiler.initFromURLQueryParams(location.search);
+      await TalosContentProfiler.pause("This test measures the time between sessionRestoreInit and sessionRestored, ignore everything around that");
+      await TalosContentProfiler.finishStartupProfiling();
 
       // Show result on screen. Nice but not really necessary.
       document.getElementById("sessionRestoreInit-to-sessionRestored").textContent = duration + "ms";
 
       // Report data to Talos, if possible
       dumpLog("__start_report" +
               duration         +
               "__end_report\n\n");