Bug 1415532 - Run DAMP test against a document specific to the netmonitor. r=Honza
MozReview-Commit-ID: EfpdFpCUM69
--- a/devtools/client/netmonitor/src/middleware/batching.js
+++ b/devtools/client/netmonitor/src/middleware/batching.js
@@ -10,21 +10,21 @@ const REQUESTS_REFRESH_RATE = 50; // ms
/**
* Middleware that watches for actions with a "batch = true" value in their meta field.
* These actions are queued and dispatched as one batch after a timeout.
* Special actions that are handled by this middleware:
* - BATCH_ENABLE can be used to enable and disable the batching.
* - BATCH_RESET discards the actions that are currently in the queue.
*/
+let flushTask = null;
function batchingMiddleware(store) {
return next => {
let queuedActions = [];
let enabled = true;
- let flushTask = null;
return action => {
if (action.type === BATCH_ENABLE) {
return setEnabled(action.enabled);
}
if (action.type === BATCH_RESET) {
return resetQueue();
@@ -124,8 +124,15 @@ DelayedTask.prototype = {
clearTimeout(this.timeout);
if (this.runTask) {
this.runTask();
}
}
};
module.exports = batchingMiddleware;
+
+batchingMiddleware.onAllTaskFlushed = function () {
+ if (!flushTask) {
+ return Promise.resolve();
+ }
+ return flushTask.promise;
+}
--- a/testing/talos/talos/tests/devtools/addon/content/damp.html
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.html
@@ -26,16 +26,17 @@ var defaultConfig = {
"complicated.styleeditor": true,
"complicated.performance": true,
"complicated.netmonitor": true,
"complicated.saveAndReadHeapSnapshot": true,
"custom.webconsole": true,
"custom.inspector": true,
"custom.debugger": true,
+ "custom.netmonitor": true,
"console.bulklog": true,
"console.streamlog": true,
"console.objectexpand": true,
"console.openwithcache": true,
"inspector.mutations": true,
}
};
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -65,17 +65,17 @@ Damp.prototype = {
return this._win.gBrowser.selectedTab;
},
reloadPage(onReload) {
let startReloadTimestamp = performance.now();
return new Promise((resolve, reject) => {
let browser = gBrowser.selectedBrowser;
if (typeof (onReload) == "function") {
- onReload().then(function() {
+ onReload(browser).then(function() {
let stopReloadTimestamp = performance.now();
resolve({
time: stopReloadTimestamp - startReloadTimestamp
});
});
} else {
browser.addEventListener("load", function onload() {
let stopReloadTimestamp = performance.now();
@@ -543,16 +543,53 @@ async _consoleOpenWithCachedMessagesTest
let url = CUSTOM_URL.replace(/\$TOOL/, "debugger");
await this.testSetup(url);
let toolbox = await this.openDebuggerAndLog(label);
await this.reloadDebuggerAndLog(label, toolbox);
await this.closeToolboxAndLog(label + ".jsdebugger");
await this.testTeardown();
},
+ async customNetmonitor() {
+ let url = CUSTOM_URL.replace(/\$TOOL/, "netmonitor");
+ await this.testSetup(url);
+ const toolbox = await this.openToolboxAndLog("custom.netmonitor", "netmonitor");
+ let onReload = async (browser) => {
+ await new Promise(done => {
+ browser.addEventListener("load", done, { capture: true, once: true });
+ });
+
+ let window = toolbox.getCurrentPanel().panelWin;
+ dump("window:"+window+"\n");
+ dump("connector:"+window.connector+"\n");
+ dump("dp:"+window.connector.connector.dataProvider+"\n");
+ let { dataProvider } = window.connector.connector;
+ if (dataProvider && dataProvider.isPayloadQueueEmpty()) {
+ return;
+ }
+ await new Promise(done => {
+ let listener = () => {
+ if (!dataProvider.isPayloadQueueEmpty()) {
+ return;
+ }
+ dump("payload empty!\n");
+ window.off(EVENTS.PAYLOAD_READY, listener);
+ done();
+ }
+ window.on(EVENTS.PAYLOAD_READY, listener);
+ });
+ let { onAllTaskFlushed } = require("devtools/client/netmonitor/src/middleware/batching");
+ await onAllTaskFlushed();
+ dump("all task flushed!\n");
+ }
+ await this.reloadPageAndLog("custom.netmonitor", onReload);
+ await this.closeToolboxAndLog("custom.netmonitor");
+ await this.testTeardown();
+ },
+
_getToolLoadingTests(url, label, { expectedMessages, expectedSources }) {
let tests = {
async inspector() {
await this.testSetup(url);
let toolbox = await this.openToolboxAndLog(label + ".inspector", "inspector");
await this.reloadInspectorAndLog(label, toolbox);
await this.closeToolboxAndLog(label + ".inspector");
await this.testTeardown();
@@ -793,16 +830,17 @@ async _consoleOpenWithCachedMessagesTest
expectedMessages: 7,
expectedSources: 14,
}));
// Run all tests against a document specific to each tool
tests["custom.inspector"] = this.customInspector;
tests["custom.webconsole"] = this.customConsole;
tests["custom.debugger"] = this.customDebugger;
+ tests["custom.netmonitor"] = this.customNetmonitor;
// Run individual tests covering a very precise tool feature
tests["console.bulklog"] = this._consoleBulkLoggingTest;
tests["console.streamlog"] = this._consoleStreamLoggingTest;
tests["console.objectexpand"] = this._consoleObjectExpansionTest;
tests["console.openwithcache"] = this._consoleOpenWithCachedMessagesTest;
tests["inspector.mutations"] = this._inspectorMutationsTest;
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Custom page for the Console</title>
+
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?1" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?2" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?3" />
+</head>
+<body>
+
+<script type="text/javascript" src="netmonitor/script.js?1"></script>
+<script type="text/javascript" src="netmonitor/script.js?2"></script>
+<script type="text/javascript" src="netmonitor/script.js?3"></script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor/script.js
@@ -0,0 +1,99 @@
+/******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ *****************************************************************************************************************************************/
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor/style.css
@@ -0,0 +1,99 @@
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}
+body {
+ background: #f0f0f0;
+}