Bug 1388159 - New talos test to replace tpaint. r=jmaher
authorBrendan Dahl <bdahl@mozilla.com>
Fri, 08 Mar 2019 16:37:15 +0000
changeset 521428 ad21d7147c00
parent 521427 6f7a618fc25f
child 521429 abac6267ab62
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1388159
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 1388159 - New talos test to replace tpaint. r=jmaher Currently, tpaint measures from window.open until a message is received that the MozAfterPaint event has fired from the content in the new window. This has several issues: 1) the MozAfterPaint event is dispatched asynchronously and it's not the actual time the paint occurred 2) it adds the lag time of sending a message 3) it uses MozAfterPaint from the content page 4) window.open is not the default code path that opening a new window follows in Firefox In the new measurement, twinopen measures from OpenBrowserWindow (which is closer to ctrl+n) to browser chrome's paintTimeStamp from MozAfterPaint. Differential Revision: https://phabricator.services.mozilla.com/D22386
testing/talos/talos.json
testing/talos/talos/test.py
testing/talos/talos/tests/twinopen/api.js
testing/talos/talos/tests/twinopen/driver.js
testing/talos/talos/tests/twinopen/manifest.json
testing/talos/talos/tests/twinopen/schema.json
testing/talos/talos/tests/twinopen/twinopen.html
testing/talos/talos/tests/twinopen/twinopen.manifest
testing/talos/talos/tests/twinopen/twinopen.manifest.develop
--- 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", "startup_about_home_paint"]
+            "tests": ["a11yr", "ts_paint", "tpaint", "twinopen", "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"
         },
--- a/testing/talos/talos/test.py
+++ b/testing/talos/talos/test.py
@@ -286,16 +286,38 @@ class tpaint(PageloaderTest):
     gecko_profile_entries = 2000000
     tpmozafterpaint = True
     filters = filter.ignore_first.prepare(5) + filter.median.prepare()
     unit = 'ms'
     preferences = {'security.data_uri.block_toplevel_data_uri_navigations': False}
 
 
 @register_test()
+class twinopen(PageloaderTest):
+    """
+    Tests the amount of time it takes an open browser to open a new browser
+    window and paint the browser chrome. This test does not include startup
+    time. Multiple test windows are opened in succession.
+    (Measures ctrl-n performance.)
+    """
+    extensions = ['${talos}/pageloader', '${talos}/tests/twinopen']
+    tpmanifest = '${talos}/tests/twinopen/twinopen.manifest'
+    tppagecycles = 20
+    timeout = 300
+    gecko_profile_interval = 1
+    gecko_profile_entries = 2000000
+    tpmozafterpaint = True
+    filters = filter.ignore_first.prepare(5) + filter.median.prepare()
+    unit = 'ms'
+    preferences = {
+        'browser.startup.homepage': 'about:blank'
+    }
+
+
+@register_test()
 class cpstartup(PageloaderTest):
     """
     Tests the amount of time it takes to start up a new content process and
     initialize it to the point where it can start processing incoming URLs
     to load.
     """
     extensions = ['${talos}/pageloader', '${talos}/tests/cpstartup/extension']
     tpmanifest = '${talos}/tests/cpstartup/cpstartup.manifest'
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/api.js
@@ -0,0 +1,62 @@
+"use strict";
+
+ChromeUtils.defineModuleGetter(this, "Services",
+                               "resource://gre/modules/Services.jsm");
+ChromeUtils.defineModuleGetter(this, "TalosParentProfiler",
+                               "resource://talos-powers/TalosParentProfiler.jsm");
+ChromeUtils.defineModuleGetter(this, "AppConstants",
+                               "resource://gre/modules/AppConstants.jsm");
+
+var OPENER_DELAY = 1000; // ms delay between tests
+
+async function openDelay(win) {
+  return new Promise((resolve) => {
+    win.setTimeout(resolve, OPENER_DELAY);
+  });
+}
+
+function waitForBrowserPaint() {
+  return new Promise((resolve) => {
+    let observer = {
+      observe(doc) {
+        if (!doc.location || doc.location.href != AppConstants.BROWSER_CHROME_URL) {
+          return;
+        }
+        Services.obs.removeObserver(observer, "document-element-inserted");
+        doc.ownerGlobal.addEventListener("MozAfterPaint", (evt) => {
+          resolve(doc.ownerGlobal.performance.timing.fetchStart + evt.paintTimeStamp);
+        }, {once: true});
+      },
+    };
+    Services.obs.addObserver(observer, "document-element-inserted");
+  });
+}
+
+async function startTest(context) {
+  await TalosParentProfiler.resume("twinopen", true);
+  Cu.forceGC();
+  Cu.forceCC();
+  Cu.forceShrinkingGC();
+  let win = context.xulWindow;
+  await openDelay(win);
+  let mozAfterPaint = waitForBrowserPaint();
+
+  // We have to compare time measurements across two windows so we must use
+  // the absolute time.
+  let start = win.performance.timing.fetchStart + win.performance.now();
+  let newWin = win.OpenBrowserWindow();
+  let end = await mozAfterPaint;
+  newWin.close();
+  return end - start;
+}
+
+/* globals ExtensionAPI */
+this.twinopen = class extends ExtensionAPI {
+  getAPI(context) {
+    return {
+      twinopen: {
+        startTest: () => startTest(context),
+      },
+    };
+  }
+};
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/driver.js
@@ -0,0 +1,6 @@
+/* eslint-env webextensions */
+addEventListener("load", () => {
+  browser.twinopen.startTest().then(result => {
+    window.tpRecordTime(result);
+  });
+});
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/manifest.json
@@ -0,0 +1,30 @@
+{
+  "manifest_version": 2,
+  "name": "twinopen",
+  "version": "0.1",
+
+  "applications": {
+    "gecko": {
+      "id": "bug1388159@mozilla.org"
+    }
+  },
+
+  "protocol_handlers": [
+    {
+      "protocol": "ext+twinopen",
+      "name": "twinopen protocol",
+      "uriTemplate": "/twinopen.html"
+    }
+  ],
+
+  "experiment_apis": {
+    "twinopen": {
+      "schema": "schema.json",
+      "parent": {
+        "scopes": ["addon_parent"],
+        "script": "api.js",
+        "paths": [["twinopen"]]
+      }
+    }
+  }
+}
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/schema.json
@@ -0,0 +1,13 @@
+[
+  {
+    "namespace": "twinopen",
+    "functions": [
+      {
+        "name": "startTest",
+        "type": "function",
+        "async": true,
+        "parameters": []
+      }
+    ]
+  }
+]
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/twinopen.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<meta charset="UTF-8"/>
+<title>twinopen</title>
+
+<script src="driver.js"></script>
+</head>
+
+<body>
+  <h4>twinopen</h4>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/twinopen.manifest
@@ -0,0 +1,1 @@
+% ext+twinopen:twinopen.html
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/twinopen/twinopen.manifest.develop
@@ -0,0 +1,1 @@
+% ext+twinopen:twinopen.html