Bug 1399460 - Fix for browser_webconsole_check_stubs_console_api. r=Honza
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Thu, 14 Sep 2017 18:49:43 +0200
changeset 665591 8b0058e2a4a8a123e09470b7ee975963be88a158
parent 665590 e7d1f0e04aaef260f2acd9f998eacf245ea2c363
child 665592 9253681974414228318eacfdcaafdaae333855bb
push id80115
push userbmo:eoger@fastmail.com
push dateFri, 15 Sep 2017 18:29:01 +0000
reviewersHonza
bugs1399460
milestone57.0a1
Bug 1399460 - Fix for browser_webconsole_check_stubs_console_api. r=Honza The test that checked console api stubs was failing because we were trying to reach the server while the connection was closed, which throws an error. This patch filters-out log messages in the console output so we don't get unwanted server communication. The output is not important here since we are only listening to the consoleAPICall event. MozReview-Commit-ID: Ay5fQ1CSbLx
devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/head.js
--- a/devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/head.js
+++ b/devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/head.js
@@ -13,16 +13,17 @@
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js",
   this);
 
 Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
 });
+const { PREFS } = require("devtools/client/webconsole/new-console-output/constants");
 
 const { prepareMessage } = require("devtools/client/webconsole/new-console-output/utils/messages");
 const { stubPackets } = require("devtools/client/webconsole/new-console-output/test/fixtures/stubs/index.js");
 const {
   consoleApi,
   cssMessage,
   evaluationResult,
   networkEvent,
@@ -283,16 +284,19 @@ module.exports = {
   stubPackets,
 };
 `;
 }
 
 function* generateConsoleApiStubs() {
   const TEST_URI = "http://example.com/browser/devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/test-console-api.html";
 
+  // Hiding log messages so we don't get unwanted client/server communication.
+  Services.prefs.setBoolPref(PREFS.FILTER.LOG, false);
+
   let stubs = {
     preparedMessages: [],
     packets: [],
   };
 
   let toolbox = yield openNewTabAndToolbox(TEST_URI, "webconsole");
   const hud = toolbox.getCurrentPanel().hud;
   let {ui} = hud;
@@ -325,16 +329,18 @@ function* generateConsoleApiStubs() {
         content.wrappedJSObject.triggerPacket();
         script.remove();
       }
     );
 
     yield received;
   }
 
+  Services.prefs.clearUserPref(PREFS.FILTER.LOG);
+
   yield closeTabAndToolbox();
   return formatFile(stubs, "ConsoleMessage");
 }
 
 function* generateCssMessageStubs() {
   const TEST_URI = "http://example.com/browser/devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/test-css-message.html";
 
   let stubs = {