Bug 1355934 - transform tpaint into a Pageloader test r?jmaher draft rename_tpaint
authorIonut Goldan <ionut.goldan@softvision.ro>
Wed, 28 Jun 2017 11:40:38 -0700
changeset 604728 5489b4d8a9b7fda703bdbdf44603f23602d20187
parent 604727 018b3829d0a7f6944a5ae1489f3a64c9e2893909
child 636276 32c745afd4dd70a994dde6e4acb4ebf12b36f175
push id67171
push userbmo:ionut.goldan@softvision.ro
push dateThu, 06 Jul 2017 09:48:53 +0000
reviewersjmaher
bugs1355934
milestone56.0a1
Bug 1355934 - transform tpaint into a Pageloader test r?jmaher MozReview-Commit-ID: J3iZDRp14Br
testing/talos/talos/startup_test/tpaint.html
testing/talos/talos/test.py
testing/talos/talos/tests/tpaint/tpaint.html
testing/talos/talos/tests/tpaint/tpaint.manifest
deleted file mode 100644
--- a/testing/talos/talos/startup_test/tpaint.html
+++ /dev/null
@@ -1,126 +0,0 @@
-<html>
-<meta charset='utf-8'>
-<script language="JavaScript" type="text/javascript" src="../scripts/MozillaFileLogger.js"></script>
-<script language="JavaScript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
-<script language="JavaScript" type="text/javascript" src="chrome://talos-powers-content/content/TalosPowersContent.js"></script>
-<script language="JavaScript" type="text/javascript" src="../tests/quit.js"></script>
-<script>
-var OPENER_DELAY = 1000; // ms delay between tests
-var REPEAT_COUNT = 20;
-var kid, kidStartTime, kidEndTime, windowIndex, openTimes;
-var auto = document.location.search.split("=")[1]; // ?auto=1
-
-/*
- * tpaint -- measures the amount of time between opening a new window
- *           its contents being painted.
- *
- * XXX When run manually, outside of automation, need to:
- *     1) allow popups
- *     2) set dom.send_after_paint_to_content = true
- *     3) set browser.link.open_newwindow = 2 (else it opens in a tab)
- */
-
-async function startTest() {
-  // Initialize
-  windowIndex = -1;
-  openTimes = [];
-
-  TalosContentProfiler.initFromURLQueryParams(location.search);
-  await TalosContentProfiler.beginTest("tpaint");
-  scheduleNextWindow();
-}
-
-function scheduleNextWindow() {
-  windowIndex++;
-  if (windowIndex >= REPEAT_COUNT) {
-    window.setTimeout(reportTimes, 0);
-    return;
-  }
-
-  TalosPowersContent.forceCCAndGC();
-  window.setTimeout(openWindow, OPENER_DELAY);
-}
-
-function calcMedian( numbers ) {
-  // Avoid changing the original array.
-  var sortedNumbers = Array.from(numbers);
-  sortedNumbers.sort( function(a, b) { return a - b; } );
-  var n = Math.floor( sortedNumbers.length / 2 );
-  if (sortedNumbers.length % 2) {
-    return sortedNumbers[n];
-  }
-  return ( sortedNumbers[n - 1] + sortedNumbers[n] ) / 2;
-}
-
-async function reportTimes() {
-  await TalosContentProfiler.finishTest();
-
-  var min = 99999, max = 0, avg = 0;
-  var count = openTimes.length;
-  for (var i = 0; i < count; i++) {
-    var time = openTimes[i];
-    avg += time;
-    if (time < min)
-      min = time;
-    if (time > max)
-      max = time;
-  }
-  avg = (avg / count).toFixed(2);
-  min = min.toFixed(2);
-  max = max.toFixed(2);
-  var med = calcMedian(openTimes);
-
-  if (auto) {
-    dumpLog("__start_report" + openTimes.join("|") + "__end_report");
-    var now = (new Date()).getTime();
-    dumpLog("__startTimestamp" + now + "__endTimestamp\n");
-    dumpLog("openingTimes=" + openTimes.slice(1) + "\n");
-    dumpLog("avgOpenTime:" + avg + "\n" );
-    dumpLog("minOpenTime:" + min + "\n" );
-    dumpLog("maxOpenTime:" + max + "\n" );
-    dumpLog("medOpenTime:" + med + "\n" );
-    dumpLog("__xulWinOpenTime:" + med + "\n");
-
-    goQuitApplication();
-    window.close();
-  } else {
-    alert("Average over " + count + " runs: " + avg + "\n" +
-          "(min=" + min + ", max=" + max + ")\n" +
-          "runs=" + openTimes.join(","));
-  }
-}
-
-async function childIsOpen() {
-  kidEndTime = window.performance.now();
-  await TalosContentProfiler.pause("tpaint " + windowIndex);
-  openTimes[windowIndex] = kidEndTime - kidStartTime;
-  scheduleNextWindow();
-}
-
-/* eslint-disable no-useless-concat */
-var kidHTML = "<html><meta charset='utf-8'><script>" +
-              "var e = 'MozAfterPaint';" +
-              "function done() {" +
-              "  window.removeEventListener(e, done, true);" +
-              "  window.opener.childIsOpen();" +
-              "  window.close();" +
-              "}" +
-              "window.addEventListener(e, done, true);" +
-              "</" + "script>TPAINT</html>";
-/* eslint-enable no-useless-concat */
-var kidURI = "data:text/html," + encodeURI(kidHTML);
-
-async function openWindow() {
-  await TalosContentProfiler.resume("tpaint " + windowIndex);
-  kidStartTime = window.performance.now();
-  kid = window.open(kidURI);
-}
-
-if (auto)
-  startTest();
-
-</script>
-<h2>tpaint runner</h2>
-<button onclick="startTest()">Start</button>
-</html>
-
--- a/testing/talos/talos/test.py
+++ b/testing/talos/talos/test.py
@@ -197,34 +197,16 @@ class sessionrestore_many_windows(sessio
     1. Set up Firefox to restore automatically from sessionstore.js file.
     2. Launch Firefox.
     3. Measure the delta between firstPaint and sessionRestored.
     """
     profile_path = '${talos}/startup_test/sessionrestore/profile-manywindows'
 
 
 @register_test()
-class tpaint(TsBase):
-    """
-    Tests the amount of time it takes the open a new window. This test does
-    not include startup time. Multiple test windows are opened in succession,
-    results reported are the average amount of time required to create and
-    display a window in the running instance of the browser.
-    (Measures ctrl-n performance.)
-    """
-    url = 'file://${talos}/startup_test/tpaint.html?auto=1'
-    timeout = 300
-    gecko_profile_interval = 1
-    gecko_profile_entries = 2000000
-    tpmozafterpaint = True
-    filters = filter.ignore_first.prepare(5) + filter.median.prepare()
-    unit = 'ms'
-
-
-@register_test()
 class tresize(TsBase):
     """
     This test does some resize thing.
     """
     extensions = '${talos}/startup_test/tresize/addon/tresize-signed.xpi'
     cycles = 20
     url = 'startup_test/tresize/addon/content/tresize-test.html'
     timeout = 150
@@ -270,16 +252,35 @@ class QuantumPageloadTest(PageloaderTest
     gecko_profile_interval = 1
     gecko_profile_entries = 2000000
     filters = filter.ignore_first.prepare(5) + filter.median.prepare()
     unit = 'ms'
     lower_is_better = True
 
 
 @register_test()
+class tpaint(PageloaderTest):
+    """
+    Tests the amount of time it takes the open a new window. This test does
+    not include startup time. Multiple test windows are opened in succession,
+    results reported are the average amount of time required to create and
+    display a window in the running instance of the browser.
+    (Measures ctrl-n performance.)
+    """
+    tpmanifest = '${talos}/tests/tpaint/tpaint.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'
+
+
+@register_test()
 class tabpaint(PageloaderTest):
     """
     Tests the amount of time it takes to open new tabs, triggered from
     both the parent process and the content process.
     """
     extensions = '${talos}/tests/tabpaint/tabpaint-signed.xpi'
     tpmanifest = '${talos}/tests/tabpaint/tabpaint.manifest'
     tppagecycles = 20
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/tpaint/tpaint.html
@@ -0,0 +1,89 @@
+<html>
+<meta charset='utf-8'>
+<script language="JavaScript" type="text/javascript" src="../../scripts/MozillaFileLogger.js"></script>
+<script language="JavaScript" src="chrome://talos-powers-content/content/TalosContentProfiler.js"></script>
+<script language="JavaScript" type="text/javascript" src="chrome://talos-powers-content/content/TalosPowersContent.js"></script>
+<script language="JavaScript" type="text/javascript" src="../quit.js"></script>
+<script>
+var OPENER_DELAY = 1000; // ms delay between tests
+var kid, kidStartTime, kidEndTime, openTime;
+var auto = document.location.search.split("=")[1]; // ?auto=1
+
+/*
+ * tpaint -- measures the amount of time between opening a new window
+ *           its contents being painted.
+ *
+ * XXX When run manually, outside of automation, need to:
+ *     1) allow popups
+ *     2) set dom.send_after_paint_to_content = true
+ *     3) set browser.link.open_newwindow = 2 (else it opens in a tab)
+ */
+
+async function startTest() {
+  TalosContentProfiler.initFromURLQueryParams(location.search);
+  await TalosContentProfiler.beginTest("tpaint");
+  scheduleNextWindow();
+}
+
+function scheduleNextWindow() {
+  TalosPowersContent.forceCCAndGC();
+  window.setTimeout(openWindow, OPENER_DELAY);
+}
+
+function calcMedian( numbers ) {
+  // Avoid changing the original array.
+  var sortedNumbers = Array.from(numbers);
+  sortedNumbers.sort( function(a, b) { return a - b; } );
+  var n = Math.floor( sortedNumbers.length / 2 );
+  if (sortedNumbers.length % 2) {
+    return sortedNumbers[n];
+  }
+  return ( sortedNumbers[n - 1] + sortedNumbers[n] ) / 2;
+}
+
+async function reportTimes() {
+  await TalosContentProfiler.finishTest();
+
+  if (window.tpRecordTime)
+    window.tpRecordTime(openTime);
+
+  if (auto) {
+    dumpLog("openingTime=" + openTime + "\n");
+  }
+}
+
+async function childIsOpen() {
+  kidEndTime = window.performance.now();
+  openTime = kidEndTime - kidStartTime;
+  await TalosContentProfiler.pause("tpaint");
+
+  window.setTimeout(reportTimes, 0);
+}
+
+/* eslint-disable no-useless-concat */
+var kidHTML = "<html><meta charset='utf-8'><script>" +
+              "var e = 'MozAfterPaint';" +
+              "function done() {" +
+              "  window.removeEventListener(e, done, true);" +
+              "  window.opener.childIsOpen();" +
+              "  window.close();" +
+              "}" +
+              "window.addEventListener(e, done, true);" +
+              "</" + "script>TPAINT</html>";
+/* eslint-enable no-useless-concat */
+var kidURI = "data:text/html," + encodeURI(kidHTML);
+
+async function openWindow() {
+  await TalosContentProfiler.resume("tpaint");
+  kidStartTime = window.performance.now();
+  kid = window.open(kidURI);
+}
+
+if (auto)
+  startTest();
+
+</script>
+<h2>tpaint runner</h2>
+<button onclick="startTest()">Start</button>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/tpaint/tpaint.manifest
@@ -0,0 +1,1 @@
+% http://localhost/tests/tpaint/tpaint.html?auto=1
\ No newline at end of file