Bug 1381988 - Switch talos tpaint test to measure time until timeToNonBlankPaint, rather than until MozAfterPaint.
MozReview-Commit-ID: AZsfKMjf8mk
--- a/testing/talos/talos/test.py
+++ b/testing/talos/talos/test.py
@@ -267,19 +267,22 @@ class tpaint(PageloaderTest):
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
+ tpmozafterpaint = False
filters = filter.ignore_first.prepare(5) + filter.median.prepare()
unit = 'ms'
+ preferences = {
+ 'dom.performance.time_to_non_blank_paint.enabled': True
+ }
@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.
"""
--- a/testing/talos/talos/tests/tpaint/tpaint.html
+++ b/testing/talos/talos/tests/tpaint/tpaint.html
@@ -44,33 +44,53 @@ async function reportTimes() {
if (window.tpRecordTime)
window.tpRecordTime(openTime);
if (auto) {
dumpLog("openingTime=" + openTime + "\n");
}
}
-async function childIsOpen() {
- kidEndTime = window.performance.now();
+async function childIsOpen(delay) {
+ kidEndTime = window.performance.now() - delay;
openTime = kidEndTime - kidStartTime;
await TalosContentProfiler.pause("tpaint", true);
window.setTimeout(reportTimes, 0);
}
+/**
+ * We're going to calculate the difference between when the done() function
+ * is called, and when timeToNonBlankPaint happened.
+ *
+ * This difference, called `delay` will be transferred back to the childIsOpen
+ * and subtracted from the measurement.
+ *
+ * The end result is that openTime should hold the high precision difference
+ * between when window.open has been called, and when the timeToNonBlankPaint
+ * has been measured in the child window.
+ */
+
/* 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();" +
+ "function readFNBPaint() {" +
+ " const fnbp = performance.timing.timeToNonBlankPaint;" +
+ " if (fnbp === undefined) {" +
+ " window.removeEventListener('MozAfterPaint', readFNBPaint, true);" +
+ " throw new Error('FNBPaint not available');" +
+ " }" +
+ " if (fnbp !== 0) {" +
+ " window.removeEventListener('MozAfterPaint', readFNBPaint, true);" +
+ " const epochNow = performance.timing.navigationStart + performance.now();" +
+ " const delay = epochNow - fnbp;" +
+ " window.opener.childIsOpen(delay);" +
+ " window.close();" +
+ " }" +
"}" +
- "window.addEventListener(e, done, true);" +
+ "window.addEventListener('MozAfterPaint', readFNBPaint, 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);