зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1454580 - Add a DAMP test to watch RDP/protocol.js performance. r=jryans
MozReview-Commit-ID: LQ5PyosfogU --HG-- extra : rebase_source : 5918bd7e43b72a632c6f4695dd4eeb7473ce56e6
This commit is contained in:
Родитель
89a1cd8a45
Коммит
f4fdaa67ba
|
@ -124,6 +124,10 @@ window.DAMP_TESTS = [
|
|||
name: "panelsInBackground.reload",
|
||||
path: "toolbox/panels-in-background.js",
|
||||
description: "Measure page reload time when all panels are in background"
|
||||
}, {
|
||||
name: "server.protocoljs",
|
||||
path: "server/protocol.js",
|
||||
description: "Measure RDP/protocol.js performance"
|
||||
},
|
||||
// ⚠ Adding new individual tests slows down DAMP execution ⚠
|
||||
// ⚠ Consider contributing to custom.${tool} rather than adding isolated tests ⚠
|
||||
|
|
|
@ -117,7 +117,7 @@ exports.closeToolbox = async function() {
|
|||
};
|
||||
|
||||
exports.openToolboxAndLog = async function(name, tool, onLoad) {
|
||||
let test = runTest(name + ".open.DAMP");
|
||||
let test = runTest(name + ".open.DAMP");
|
||||
let toolbox = await openToolbox(tool, onLoad);
|
||||
test.done();
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
|
||||
const { dampTestSpec } = require("./spec");
|
||||
|
||||
exports.DampTestActor = protocol.ActorClassWithSpec(dampTestSpec, {
|
||||
initialize(conn) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
},
|
||||
|
||||
testMethod(arg, { option }, arraySize) {
|
||||
// Emit an event with second argument's option.
|
||||
this.emit("testEvent", option);
|
||||
|
||||
// Returns back an array of repetition of first argument.
|
||||
return arg;
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { openToolbox, closeToolbox, testSetup, testTeardown, runTest,
|
||||
SIMPLE_URL } = require("../head");
|
||||
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { dampTestSpec } = require("./spec");
|
||||
|
||||
// Test parameters
|
||||
const ATTRIBUTES = 10;
|
||||
const STRING_SIZE = 1000;
|
||||
const ARRAY_SIZE = 50;
|
||||
const REPEAT = 300;
|
||||
|
||||
const DampTestFront = protocol.FrontClassWithSpec(dampTestSpec, {
|
||||
initialize(client, tabForm) {
|
||||
this.actorID = tabForm.dampTestActor;
|
||||
protocol.Front.prototype.initialize.call(this, client);
|
||||
// Root owns itself.
|
||||
this.manage(this);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = async function() {
|
||||
let tab = await testSetup(SIMPLE_URL);
|
||||
let messageManager = tab.linkedBrowser.messageManager;
|
||||
|
||||
// Register a test actor within the content process
|
||||
messageManager.loadFrameScript("data:,(" + encodeURIComponent(
|
||||
`function () {
|
||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
DebuggerServer.registerModule("chrome://damp/content/tests/server/actor.js", {
|
||||
prefix: "dampTest",
|
||||
constructor: "DampTestActor",
|
||||
type: { tab: true }
|
||||
});
|
||||
}`
|
||||
) + ")()", true);
|
||||
|
||||
// Create test payloads
|
||||
let bigString = "";
|
||||
for (let i = 0; i < STRING_SIZE; i++) {
|
||||
bigString += "x";
|
||||
}
|
||||
|
||||
let bigObject = {};
|
||||
for (let i = 0; i < ATTRIBUTES; i++) {
|
||||
bigObject["attribute-" + i] = bigString;
|
||||
}
|
||||
|
||||
let bigArray = Array.from({length: ARRAY_SIZE}, (_, i) => bigObject);
|
||||
|
||||
// Open against options to avoid noise from tools
|
||||
let toolbox = await openToolbox("options");
|
||||
|
||||
// Instanciate a front for this test actor
|
||||
let { target } = toolbox;
|
||||
let front = DampTestFront(target.client, target.form);
|
||||
|
||||
// Execute the core of this test, call one method multiple times
|
||||
// and listen for an event sent by this method
|
||||
let test = runTest("server.protocoljs.DAMP");
|
||||
for (let i = 0; i < REPEAT; i++) {
|
||||
let onEvent = front.once("testEvent");
|
||||
await front.testMethod(bigArray, { option: bigArray }, ARRAY_SIZE);
|
||||
await onEvent;
|
||||
}
|
||||
test.done();
|
||||
|
||||
await closeToolbox();
|
||||
await testTeardown();
|
||||
};
|
|
@ -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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {Arg, Option, RetVal, types} = protocol;
|
||||
|
||||
types.addDictType("test.option", {
|
||||
"attribute-1": "string",
|
||||
"attribute-2": "string",
|
||||
"attribute-3": "string",
|
||||
"attribute-4": "string",
|
||||
"attribute-5": "string",
|
||||
"attribute-6": "string",
|
||||
"attribute-7": "string",
|
||||
"attribute-9": "string",
|
||||
"attribute-10": "string",
|
||||
});
|
||||
const dampTestSpec = protocol.generateActorSpec({
|
||||
typeName: "dampTest",
|
||||
|
||||
events: {
|
||||
"testEvent": { arg: Arg(0, "array:json") },
|
||||
},
|
||||
|
||||
methods: {
|
||||
testMethod: {
|
||||
request: {
|
||||
arg: Arg(0, "array:json"),
|
||||
option: Option(1, "array:test.option"),
|
||||
arraySize: Arg(2, "number"),
|
||||
},
|
||||
response: { value: RetVal("array:json") },
|
||||
},
|
||||
}
|
||||
});
|
||||
exports.dampTestSpec = dampTestSpec;
|
Загрузка…
Ссылка в новой задаче