Bug 1419327 - Run DAMP test against a document specific to the netmonitor. r=Honza
MozReview-Commit-ID: EfpdFpCUM69
--- 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,
"inspector.layout": true,
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -264,22 +264,36 @@ Damp.prototype = {
} else if (DEBUG_ALLOCATIONS == "verbose") {
this.allocationTracker.logAllocationSites();
}
}
};
},
addTab(url) {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
let tab = this._win.gBrowser.selectedTab = this._win.gBrowser.addTab(url);
- let browser = tab.linkedBrowser;
- browser.addEventListener("load", function onload() {
+ // We have to use a frame script as listening for "load" event
+ // on <browser> is subject to races as this event may fire during the call to
+ // addTab for really small documents.
+ let mm = tab.linkedBrowser.messageManager;
+ mm.addMessageListener("damp-tab-loaded", function listener() {
+ mm.removeMessageListener("damp-tab-loaded", listener);
resolve(tab);
- }, {capture: true, once: true});
+ });
+ mm.loadFrameScript("data:,new " + function() {
+ if (content.document.readyState == "complete") {
+ sendAsyncMessage("damp-tab-loaded");
+ } else {
+ addEventListener("load", function onload() {
+ sendAsyncMessage("damp-tab-loaded");
+ }, {capture: true, once: true});
+ }
+ }, false);
+
});
},
closeCurrentTab() {
this._win.BrowserCloseTabOrWindow();
return this._win.gBrowser.selectedTab;
},
@@ -816,16 +830,73 @@ async _consoleOpenWithCachedMessagesTest
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();
},
+ async customNetmonitor() {
+ // These numbers controls the number of requests we do in the test
+ let bigFileRequests = 20, postDataRequests = 20, xhrRequests = 50;
+ // These other numbers only state how many requests the test do,
+ // we have to keep them in sync with netmonitor.html static content
+ let syncCssRequests = 10, syncJSRequests = 10, syncIframeRequests = 3 * 10;
+ let expectedRequests = 1 + syncCssRequests + syncJSRequests + syncIframeRequests +
+ bigFileRequests + postDataRequests + xhrRequests;
+ let page = `netmonitor.html?bigFileRequests=${bigFileRequests}&postDataRequests=${postDataRequests}&xhrRequests=${xhrRequests}`;
+ let url = CUSTOM_URL.replace(/\$TOOL\.html/, page);
+
+ // First load an empty document in order to be sure of registering DOMContentLoaded
+ // listener before its dispatch from custom document.
+ let tab = await this.testSetup("data:text/html;charset=utf-8,custom-netmonitor");
+ let { messageManager } = tab.linkedBrowser;
+ let onReady = new Promise(done => {
+ messageManager.addMessageListener("ready", done);
+ });
+ messageManager.loadFrameScript("data:,(" + encodeURIComponent(
+ `function () {
+ addEventListener("DOMContentLoaded", function () {
+ content.addEventListener("message", function () {
+ sendAsyncMessage("ready");
+ });
+ }, true);
+ }`
+ ) + ")()", true);
+ tab.linkedBrowser.loadURI(url);
+
+ // We wait for a custom "ready" event in order to ensure all the requests
+ // done during document load are finished before opening the netmonitor.
+ // Otherwise some still pending requests will be displayed on toolbox open
+ // and the number of requests being displayed will be random and introduce noise
+ // in custom.netmonitor.open
+ dump("Waiting for document to be ready and have sent all its requests\n");
+ await onReady;
+
+ const toolbox = await this.openToolboxAndLog("custom.netmonitor", "netmonitor");
+
+ // Waterfall will only work after an idle event. Its width is only set after idle.
+ // Before that, it doesn't render.
+ dump("Waiting for idle in order to ensure running reload with a waterfall\n");
+ let window = toolbox.getCurrentPanel().panelWin;
+ await new Promise(done => {
+ window.requestIdleCallback(done);
+ });
+
+ // This number is to update according to pages/custom/netmonitor.html behavior
+ const requestsDone = this.waitForNetworkRequests("custom.netmonitor", toolbox,
+ expectedRequests);
+ await this.reloadPageAndLog("custom.netmonitor", toolbox);
+ await requestsDone;
+
+ await this.closeToolboxAndLog("custom.netmonitor", toolbox);
+ await this.testTeardown();
+ },
+
_getToolLoadingTests(url, label, {
expectedMessages,
expectedRequests,
expectedSources,
selectedFile,
expectedText,
}) {
let tests = {
@@ -1092,16 +1163,17 @@ async _consoleOpenWithCachedMessagesTest
selectedFile: "ga.js",
expectedText: "Math;function ga(a,b){return a.name=b}"
}));
// 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;
+ 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;
tests["inspector.layout"] = this._inspectorLayoutTest;
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor.html
@@ -0,0 +1,139 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Custom page for the Netmonitor</title>
+
+ <!-- 10 css requests -->
+ <!-- count to keep in sync in damp.js:customNetmonitor -->
+ <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" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?4" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?5" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?6" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?7" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?8" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?9" />
+ <link rel="stylesheet" type="text/css" href="netmonitor/style.css?10" />
+
+ <style>
+ iframe {
+ width: 100px;
+ height: 50px;
+ border: 1px solid black;
+ }
+ span {
+ font-size: 5px;
+ }
+ </style>
+</head>
+<body>
+
+<h1>Performance test page for the network monitor.</h1>
+
+<!-- 10 js requests -->
+<!-- count to keep in sync in damp.js:customNetmonitor -->
+<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>
+<script type="text/javascript" src="netmonitor/script.js?4"></script>
+<script type="text/javascript" src="netmonitor/script.js?5"></script>
+<script type="text/javascript" src="netmonitor/script.js?6"></script>
+<script type="text/javascript" src="netmonitor/script.js?7"></script>
+<script type="text/javascript" src="netmonitor/script.js?8"></script>
+<script type="text/javascript" src="netmonitor/script.js?9"></script>
+<script type="text/javascript" src="netmonitor/script.js?10"></script>
+
+<!-- each of these iframe will do 3 requests
+ 30 iframe related requests -->
+<!-- count to keep in sync in damp.js:customNetmonitor -->
+<iframe src="netmonitor/iframe.html?1"></iframe>
+<iframe src="netmonitor/iframe.html?2"></iframe>
+<iframe src="netmonitor/iframe.html?3"></iframe>
+<iframe src="netmonitor/iframe.html?4"></iframe>
+<iframe src="netmonitor/iframe.html?5"></iframe>
+<iframe src="netmonitor/iframe.html?6"></iframe>
+<iframe src="netmonitor/iframe.html?7"></iframe>
+<iframe src="netmonitor/iframe.html?8"></iframe>
+<iframe src="netmonitor/iframe.html?9"></iframe>
+<iframe src="netmonitor/iframe.html?10"></iframe>
+
+<script>
+// These query parameters are set in damp.js:customNetmonitor and define the various
+// threshold we use to run this test.
+let searchParams = new URLSearchParams(location.search);
+let bigFileRequests = searchParams.get("bigFileRequests");
+let postDataRequests = searchParams.get("postDataRequests");
+let xhrRequests = searchParams.get("xhrRequests");
+
+// Do one XHR against a significant size file
+async function requestBigFile() {
+ await fetch("/tests/video/clips/testsrc.1080p.60fps.mp4?" + Math.round(Math.random() * 10000));
+}
+
+// Do one XHR with significant post data
+function requestPostData() {
+ let postDataSize = 500000, postDataFields = 10;
+
+ let xhr = new XMLHttpRequest();
+ xhr.open("POST", "netmonitor/script.js?post-data", true);
+ // Override mime type to prevent "XML Parsing Error"
+ xhr.overrideMimeType("text/plain");
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ let postData = [];
+ for (let i = 0; i < postDataFields; i++) {
+ postData.push("a" + i + "=" + i);
+ }
+ // Include one field that fakes a 500k file upload.
+ postData.push("data=" + new Array(postDataSize).join("x"));
+ xhr.send(postData.join("&"));
+ return new Promise(done => {
+ xhr.onload = done;
+ });
+}
+
+// Do many XHR against smaller files
+let headersCount = 100, headerDataSize;
+let headers = new Headers();
+for (let i = 0; i < headersCount; i++) {
+ headers.append("X-Custom-Header-" + i, "header");
+}
+// Set one significant headers, 10K
+headers.append("X-Custom-Header-data", new Array(headerDataSize).join("x"));
+async function doManyXHR(howMany) {
+ for (let i = 0; i < howMany; i++) {
+ await fetch("netmonitor/script.js?xhr=" + i, { headers });
+ }
+}
+
+// Force some DOM updates to better simulate a single page webapp
+// which is going to create its DOM dynamically.
+// This will help seeing if the page load slow down because
+// of netmonitor listeners.
+let interval = setInterval(function forcePaint() {
+ let div = document.createElement("span");
+ div.textContent = " force paint ";
+ document.body.appendChild(div);
+}, 20);
+
+window.onload = async function() {
+ for (let i = 0; i < bigFileRequests; i++) {
+ await requestBigFile();
+ }
+ for (let i = 0; i < postDataRequests; i++) {
+ await requestPostData();
+ }
+ await doManyXHR(xhrRequests);
+
+ // Tells damp test script when all request are sent
+ window.postMessage("ready", "*");
+
+ // Stop forcing reflows once all the request are done
+ clearInterval(interval);
+}
+
+
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor/iframe.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Custom page for the Netmonitor</title>
+
+ <link rel="stylesheet" type="text/css" href="style.css?iframe" />
+</head>
+<body>
+
+<script type="text/javascript" src="script.js?iframe"></script>
+
+Iframe
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor/script.js
@@ -0,0 +1,100 @@
+/**
+ ****************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ *****************************************************************************************************************************************/
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/netmonitor/style.css
@@ -0,0 +1,99 @@
+/******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ ******************************************************************************************************************************************
+ *****************************************************************************************************************************************/