Bug 1419328 - Run DAMP test against a document specific to the webconsole. r=nchevobbe

MozReview-Commit-ID: Dzyh733rgfG

--HG--
extra : rebase_source : 8d082d26d46ca67f03a65d03115eebaa72105f89
This commit is contained in:
Alexandre Poirot 2017-11-17 03:27:10 -08:00
Родитель 5c052cc871
Коммит c4601413b4
3 изменённых файлов: 84 добавлений и 14 удалений

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

@ -28,6 +28,7 @@ var defaultConfig = {
"complicated.netmonitor": true,
"complicated.saveAndReadHeapSnapshot": true,
"custom.webconsole": true,
"custom.inspector": true,
"custom.debugger": true,

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

@ -793,6 +793,35 @@ async _consoleOpenWithCachedMessagesTest() {
await this.testTeardown();
},
async reloadConsoleAndLog(label, toolbox, expectedMessages) {
let onReload = async function() {
let webconsole = toolbox.getPanel("webconsole");
await new Promise(done => {
let messages = 0;
let receiveMessages = () => {
if (++messages == expectedMessages) {
webconsole.hud.ui.off("new-messages", receiveMessages);
done();
}
};
webconsole.hud.ui.on("new-messages", receiveMessages);
});
};
await this.reloadPageAndLog(label + ".webconsole", toolbox, onReload);
},
async customConsole() {
// These numbers controls the number of console api calls we do in the test
let sync = 250, stream = 250, async = 250;
let page = `console.html?sync=${sync}&stream=${stream}&async=${async}`;
let url = CUSTOM_URL.replace(/\$TOOL\.html/, page);
await this.testSetup(url);
let toolbox = await this.openToolboxAndLog("custom.webconsole", "webconsole");
await this.reloadConsoleAndLog("custom", toolbox, sync + stream + async);
await this.closeToolboxAndLog("custom.webconsole", toolbox);
await this.testTeardown();
},
_getToolLoadingTests(url, label, {
expectedMessages,
expectedRequests,
@ -812,20 +841,7 @@ async _consoleOpenWithCachedMessagesTest() {
async webconsole() {
await this.testSetup(url);
let toolbox = await this.openToolboxAndLog(label + ".webconsole", "webconsole");
let onReload = async function() {
let webconsole = toolbox.getPanel("webconsole");
await new Promise(done => {
let messages = 0;
let receiveMessages = () => {
if (++messages == expectedMessages) {
webconsole.hud.ui.off("new-messages", receiveMessages);
done();
}
};
webconsole.hud.ui.on("new-messages", receiveMessages);
});
};
await this.reloadPageAndLog(label + ".webconsole", toolbox, onReload);
await this.reloadConsoleAndLog(label, toolbox, expectedMessages);
await this.closeToolboxAndLog(label + ".webconsole", toolbox);
await this.testTeardown();
},
@ -1081,6 +1097,7 @@ async _consoleOpenWithCachedMessagesTest() {
// Run all tests against a document specific to each tool
tests["custom.inspector"] = this.customInspector;
tests["custom.debugger"] = this.customDebugger;
tests["custom.webconsole"] = this.customConsole;
// Run individual tests covering a very precise tool feature
tests["console.bulklog"] = this._consoleBulkLoggingTest;

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

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Custom page for the Console</title>
</head>
<body>
<script>
// These query parameters are set in damp.js:customConsole and define the number
// of console API calls we do in this test.
let searchParams = new URLSearchParams(location.search);
let sync = searchParams.get("sync");
let stream = searchParams.get("stream");
let async = searchParams.get("async");
// We log complex objects:
// * a complex js object (window)
// * a DOM node (body)
// * a large array
let bigArray = Array.from({length: 10000}, (_, i) => i);
// Fill up the console with many logs synchronously during page load.
for (let i = 0; i < sync; i++) {
console.log("sync log", i, window, document.body, bigArray);
}
// Then, do streamlogs, log asynchronously a lot of messages
let n = 0;
function streamLogs() {
console.log("stream log", n++, window, document.body, bigArray);
if (n < stream) {
requestAnimationFrame(streamLogs);
} else {
requestIdleCallback(asyncLogs);
}
}
requestIdleCallback(streamLogs);
// Finally, we log by small bulk asynchronously slightly more slowly thanks to idle callback
let x = 0;
function asyncLogs() {
let asyncBulk = 10;
for (let i = 0; i < asyncBulk; i++) {
console.log("async log", x++, window, document.body, bigArray);
}
if (x < async) {
requestIdleCallback(asyncLogs);
}
}
</script>
</body>
</html>