Bug 1566850 - Remove target.activeConsole usage in tests. r=ochameau.
☠☠ backed out by 535b50b4c504 ☠ ☠
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Fri, 13 Dec 2019 09:10:33 +0000
changeset 506847 33c4706a425593d57c2dce5073ea7ddf5b5b8223
parent 506846 1796a39b020bf7b87b1d640b2caea0bf5a953b09
child 506848 55ac64d7472555b142b0de681fd2da8d12944bb5
push id36913
push useropoprus@mozilla.com
push dateFri, 13 Dec 2019 16:53:24 +0000
treeherdermozilla-central@1ed684598bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1566850
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1566850 - Remove target.activeConsole usage in tests. r=ochameau. Differential Revision: https://phabricator.services.mozilla.com/D56688
devtools/client/framework/test/browser_target_parents.js
devtools/client/framework/test/browser_two_tabs.js
devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js
devtools/client/webconsole/test/browser/browser_console_cpow.js
devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js
devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js
devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js
devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js
devtools/server/tests/browser/browser_webextension_inspected_window.js
devtools/server/tests/mochitest/webconsole-helpers.js
devtools/shared/webconsole/test/browser/browser_commands_registration.js
devtools/shared/webconsole/test/browser/browser_network_longstring.js
devtools/shared/webconsole/test/common.js
--- a/devtools/client/framework/test/browser_target_parents.js
+++ b/devtools/client/framework/test/browser_target_parents.js
@@ -58,18 +58,18 @@ add_task(async function() {
         }
         promises.push(
           targetPromise.then(target => {
             is(
               target.descriptorFront,
               processDescriptor,
               "Got the correct descriptorFront from the process target."
             );
-            // activeConsole is one of the only attribute to assess that a Content Process Target is attached
-            ok(target.activeConsole, "The target is attached");
+            // Content Process Target is attached when it has a console front.
+            ok(target.getCachedFront("console"), "The target is attached");
             return target;
           })
         );
       }
       const targets = await Promise.all(promises);
       for (let i = 1; i < concurrentCalls; i++) {
         is(
           targets[0],
--- a/devtools/client/framework/test/browser_two_tabs.js
+++ b/devtools/client/framework/test/browser_two_tabs.js
@@ -79,24 +79,26 @@ async function checkGetTabFailures(clien
       "Protocol error (noTab): Unable to find tab with outerWindowID '-999'"
     );
   }
 }
 
 async function checkSelectedTargetActor(targetFront2) {
   // Send a naive request to the second target actor to check if it works
   await targetFront2.attach();
-  const response = await targetFront2.activeConsole.startListeners([]);
+  const consoleFront = await targetFront2.getFront("console");
+  const response = await consoleFront.startListeners([]);
   ok(
     "startedListeners" in response,
     "Actor from the selected tab should respond to the request."
   );
 }
 
 async function checkFirstTargetActor(targetFront1) {
   // then send a request to the first target actor to check if it still works
   await targetFront1.attach();
-  const response = await targetFront1.activeConsole.startListeners([]);
+  const consoleFront = await targetFront1.getFront("console");
+  const response = await consoleFront.startListeners([]);
   ok(
     "startedListeners" in response,
     "Actor from the first tab should still respond."
   );
 }
