зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1466479 - Remove useless communication between damp.html and talos add-on. r=jdescottes
MozReview-Commit-ID: 6pqokJgqrnu --HG-- extra : rebase_source : 82dc3db8f57855fba68c8a00ca9e39e9a93a8e52
This commit is contained in:
Родитель
81c79d5396
Коммит
2ae882b64e
|
@ -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);
|
|
@ -2,8 +2,6 @@
|
|||
<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>
|
||||
|
|
|
@ -11,14 +11,6 @@ XPCOMUtils.defineLazyGetter(this, "require", function() {
|
|||
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
|
||||
|
@ -32,10 +24,6 @@ function getMostRecentBrowserWindow() {
|
|||
return Services.wm.getMostRecentWindow("navigator:browser");
|
||||
}
|
||||
|
||||
function getActiveTab(window) {
|
||||
return window.gBrowser.selectedTab;
|
||||
}
|
||||
|
||||
let gmm = window.getGroupMessageManager("browsers");
|
||||
|
||||
const frameScript = "data:," + encodeURIComponent(`(${
|
||||
|
@ -312,8 +300,6 @@ Damp.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_onTestComplete: null,
|
||||
|
||||
_doneInternal() {
|
||||
// Ignore any duplicated call to this method
|
||||
if (this._done) {
|
||||
|
@ -332,9 +318,7 @@ Damp.prototype = {
|
|||
this._reportAllResults();
|
||||
}
|
||||
|
||||
if (this._onTestComplete) {
|
||||
this._onTestComplete(JSON.parse(JSON.stringify(this._results))); // Clone results
|
||||
}
|
||||
TalosParentProfiler.pause("DAMP - end");
|
||||
},
|
||||
|
||||
startAllocationTracker() {
|
||||
|
@ -399,17 +383,12 @@ Damp.prototype = {
|
|||
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
|
||||
|
|
|
@ -1,25 +1,12 @@
|
|||
(function() {
|
||||
const PREFIX = "damp@mozilla.org:";
|
||||
const MESSAGE = "damp@mozilla.org:html-loaded";
|
||||
|
||||
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");
|
||||
addEventListener("load", function onload(e) {
|
||||
if (e.target.documentURI.indexOf("chrome://damp/content/damp.html")) {
|
||||
return;
|
||||
}
|
||||
removeEventListener("load", onload);
|
||||
|
||||
// eslint-disable-next-line mozilla/avoid-Date-timing
|
||||
var uniqueMessageId = PREFIX + content.document.documentURI + Date.now() + Math.random();
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
sendAsyncMessage(PREFIX + "chrome-exec-message", {
|
||||
command: e.detail.command,
|
||||
id: uniqueMessageId
|
||||
});
|
||||
}, false);
|
||||
sendAsyncMessage(MESSAGE);
|
||||
}, true);
|
||||
})();
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
% chrome://damp/content/damp.html#auto
|
||||
% chrome://damp/content/damp.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче