Bug 1466479 - Cleanup damp from its unused frontend. r=jdescottes

MozReview-Commit-ID: GmJ2EmLpfb2

--HG--
extra : rebase_source : 5120c5c8cfd91aea23d5c7cce7751d5140b8a982
This commit is contained in:
Alexandre Poirot 2018-06-01 00:22:45 -07:00
Родитель 533d5e8378
Коммит 3efd3f6786
6 изменённых файлов: 14 добавлений и 215 удалений

Просмотреть файл

@ -11,7 +11,6 @@
// Reads the chrome.manifest from a legacy non-restartless extension and loads
// its overlays into the appropriate top-level windows.
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
const windowTracker = {
@ -35,12 +34,6 @@ const windowTracker = {
},
};
function readSync(uri) {
let channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
let buffer = NetUtil.readInputStream(channel.open2());
return new TextDecoder().decode(buffer);
}
function startup(data, reason) {
Services.scriptloader.loadSubScript(data.resourceURI.resolve("content/initialize_browser.js"));
windowTracker.init();

Просмотреть файл

@ -1,12 +1,6 @@
// This file is the common bits for the test runner frontend, originally
// extracted out of the tart.html frontend when creating the damp test.
/* globals updateConfig, defaultConfig, config */ /* from damp.html */
function $(id) {
return document.getElementById(id);
}
// Executes command at the chrome process.
// Limited to one argument (data), which is enough for TART.
// doneCallback will be called once done and, if applicable, with the result as argument.
@ -29,136 +23,12 @@ function chromeExec(commandName, data, doneCallback) {
);
}
function toClipboard(text) {
chromeExec("toClipboard", text);
}
function runTest(config, doneCallback) {
chromeExec("runTest", config, doneCallback);
}
function sum(values) {
return values.reduce(function(a, b) { return a + b; });
}
function average(values) {
return values.length ? sum(values) / values.length : 999999999;
}
function stddev(values, avg) {
if (undefined == avg) avg = average(values);
if (values.length <= 1) return 0;
return Math.sqrt(
values.map(function(v) { return Math.pow(v - avg, 2); })
.reduce(function(a, b) { return a + b; }) / (values.length - 1));
}
var lastResults = '["[no results collected]"]';
function doneTest(dispResult) {
$("hide-during-run").style.display = "block";
$("show-during-run").style.display = "none";
if (dispResult) {
// Array of test results, each element has .name and .value (test name and test result).
// Test result may also be an array of numeric values (all the intervals)
lastResults = JSON.stringify(dispResult); // for "Copy to clipboard" button
var stats = {}; // Used for average, stddev when repeat!=1
var isRepeat = false;
for (var i in dispResult) {
var di = dispResult[i];
var disp = [].concat(di.value).map(function(a) { return " " + (isNaN(a) ? -1 : a.toFixed(1)); }).join("&nbsp;&nbsp;");
dispResult[i] = String(di.name) + ": " + disp;
if (di.name.includes(".half") || di.name.includes(".all"))
dispResult[i] = "<b>" + dispResult[i] + "</b>";
if (di.name.includes(".raw"))
dispResult[i] = "<br/>" + dispResult[i]; // Add space before raw results (which are the first result of an animation)
// stats:
if (!di.name.includes(".raw")) {
if (!stats[di.name]) {
stats[di.name] = [];
} else {
isRepeat = true;
}
stats[di.name].push(di.value);
}
}
var dispStats = "";
if (isRepeat) {
dispStats = "<hr/><b>Aggregated</b>:<br/>";
for (var s in stats) {
if (s.includes(".half") )
dispStats += "<br/>";
dispStats += s + "&nbsp;&nbsp;&nbsp;&nbsp;Average (" + stats[s].length + "): " + average(stats[s]).toFixed(2) + " stddev: " + stddev(stats[s]).toFixed(2) + "<br/>";
}
dispStats += "<hr/><b>Individual animations</b>:<br/>";
}
// eslint-disable-next-line no-unsanitized/property
$("run-results").innerHTML = "<hr/><br/>Results <button onclick='toClipboard(lastResults)'>[ Copy to clipboard as JSON ]</button>:<br/>" + dispStats + dispResult.join("<br/>");
}
}
function triggerStart() {
updateConfig();
$("hide-during-run").style.display = "none";
$("show-during-run").style.display = "block";
$("run-results").innerHTML = "";
runTest(config, doneTest);
}
function deselectAll() {
for (var test of defaultConfig.subtests) {
$("subtest-" + test.name).checked = false;
}
}
// E.g. returns "world" for key "hello", "2014" for key "year", and "" for key "dummy":
// http://localhost/x.html#hello=world&x=12&year=2014
function getUriHashValue(key) {
var k = String(key) + "=";
var uriVars = unescape(document.location.hash).substr(1).split("&");
for (var i in uriVars) {
if (uriVars[i].indexOf(k) == 0)
return uriVars[i].substr(k.length);
}
return "";
}
// URL e.g. chrome://devtools/content/devtools.html#auto&tests=["simple","iconFadeDpiCurrent"]
// Note - there's no error checking for arguments parsing errors.
// Any errors will express as either javascript errors or not reading the args correctly.
// This is not an "official" part of the UI, and when used in talos, will fail early
// enough to not cause "weird" issues too late.
function updateOptionsFromUrl() {
var uriTests = getUriHashValue("tests");
var tests = uriTests ? JSON.parse(uriTests) : [];
if (tests.length) {
for (var test of defaultConfig.subtests) {
$("subtest-" + test.name).checked = false;
for (var t in tests) {
if (tests[t] == test.name) {
$("subtest-" + test.name).checked = true;
}
}
}
}
}
function init() {
updateOptionsFromUrl();
if (document.location.hash.indexOf("#auto") == 0) {
triggerStart();
}
runTest();
}
addEventListener("load", init);