--- a/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js
+++ b/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js
@@ -150,22 +150,23 @@ add_task(async function testSidebarSetOb
   const expression = `
     var obj = Object.create(null);
     obj.prop1 = 123;
     obj[Symbol('sym1')] = 456;
     obj.cyclic = obj;
     obj;
   `;
 
+  const consoleFront = await toolbox.target.getFront("console");
   const evalResult = await inspectedWindowFront.eval(
     fakeExtCallerInfo,
     expression,
     {
       evalResultAsGrip: true,
-      toolboxConsoleActorID: toolbox.target.activeConsole.actor,
+      toolboxConsoleActorID: consoleFront.actor,
     }
   );
 
   sidebar.setObjectValueGrip(evalResult.valueGrip, "Expected Root Title");
 
   // Wait the ObjectInspector component to be rendered and test its content.
   await testSetExpressionSidebarPanel(sidebarPanelContent, {
     nodesLength: 4,
@@ -232,22 +233,23 @@ add_task(async function testSidebarDOMNo
   const inspectedWindowFront = await toolbox.target.getFront(
     "webExtensionInspectedWindow"
   );
   const sidebar = inspector.getPanel(SIDEBAR_ID);
   const sidebarPanelContent = inspector.sidebar.getTabPanel(SIDEBAR_ID);
 
   const expression = "({ body: document.body })";
 
+  const consoleFront = await toolbox.target.getFront("console");
   const evalResult = await inspectedWindowFront.eval(
     fakeExtCallerInfo,
     expression,
     {
       evalResultAsGrip: true,
-      toolboxConsoleActorID: toolbox.target.activeConsole.actor,
+      toolboxConsoleActorID: consoleFront.actor,
     }
   );
 
   sidebar.setObjectValueGrip(evalResult.valueGrip);
 
   // Wait the DOM node to be rendered inside the component.
   await waitForObjectInspector(sidebarPanelContent, "node");
 
--- a/devtools/client/webconsole/test/browser/browser_console_cpow.js
+++ b/devtools/client/webconsole/test/browser/browser_console_cpow.js
@@ -30,17 +30,18 @@ async function obtainObjectWithCPOW(hud)
       Services.ppmm.removeMessageListener("cpow", listener);
       console.log(message.objects);
       globalThis.result = message.objects;
     });
   `);
 
   info("Open the browser content toolbox and send a message");
   const toolbox = await gDevToolsBrowser.openContentProcessToolbox(gBrowser);
-  await toolbox.target.activeConsole.evaluateJSAsync(`
+  const webConsoleFront = await toolbox.target.getFront("console");
+  await webConsoleFront.evaluateJSAsync(`
     let {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
     Services.cpmm.sendAsyncMessage("cpow", null, {cpow: {a:1}});
   `);
 
   info("Obtain the object with CPOW");
   const message = await waitFor(() => findMessage(hud, "cpow"));
   const result = await hud.evaluateJSAsync("result");
   const objectFront = result.result;
--- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js
+++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js
@@ -60,33 +60,33 @@ add_task(async function() {
 
   await closeTabAndToolbox().catch(() => {});
 });
 
 async function generateConsoleApiStubs() {
   const stubs = new Map();
 
   const hud = await openNewTabAndConsole(TEST_URI);
-
   const target = hud.currentTarget;
+  const webConsoleFront = await target.getFront("console");
 
   for (const { keys, code } of getCommands()) {
     const received = new Promise(resolve => {
       let i = 0;
       const listener = async res => {
         const callKey = keys[i];
 
         stubs.set(callKey, getCleanedPacket(callKey, res));
 
         if (++i === keys.length) {
-          target.activeConsole.off("consoleAPICall", listener);
+          webConsoleFront.off("consoleAPICall", listener);
           resolve();
         }
       };
-      target.activeConsole.on("consoleAPICall", listener);
+      webConsoleFront.on("consoleAPICall", listener);
     });
 
     await ContentTask.spawn(gBrowser.selectedBrowser, code, function(subCode) {
       const script = content.document.createElement("script");
       script.append(
         content.document.createTextNode(`function triggerPacket() {${subCode}}`)
       );
       content.document.body.append(script);
--- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js
+++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js
@@ -58,22 +58,22 @@ add_task(async function() {
   } else {
     ok(true, "Stubs are up to date");
   }
 });
 
 async function generateCssMessageStubs() {
   const stubs = new Map();
   const toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");
+  const webConsoleFront = await toolbox.target.getFront("console");
 
   for (const code of getCommands()) {
     const received = new Promise(resolve => {
       /* CSS errors are considered as pageError on the server */
-      toolbox.target.activeConsole.on("pageError", function onPacket(packet) {
-        toolbox.target.activeConsole.off("pageError", onPacket);
+      webConsoleFront.once("pageError", function onPacket(packet) {
         info(
           "Received css message: pageError " +
             JSON.stringify(packet, null, "\t")
         );
 
         const key = packet.pageError.errorMessage;
         stubs.set(key, getCleanedPacket(key, packet));
         resolve();
--- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js
+++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_evaluation_result.js
@@ -58,19 +58,19 @@ add_task(async function() {
   }
 
   await closeTabAndToolbox();
 });
 
 async function generateEvaluationResultStubs() {
   const stubs = new Map();
   const toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");
-
+  const webConsoleFront = await toolbox.target.getFront("console");
   for (const [key, code] of getCommands()) {
-    const packet = await toolbox.target.activeConsole.evaluateJSAsync(code);
+    const packet = await webConsoleFront.evaluateJSAsync(code);
     stubs.set(key, getCleanedPacket(key, packet));
   }
 
   return stubs;
 }
 
 function getCommands() {
   const evaluationResultCommands = [
--- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js
+++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js
@@ -59,19 +59,19 @@ add_task(async function() {
   }
 
   await closeTabAndToolbox();
 });
 
 async function generatePageErrorStubs() {
   const stubs = new Map();
   const toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");
-
+  const webConsoleFront = await toolbox.target.getFront("console");
   for (const [key, code] of getCommands()) {
-    const onPageError = toolbox.target.activeConsole.once("pageError");
+    const onPageError = webConsoleFront.once("pageError");
 
     // On e10s, the exception is triggered in child process
     // and is ignored by test harness
     // expectUncaughtException should be called for each uncaught exception.
     if (!Services.appinfo.browserTabsRemoteAutostart) {
       expectUncaughtException();
     }
 
--- a/devtools/server/tests/browser/browser_webextension_inspected_window.js
+++ b/devtools/server/tests/browser/browser_webextension_inspected_window.js
@@ -23,17 +23,17 @@ async function setup(pageUrl) {
     addonId: extension.id,
   };
 
   const target = await addTabTarget(pageUrl);
 
   await target.attach();
 
   const { client } = target;
-  const webConsoleFront = target.activeConsole;
+  const webConsoleFront = await target.getFront("console");
   const inspectedWindowFront = await target.getFront(
     "webExtensionInspectedWindow"
   );
 
   return {
     client,
     target,
     webConsoleFront,
--- a/devtools/server/tests/mochitest/webconsole-helpers.js
+++ b/devtools/server/tests/mochitest/webconsole-helpers.js
@@ -33,18 +33,19 @@ if (!DebuggerServer.initialized) {
  *           - webConsoleFront: the console front
  *           - cleanup: a generator function which can be called to close
  *             the opened tab and disconnect its debugger client.
  */
 async function attachURL(url) {
   const tab = await addTab(url);
   const target = await TargetFactory.forTab(tab);
   await target.attach();
+  const webConsoleFront = await target.getFront("console");
   return {
-    webConsoleFront: target.activeConsole,
+    webConsoleFront,
   };
 }
 
 /**
  * Naive implementaion of addTab working from a mochitest-chrome test.
  */
 async function addTab(url) {
   const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
--- a/devtools/shared/webconsole/test/browser/browser_commands_registration.js
+++ b/devtools/shared/webconsole/test/browser/browser_commands_registration.js
@@ -4,17 +4,17 @@
 "use strict";
 
 // Test for Web Console commands registration.
 
 add_task(async function() {
   const tab = await addTab("data:text/html,<div id=quack></div>");
   const target = await getTargetForTab(tab);
 
-  const webConsoleFront = target.activeConsole;
+  const webConsoleFront = await target.getFront("console");
 
   // Fetch WebConsoleCommands so that it is available for next Content Tasks
   await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
     const { require } = ChromeUtils.import(
       "resource://devtools/shared/Loader.jsm"
     );
     const {
       WebConsoleCommands,
--- a/devtools/shared/webconsole/test/browser/browser_network_longstring.js
+++ b/devtools/shared/webconsole/test/browser/browser_network_longstring.js
@@ -10,17 +10,17 @@ const LONG_STRING_LENGTH = 400;
 const LONG_STRING_INITIAL_LENGTH = 400;
 let ORIGINAL_LONG_STRING_LENGTH, ORIGINAL_LONG_STRING_INITIAL_LENGTH;
 
 add_task(async function() {
   const tab = await addTab(URL_ROOT + "network_requests_iframe.html");
 
   const target = await getTargetForTab(tab);
   const { client } = target;
-  const webConsoleFront = target.activeConsole;
+  const webConsoleFront = await target.getFront("console");
 
   await webConsoleFront.startListeners(["NetworkActivity"]);
 
   // Override the default long string settings to lower values.
   // This is done from the parent process's DebuggerServer as the LongString
   // actor is being created from the parent process as network requests are
   // watched from the parent process.
   ORIGINAL_LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH;
--- a/devtools/shared/webconsole/test/common.js
+++ b/devtools/shared/webconsole/test/common.js
@@ -92,17 +92,17 @@ var _attachConsole = async function(list
       }
     }
 
     // Attach the Target and the target thread in order to instantiate the console client.
     await target.attach();
     const [, threadFront] = await target.attachThread();
     await threadFront.resume();
 
-    const webConsoleFront = target.activeConsole;
+    const webConsoleFront = await target.getFront("console");
 
     // By default the console isn't listening for anything,
     // request listeners from here
     const response = await webConsoleFront.startListeners(listeners);
     return {
       state: {
         dbgClient: client,
         webConsoleFront,