Bug 1251732 - Make tpaint open the window from the parent
MozReview-Commit-ID: 6oe38jNQl5F
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/chrome.manifest
@@ -0,0 +1,2 @@
+content tpaint content/
+overlay chrome://browser/content/browser.xul chrome://tpaint/content/tpaint.overlay.xul
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/content/tpaint-framescript.js
@@ -0,0 +1,19 @@
+(function() {
+ const TPAINT_PREFIX = "tpaint@mozilla.org:";
+
+ addEventListener(TPAINT_PREFIX + "chrome-run-event", function (e) {
+ var uniqueMessageId = TPAINT_PREFIX + content.document.documentURI + Date.now() + Math.random();
+
+ addMessageListener(TPAINT_PREFIX + "chrome-run-reply", function done(reply) {
+ if (reply.data.id == uniqueMessageId) {
+ removeMessageListener(TPAINT_PREFIX + "chrome-run-reply", done);
+ content.wrappedJSObject.logResults(reply.data.result);
+ }
+ });
+
+ sendAsyncMessage(TPAINT_PREFIX + "chrome-run-message", {
+ id: uniqueMessageId,
+ locationSearch: e.detail.locationSearch
+ });
+ }, false, true);
+})()
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/content/tpaint-target.html
@@ -0,0 +1,1 @@
+<html><meta charset='utf-8'>TPAINT</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/content/tpaint-test.html
@@ -0,0 +1,39 @@
+<!-- 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/. -->
+<html>
+<head>
+<script language="Javascript" type="text/javascript" src="../../../../scripts/MozillaFileLogger.js"></script>
+<script language="JavaScript" type="text/javascript" src="../../../../tests/quit.js"></script>
+<script language="javascript" type="text/javascript">
+
+function runTest() {
+ dispatchEvent(
+ new CustomEvent("tpaint@mozilla.org:chrome-run-event",
+ { bubbles: true,
+ detail: { locationSearch: location.search } })
+ );
+}
+
+function logResults(data) {
+ if (typeof dumpLog != "undefined") {
+ data.forEach(function(line) {
+ dumpLog(line);
+ });
+
+
+ window.setTimeout(function() {
+ goQuitApplication();
+ window.close();
+ }, 0);
+ } else {
+ alert(data[0].split("__start_report")[1].split("__end_report")[0]);
+ }
+}
+
+</script>
+</head>
+<body id="body" onload="runTest();">
+TPAINT
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/content/tpaint.js
@@ -0,0 +1,89 @@
+let TalosPowers = Cc["@mozilla.org/talos/talos-powers-service;1"]
+ .QueryInterface(Ci.nsISupports).wrappedJSObject;
+
+var OPENER_DELAY = 1000; // ms delay between tests
+var REPEAT_COUNT = 20;
+var kid, kidStartTime, kidEndTime, windowIndex, openTimes;
+var doneCallback;
+
+function runTest(callback, locationSearch) {
+ // Initialize
+ windowIndex = -1;
+ openTimes = [];
+ doneCallback = callback;
+
+ scheduleNextWindow();
+}
+
+
+function scheduleNextWindow() {
+ windowIndex++;
+ if (windowIndex >= REPEAT_COUNT) {
+ window.setTimeout(reportTimes, 0);
+ return;
+ }
+ window.setTimeout(openWindow, OPENER_DELAY);
+}
+
+function calcMedian( numbers ) {
+ numbers.sort( function (a,b){ return a-b; } );
+ var n = Math.floor( numbers.length / 2 );
+ return numbers.length % 2 ? numbers[n] : ( numbers[n-1] + numbers[n] ) / 2;
+}
+
+function reportTimes() {
+ 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);
+ med = calcMedian(openTimes);
+
+ let res = [];
+
+ res.push("__start_report" + openTimes.join('|') + "__end_report");
+ var now = (new Date()).getTime();
+ res.push("__startTimestamp" + now + "__endTimestamp\n");
+ res.push("openingTimes="+openTimes.slice(1)+"\n");
+ res.push("avgOpenTime:" + avg + "\n" );
+ res.push("minOpenTime:" + min + "\n" );
+ res.push("maxOpenTime:" + max + "\n" );
+ res.push("medOpenTime:" + med + "\n" );
+ res.push("__xulWinOpenTime:" + med + "\n");
+
+ doneCallback(res);
+}
+
+var kidHTML = "<html><meta charset='utf-8'>TPAINT</html>";
+var kidURI = "data:text/html," + encodeURI(kidHTML);
+
+function childIsOpen() {
+ kidEndTime = window.performance.now();
+ TalosParentProfiler.pause('tpaint ' + windowIndex);
+ openTimes[windowIndex] = kidEndTime - kidStartTime;
+ scheduleNextWindow();
+}
+
+function openWindow() {
+ kidStartTime = window.performance.now();
+
+ let args = "chrome,all,dialog=no";
+ let win = window.openDialog(getBrowserURL(), "_blank", args, kidURI);
+ win.addEventListener("load", function onLoad() {
+ win.removeEventListener("load", onLoad);
+ win.addEventListener("MozAfterPaint", function onPaint() {
+ win.removeEventListener("MozAfterPaint", onPaint);
+ childIsOpen();
+ win.close();
+ });
+ });
+}
+
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/content/tpaint.overlay.xul
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<overlay id="Scrapper-Overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/x-javascript" src="chrome://talos-powers-content/content/TalosParentProfiler.js" />
+<script type="application/x-javascript" src="tpaint.js" />
+<script type="application/x-javascript">
+(function(){
+ const TPAINT_PREFIX = "tpaint@mozilla.org:";
+
+ var groupMM = window.getGroupMessageManager("browsers");
+ groupMM.loadFrameScript("chrome://tpaint/content/tpaint-framescript.js", true);
+
+ // listener/executor on the chrome process for tresize.html
+ groupMM.addMessageListener(TPAINT_PREFIX + "chrome-run-message", function listener(m) {
+ function sendResult(result) {
+ groupMM.broadcastAsyncMessage(TPAINT_PREFIX + "chrome-run-reply", {
+ id: m.data.id,
+ result: result
+ });
+ }
+
+ runTest(sendResult, m.data.locationSearch);
+ });
+})();
+</script>
+</overlay>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/startup_test/tpaint/addon/install.rdf
@@ -0,0 +1,21 @@
+<?xml version="1.0"?><RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"><Description about="urn:mozilla:install-manifest">
+
+<!-- Required Items -->
+<em:id>tresize@mozilla.org</em:id>
+<em:name>TPaint</em:name>
+<em:version>1.0.2</em:version>
+
+<em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>1.5</em:minVersion>
+ <em:maxVersion>*</em:maxVersion>
+ </Description>
+</em:targetApplication>
+
+<!-- Optional Items -->
+<em:creator>Mike Conley</em:creator>
+<em:description>https://wiki.mozilla.org/Buildbot/Talos/Tests</em:description>
+<em:homepageURL>https://wiki.mozilla.org/Buildbot/Talos/Tests</em:homepageURL>
+<em:multiprocessCompatible>true</em:multiprocessCompatible>
+</Description></RDF>
--- a/testing/talos/talos/test.py
+++ b/testing/talos/talos/test.py
@@ -181,32 +181,33 @@ class sessionrestore_no_auto_restore(ses
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'
+ url = 'file://${talos}/startup_test/tpaint/addon/content/tpaint-test.html?auto=1'
+ extensions = '${talos}/startup_test/tpaint/addon'
timeout = 300
sps_profile_interval = 1
sps_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'
- cycles = 20
+ cycles = 1
url = 'startup_test/tresize/addon/content/tresize-test.html'
timeout = 150
sps_profile_interval = 2
sps_profile_entries = 1000000
tpmozafterpaint = True
filters = filter.ignore_first.prepare(5) + filter.median.prepare()
unit = 'ms'