Bug 1529965 - about:home paint talos test. r=Felipe,davehunt
authorMike Conley <mconley@mozilla.com>
Mon, 25 Feb 2019 18:37:35 +0000
changeset 460951 98486a2bc3c60878d4fce5073eacff3bd1df17b1
parent 460950 5e240b5794fcf316368e5027b52884a7aec0268c
child 460952 c3fd93ab694f412a09a85567acf52699af0abf94
push id35613
push usernerli@mozilla.com
push dateTue, 26 Feb 2019 03:52:35 +0000
treeherdermozilla-central@faec87a80ed1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, davehunt
bugs1529965
milestone67.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 1529965 - about:home paint talos test. r=Felipe,davehunt Differential Revision: https://phabricator.services.mozilla.com/D20889
testing/talos/talos.json
testing/talos/talos/startup_test/startup_about_home_paint/addon/api.js
testing/talos/talos/startup_test/startup_about_home_paint/addon/manifest.json
testing/talos/talos/startup_test/startup_about_home_paint/addon/schema.json
testing/talos/talos/startup_test/startup_about_home_paint/startup_about_home_paint.manifest
testing/talos/talos/test.py
--- a/testing/talos/talos.json
+++ b/testing/talos/talos.json
@@ -8,17 +8,17 @@
         },
         "dromaeojs-e10s": {
             "tests": ["dromaeo_css", "kraken"]
         },
         "flex-e10s": {
             "tests": ["tart_flex", "ts_paint_flex"]
         },
         "other-e10s": {
-            "tests": ["a11yr", "ts_paint", "tpaint", "sessionrestore", "sessionrestore_no_auto_restore", "tabpaint", "cpstartup"]
+            "tests": ["a11yr", "ts_paint", "tpaint", "sessionrestore", "sessionrestore_no_auto_restore", "tabpaint", "cpstartup", "startup_about_home_paint"]
         },
         "sessionrestore-many-windows-e10s": {
             "tests": ["sessionrestore_many_windows"]
         },
         "g1-e10s": {
             "tests": ["tp5o_scroll", "glterrain"],
             "pagesets_name": "tp5n.zip"
         },
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/startup_about_home_paint/addon/api.js
@@ -0,0 +1,92 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+/* globals ExtensionAPI */
+
+const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+  BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
+  Services: "resource://gre/modules/Services.jsm",
+  setTimeout: "resource://gre/modules/Timer.jsm",
+  TalosParentProfiler: "resource://talos-powers/TalosParentProfiler.jsm",
+});
+
+const SCALAR_KEY = "timestamps.about_home_topsites_first_paint";
+
+const MAX_ATTEMPTS = 10;
+
+let gAttempts = 0;
+
+this.startup_about_home_paint = class extends ExtensionAPI {
+  onStartup() {
+    Services.obs.addObserver(this, "browser-idle-startup-tasks-finished");
+  }
+
+  async wait(aMs) {
+    return new Promise(resolve => {
+      setTimeout(resolve, aMs);
+    });
+  }
+
+  observe(subject, topic, data) {
+    if (topic == "browser-idle-startup-tasks-finished") {
+      this.checkForTelemetry();
+    }
+  }
+
+  async checkForTelemetry() {
+    let snapshot = Services.telemetry.getSnapshotForScalars("main");
+    let measurement = snapshot.parent[SCALAR_KEY];
+    if (!measurement) {
+      if (gAttempts == MAX_ATTEMPTS) {
+        dump(`Failed to get ${SCALAR_KEY} scalar probe in time.\n`);
+        await this.quit();
+        return;
+      }
+      gAttempts++;
+
+      await this.wait(1000);
+      ChromeUtils.idleDispatch(() => {
+        this.checkForTelemetry();
+      });
+    } else {
+      // Got our measurement.
+      dump("__start_report" + measurement + "__end_report\n\n");
+
+      dump("__startTimestamp" + Date.now() + "__endTimestamp\n");
+
+
+      let env = Cc["@mozilla.org/process/environment;1"]
+                  .getService(Ci.nsIEnvironment);
+
+      if (env.exists("TPPROFILINGINFO")) {
+        let profilingInfo = env.get("TPPROFILINGINFO");
+        if (profilingInfo !== null) {
+          TalosParentProfiler.initFromObject(JSON.parse(profilingInfo));
+          await TalosParentProfiler.finishStartupProfiling();
+        }
+      }
+
+      await this.quit();
+    }
+  }
+
+  async quit() {
+    for (let domWindow of Services.wm.getEnumerator(null)) {
+      domWindow.close();
+    }
+
+    try {
+      await this.wait(0);
+      Services.startup.quit(Services.startup.eForceQuit);
+    } catch (e) {
+      dump("Force Quit failed: " + e);
+    }
+  }
+
+  onShutdown() {
+
+  }
+};
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/startup_about_home_paint/addon/manifest.json
@@ -0,0 +1,23 @@
+{
+  "manifest_version": 2,
+  "name": "First about:home paint performance test",
+  "description": "Add-on that quits the browser once the about:home paint measurement has been taken.",
+  "version": "0.1",
+
+  "applications": {
+    "gecko": {
+      "id": "startup_about_home_paint@mozilla.org"
+    }
+  },
+
+  "experiment_apis": {
+    "startup_about_home_paint": {
+      "schema": "schema.json",
+      "parent": {
+        "scopes": ["addon_parent"],
+        "script": "api.js",
+        "events": ["startup"]
+      }
+    }
+  }
+}
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/startup_about_home_paint/addon/schema.json
@@ -0,0 +1,1 @@
+[]
\ No newline at end of file
new file mode 100644
--- a/testing/talos/talos/test.py
+++ b/testing/talos/talos/test.py
@@ -103,16 +103,17 @@ class TsBase(Test):
         'preferences',
         'xperf_counters',
         'xperf_providers',
         'xperf_user_providers',
         'xperf_stackwalk',
         'tpmozafterpaint',
         'fnbpaint',
         'tphero',
+        'tpmanifest',
         'profile',
         'firstpaint',
         'userready',
         'testeventmap',
         'base_vs_ref',
         'extensions',
         'filters',
         'setup',
@@ -164,16 +165,24 @@ class ts_paint_heavy(ts_paint):
 
 
 @register_test()
 class ts_paint_flex(ts_paint):
     preferences = {'layout.css.emulate-moz-box-with-flex': True}
 
 
 @register_test()
+class startup_about_home_paint(ts_paint):
+    url = None
+    cycles = 20
+    extensions = ['${talos}/startup_test/startup_about_home_paint/addon']
+    tpmanifest = '${talos}/startup_test/startup_about_home_paint/startup_about_home_paint.manifest'
+
+
+@register_test()
 class sessionrestore(TsBase):
     """
     A start up test measuring the time it takes to load a sessionstore.js file.
 
     1. Set up Firefox to restore from a given sessionstore.js file.
     2. Launch Firefox.
     3. Measure the delta between firstPaint and sessionRestored.
     """