Просмотреть файл

@ -4,6 +4,8 @@
"use strict";
/* globals module */
/**
* This is the registry for all DAMP tests. Tests will be run in the order specified by
* the DAMP_TESTS array.
@ -17,7 +19,7 @@
* - {Boolean} cold: set to true to run the test only during the first run of the browser
*/
window.DAMP_TESTS = [
module.exports = [
{
name: "inspector.cold-open",
path: "inspector/cold-open.js",

Просмотреть файл

@ -1,68 +1,11 @@
<html>
<head>
<meta charset="UTF-8"/>
<title>DAMP - Devtools At Maximum Performance</title>
<meta charset="UTF-8"/>
<title>DAMP - Devtools At Maximum Performance</title>
<script src="damp-tests.js"></script>
<script type="application/x-javascript">
// Empty subtests interpreted as all subtests, since otherwise meaningless.
var config = {subtests: [], repeat: 1};
var defaultConfig = {
repeat: 1,
rest: 100,
subtests: window.DAMP_TESTS // from damp-tests.js
};
function updateConfig() {
config = {subtests: []};
for (var test of defaultConfig.subtests) {
if ($("subtest-" + test.name).checked) { // eslint-disable-line no-undef
config.subtests.push(test);
}
}
var repeat = $("repeat").value; // eslint-disable-line no-undef
config.repeat = isNaN(repeat) ? 1 : repeat;
// use 1ms rest as a minimum.
var rest = $("rest").value; // eslint-disable-line no-undef
config.rest = Math.max(1, isNaN(rest) ? defaultConfig.rest : rest);
}
</script>
<script src="addon-test-frontend.js"></script>
<script src="addon-test-frontend.js"></script>
</head>
<body style="font-family:sans-serif;">
<h4>DAMP - Devtools At Maximum Performance</h4>
<div id="hide-during-run">
Visit <a href="https://wiki.mozilla.org/Buildbot/Talos/Tests#DAMP">talos/TART</a> for detailed info.<br/>
<ul>
<li><b>If you just opened the browser</b> - give Firefox few seconds to settle down before testing.</li>
</ul>
Utilities:
<a href="pages/simple.html">simple page</a>&nbsp;&nbsp;&nbsp;
<a href="http://localhost/tests/tp5n/bild.de/www.bild.de/index.html">complicated page</a>&nbsp;&nbsp;&nbsp;
<br/><br/>
<b>Configure DAMP</b> (CTRL-F5 to reset to talos defaults) <button type="button" onclick="deselectAll()">Deselect all tests</button><br/>
<script>
for (let test of defaultConfig.subtests) {
let checked = test.disabled ? "unchecked" : "checked";
// eslint-disable-next-line no-unsanitized/method
document.write(`<input type="checkbox" id="subtest-${test.name}" ${checked}>
${test.name}
</input>
<span style="color:grey">&nbsp;&nbsp;&nbsp;${test.description}</span>
<br/>`);
}
</script>
<br/>
Repeat: <input id="repeat" type="text" size=2 value="1" onchange="updateConfig()"/> times<br/>
Delay before starting a measured animation: <input id="rest" type="text" size=4 value="10"/> ms<br/>
<button type="button" id="start-test-button" onclick="triggerStart()">Start Devtools At Maximum Performance tests</button>&nbsp;&nbsp;&nbsp;
<div id="run-results"></div>
</div>
<div id="show-during-run" style="display:none">Testing in progress ...</div>
<h4>DAMP - Devtools At Maximum Performance</h4>
</body>
</html>

Просмотреть файл

@ -199,7 +199,7 @@ Damp.prototype = {
async testSetup(url) {
let tab = await this.addTab(url);
await new Promise(resolve => {
setTimeout(resolve, this._config.rest);
setTimeout(resolve, 100);
});
return tab;
},
@ -219,7 +219,6 @@ Damp.prototype = {
_win: undefined,
_dampTab: undefined,
_results: [],
_config: {subtests: [], repeat: 1, rest: 100},
_nextTestIndex: 0,
_tests: [],
_onSequenceComplete: 0,
@ -397,7 +396,7 @@ Damp.prototype = {
await this.garbageCollect();
},
startTest(doneCallback, config) {
startTest(doneCallback) {
try {
dump("Initialize the head file with a reference to this DAMP instance\n");
let head = require("chrome://damp/content/tests/head.js");
@ -407,7 +406,6 @@ Damp.prototype = {
TalosParentProfiler.pause("DAMP - end");
doneCallback(results);
};
this._config = config;
this._win = Services.wm.getMostRecentWindow("navigator:browser");
this._dampTab = this._win.gBrowser.selectedTab;
@ -418,8 +416,9 @@ Damp.prototype = {
// Filter tests via `./mach --subtests filter` command line argument
let filter = Services.prefs.getCharPref("talos.subtests", "");
let tests = config.subtests.filter(test => !test.disabled)
.filter(test => test.name.includes(filter));
let DAMP_TESTS = require("chrome://damp/content/damp-tests.js");
let tests = DAMP_TESTS.filter(test => !test.disabled)
.filter(test => test.name.includes(filter));
if (tests.length === 0) {
this.error(`Unable to find any test matching '${filter}'`);
@ -436,9 +435,7 @@ Damp.prototype = {
// Construct the sequence array while filtering tests
let sequenceArray = [];
for (let test of tests) {
for (let r = 0; r < config.repeat; r++) {
sequenceArray.push(test.path);
}
sequenceArray.push(test.path);
}
this.waitBeforeRunningTests().then(() => {

Просмотреть файл

@ -9,12 +9,6 @@ function initializeBrowser(win) {
runTest(config, callback) {
(new win.Damp()).startTest(callback, config);
},
toClipboard(text) {
const gClipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper);
gClipboardHelper.copyString(text);
}
};
var groupMM = win.getGroupMessageManager("browsers");