Bug 1504133 - Make sure sessionrestore tests initialize the TalosParentProfiler. r=aswan
authorMike Conley <mconley@mozilla.com>
Fri, 09 Nov 2018 14:03:26 +0000
changeset 445422 ea40fb28a2bfa764020949c399ae79dd103e673b
parent 445421 21a96274fe32a9d2120232b80820250c74e401c6
child 445423 46dd8d73a77a7b3203e2e253a0a2c31cdbeb4276
push id35015
push userdluca@mozilla.com
push dateFri, 09 Nov 2018 17:45:20 +0000
treeherdermozilla-central@2f1158e5e0ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1504133
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1504133 - Make sure sessionrestore tests initialize the TalosParentProfiler. r=aswan Depends on D11259 Differential Revision: https://phabricator.services.mozilla.com/D11260
testing/talos/talos/startup_test/sessionrestore/addon/api.js
--- a/testing/talos/talos/startup_test/sessionrestore/addon/api.js
+++ b/testing/talos/talos/startup_test/sessionrestore/addon/api.js
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
+  BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
   Services: "resource://gre/modules/Services.jsm",
   SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
   setTimeout: "resource://gre/modules/Timer.jsm",
   StartupPerformance: "resource:///modules/sessionstore/StartupPerformance.jsm",
   TalosParentProfiler: "resource://talos-powers/TalosParentProfiler.jsm",
 });
 
 /* globals ExtensionAPI */
@@ -40,16 +41,31 @@ this.sessionrestore = class extends Exte
             throw new Error("Session was not restored!");
           }
           didRestore = false;
         } else {
           await new Promise(resolve => {
             async function observe() {
               Services.obs.removeObserver(observe, StartupPerformance.RESTORED_TOPIC);
 
+              let win = BrowserWindowTracker.getTopWindow();
+              let args = win.arguments[0];
+              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 some tab that is loaded at start-up
+                // will want to use them in the TalosContentProfiler.js script.
+                //
+                // Because we're running this part of the test in the parent process, we
+                // pull those arguments from the top window directly. This is mainly so
+                // that TalosParentProfiler knows where to save the profile.
+                Cu.importGlobalProperties(["URL"]);
+                let url = new URL(args.queryElementAt(0, Ci.nsISupportsString).data);
+                TalosParentProfiler.initFromURLQueryParams(url.search);
+              }
+
               await TalosParentProfiler.pause("This test measures the time between sessionRestoreInit and sessionRestored, ignore everything around that");
               await TalosParentProfiler.finishStartupProfiling();
 
               resolve();
             }
             Services.obs.addObserver(observe, StartupPerformance.RESTORED_TOPIC);
           });
         }