Bug 1419350 - Update tests; r=ochameau
MozReview-Commit-ID: ArLb7ItI9hT
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -18,19 +18,21 @@ XPCOMUtils.defineLazyGetter(this, "EVENT
});
XPCOMUtils.defineLazyGetter(this, "TargetFactory", function() {
let { TargetFactory } = require("devtools/client/framework/target");
return TargetFactory;
});
const webserver = Services.prefs.getCharPref("addon.test.damp.webserver");
-const SIMPLE_URL = webserver + "/tests/devtools/addon/content/pages/simple.html";
+const PAGES_BASE_URL = webserver + "/tests/devtools/addon/content/pages/";
+const SIMPLE_URL = PAGES_BASE_URL + "simple.html";
const COMPLICATED_URL = webserver + "/tests/tp5n/bild.de/www.bild.de/index.html";
-const CUSTOM_URL = webserver + "/tests/devtools/addon/content/pages/custom/$TOOL.html";
+const CUSTOM_URL = PAGES_BASE_URL + "custom/$TOOL.html";
+const PANELS_IN_BACKGROUND = PAGES_BASE_URL + "custom/panels-in-background.html";
// 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
// "verbose".
const DEBUG_ALLOCATIONS = env.get("DEBUG_DEVTOOLS_ALLOCATIONS");
function getMostRecentBrowserWindow() {
return Services.wm.getMostRecentWindow("navigator:browser");
@@ -709,37 +711,57 @@ async _consoleOpenWithCachedMessagesTest
async _coldInspectorOpen() {
await this.testSetup(SIMPLE_URL);
await this.openToolboxAndLog("cold.inspector", "inspector");
await this.closeToolbox();
await this.testTeardown();
},
async _panelsInBackgroundReload() {
- let url = "data:text/html;charset=UTF-8," + encodeURIComponent(`
- <script>
- // Log a significant amount of messages
- for(let i = 0; i < 2000; i++) {
- console.log("log in background", i);
- }
- </script>
- `);
- await this.testSetup(url);
+ await this.testSetup(PANELS_IN_BACKGROUND);
+
+ // Make sure the Console and Network panels are initialized
let toolbox = await this.openToolbox("webconsole");
+ let monitor = await toolbox.selectTool("netmonitor");
- // Select the options panel to make the console be in background.
+ // Select the options panel to make both the Console and Network
+ // panel be in background.
// Options panel should not do anything on page reload.
await toolbox.selectTool("options");
+ // Reload the page and wait for all HTTP requests
+ // to finish (1 doc + 800 XHRs).
await this.reloadPageAndLog("panelsInBackground", toolbox);
+ await this.waitForPayload(801, monitor.panelWin);
+ // Clean up
await this.closeToolbox();
await this.testTeardown();
},
+ waitForPayload(count, panelWin) {
+ return new Promise(resolve => {
+ let payloadReady = 0;
+
+ function onPayloadReady(_, id) {
+ payloadReady++;
+ maybeResolve();
+ }
+
+ function maybeResolve() {
+ if (payloadReady === count) {
+ panelWin.off(EVENTS.PAYLOAD_READY, onPayloadReady);
+ resolve();
+ }
+ }
+
+ panelWin.on(EVENTS.PAYLOAD_READY, onPayloadReady);
+ });
+ },
+
async reloadInspectorAndLog(label, toolbox) {
let onReload = async function() {
let inspector = toolbox.getPanel("inspector");
// First wait for markup view to be loaded against the new root node
await inspector.once("new-root");
// Then wait for inspector to be updated
await inspector.once("inspector-updated");
};
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/panels-in-background.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<!-- 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/. -->
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Custom page for panels running in background</title>
+</head>
+<body>
+<script type="application/x-javascript">
+ function peformLogs(count) {
+ for (let i = 0; i < count; i++) {
+ console.log("log in background", i);
+ }
+ }
+
+ function performRequests(count) {
+ for (let i = 0; i < count; i++) {
+ let xhr = new XMLHttpRequest();
+ xhr.open("GET", "sjs_simple-test-server.sjs", true);
+ xhr.send(null);
+ }
+ }
+
+ peformLogs(2000);
+ performRequests(800);
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/custom/sjs_simple-test-server.sjs
@@ -0,0 +1,7 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function handleRequest(request, response) {
+ response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
+ response.write("Hello world!");
+}