Bug 1466479 - Remove useless communication between damp.html and talos add-on. r=jdescottes
MozReview-Commit-ID: 6pqokJgqrnu
deleted file mode 100644
--- a/testing/talos/talos/tests/devtools/addon/content/addon-test-frontend.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// This file is the common bits for the test runner frontend, originally
-// extracted out of the tart.html frontend when creating the damp test.
-
-// 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.
-// Execution might finish quickly (e.g. when setting prefs) or
-// take a while (e.g. when triggering the test run)
-function chromeExec(commandName, data, doneCallback) {
- // dispatch an event to the framescript which will take it from there.
- doneCallback = doneCallback || function dummy() {};
- dispatchEvent(
- new CustomEvent("damp@mozilla.org:chrome-exec-event", {
- bubbles: true,
- detail: {
- command: {
- name: commandName,
- data,
- },
- doneCallback
- }
- })
- );
-}
-
-function runTest(config, doneCallback) {
- chromeExec("runTest", config, doneCallback);
-}
-
-function init() {
- runTest();
-}
-
-addEventListener("load", init);
--- a/testing/talos/talos/tests/devtools/addon/content/damp.html
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.html
@@ -1,11 +1,9 @@
<html>
<head>
<meta charset="UTF-8"/>
<title>DAMP - Devtools At Maximum Performance</title>
-
- <script src="addon-test-frontend.js"></script>
</head>
<body style="font-family:sans-serif;">
<h4>DAMP - Devtools At Maximum Performance</h4>
</body>
</html>
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -6,41 +6,29 @@ let scope = {};
Services.scriptloader.loadSubScript("chrome://talos-powers-content/content/TalosParentProfiler.js", scope);
const { TalosParentProfiler } = scope;
XPCOMUtils.defineLazyGetter(this, "require", function() {
let { require } =
ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
return require;
});
-XPCOMUtils.defineLazyGetter(this, "gDevTools", function() {
- let { gDevTools } = require("devtools/client/framework/devtools");
- return gDevTools;
-});
-XPCOMUtils.defineLazyGetter(this, "TargetFactory", function() {
- let { TargetFactory } = require("devtools/client/framework/target");
- return TargetFactory;
-});
// Record allocation count in new subtests if DEBUG_DEVTOOLS_ALLOCATIONS is set to
// "normal". Print allocation sites to stdout if DEBUG_DEVTOOLS_ALLOCATIONS is set to
// "verbose".
const DEBUG_ALLOCATIONS = env.get("DEBUG_DEVTOOLS_ALLOCATIONS");
// Maximum time spent in one test, in milliseconds
const TEST_TIMEOUT = 5 * 60000;
function getMostRecentBrowserWindow() {
return Services.wm.getMostRecentWindow("navigator:browser");
}
-function getActiveTab(window) {
- return window.gBrowser.selectedTab;
-}
-
let gmm = window.getGroupMessageManager("browsers");
const frameScript = "data:," + encodeURIComponent(`(${
function() {
addEventListener("load", function(event) {
let subframe = event.target != content.document;
sendAsyncMessage("browser-test-utils:loadEvent",
{subframe, url: event.target.documentURI});
@@ -307,18 +295,16 @@ Damp.prototype = {
if (content && content.tpRecordTime) {
content.tpRecordTime(testResults.join(","), 0, testNames.join(","));
} else {
// alert(out);
}
},
- _onTestComplete: null,
-
_doneInternal() {
// Ignore any duplicated call to this method
if (this._done) {
return;
}
this._done = true;
if (this.allocationTracker) {
@@ -327,19 +313,17 @@ Damp.prototype = {
}
this._win.gBrowser.selectedTab = this._dampTab;
if (this._results) {
this._logLine("DAMP_RESULTS_JSON=" + JSON.stringify(this._results));
this._reportAllResults();
}
- if (this._onTestComplete) {
- this._onTestComplete(JSON.parse(JSON.stringify(this._results))); // Clone results
- }
+ TalosParentProfiler.pause("DAMP - end");
},
startAllocationTracker() {
const { allocationTracker } = require("devtools/shared/test-helpers/allocation-tracker");
return allocationTracker();
},
error(message) {
@@ -394,27 +378,22 @@ Damp.prototype = {
requestIdleCallback(resolve, { timeout: 15000 });
});
// Free memory before running the first test, otherwise we may have a GC
// related to Firefox startup or DAMP setup during the first test.
await this.garbageCollect();
},
- startTest(doneCallback) {
+ startTest() {
try {
dump("Initialize the head file with a reference to this DAMP instance\n");
let head = require("chrome://damp/content/tests/head.js");
head.initialize(this);
- this._onTestComplete = function(results) {
- TalosParentProfiler.pause("DAMP - end");
- doneCallback(results);
- };
-
this._win = Services.wm.getMostRecentWindow("navigator:browser");
this._dampTab = this._win.gBrowser.selectedTab;
this._win.gBrowser.selectedBrowser.focus(); // Unfocus the URL bar to avoid caret blink
TalosParentProfiler.resume("DAMP - start");
// Filter tests via `./mach --subtests filter` command line argument
let filter = Services.prefs.getCharPref("talos.subtests", "");
--- a/testing/talos/talos/tests/devtools/addon/content/framescript.js
+++ b/testing/talos/talos/tests/devtools/addon/content/framescript.js
@@ -1,25 +1,12 @@
(function() {
- const PREFIX = "damp@mozilla.org:";
-
- addEventListener(PREFIX + "chrome-exec-event", function(e) {
- if (content.document.documentURI.indexOf("chrome://damp/content/damp.html")) {
- // Can have url fragment. Backward compatible version of !str.startsWidth("prefix")
- throw new Error("Cannot be used outside of DAMP's launch page");
- }
-
- // eslint-disable-next-line mozilla/avoid-Date-timing
- var uniqueMessageId = PREFIX + content.document.documentURI + Date.now() + Math.random();
+ const MESSAGE = "damp@mozilla.org:html-loaded";
- addMessageListener(PREFIX + "chrome-exec-reply", function done(reply) {
- if (reply.data.id == uniqueMessageId) {
- removeMessageListener(PREFIX + "chrome-exec-reply", done);
- e.detail.doneCallback(reply.data.result);
- }
- });
+ addEventListener("load", function onload(e) {
+ if (e.target.documentURI.indexOf("chrome://damp/content/damp.html")) {
+ return;
+ }
+ removeEventListener("load", onload);
- sendAsyncMessage(PREFIX + "chrome-exec-message", {
- command: e.detail.command,
- id: uniqueMessageId
- });
- }, false);
+ sendAsyncMessage(MESSAGE);
+ }, true);
})();
--- a/testing/talos/talos/tests/devtools/addon/content/initialize_browser.js
+++ b/testing/talos/talos/tests/devtools/addon/content/initialize_browser.js
@@ -1,36 +1,14 @@
function initializeBrowser(win) {
Services.scriptloader.loadSubScript("chrome://damp/content/damp.js", win);
- const PREFIX = "damp@mozilla.org:";
+ const MESSAGE = "damp@mozilla.org:html-loaded";
- // "services" which the framescript can execute at the chrome process
- var proxiedServices = {
- runTest(config, callback) {
- (new win.Damp()).startTest(callback, config);
- },
- };
-
- var groupMM = win.getGroupMessageManager("browsers");
+ const groupMM = win.getGroupMessageManager("browsers");
groupMM.loadFrameScript("chrome://damp/content/framescript.js", true);
- // listener/executor on the chrome process for damp.html
- groupMM.addMessageListener(PREFIX + "chrome-exec-message", function listener(m) {
- function sendResult(result) {
- groupMM.broadcastAsyncMessage(PREFIX + "chrome-exec-reply", {
- id: m.data.id,
- result
- });
- }
-
- var command = m.data.command;
- if (!proxiedServices.hasOwnProperty(command.name))
- throw new Error("DAMP: service doesn't exist: '" + command.name + "'");
-
- var service = proxiedServices[command.name];
- if (command.name == "runTest") // Needs async execution
- service(command.data, sendResult);
- else
- sendResult(service(command.data));
-
+ // Listen for damp.html load event before starting tests.
+ // Each tppagecycles is going to reload damp.html and re-run DAMP entirely.
+ groupMM.addMessageListener(MESSAGE, function onMessage(m) {
+ (new win.Damp()).startTest();
});
}
--- a/testing/talos/talos/tests/devtools/damp.manifest
+++ b/testing/talos/talos/tests/devtools/damp.manifest
@@ -1,1 +1,1 @@
-% chrome://damp/content/damp.html#auto
+% chrome://damp/content/damp.html