From f1e24af91b17406232cc7bd3056d51821c2354d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 16 Apr 2018 16:39:41 +0200 Subject: [PATCH] Bug 1452143: Fix webconsole tests. r=jryans MozReview-Commit-ID: ClzJ0Ee1n5I --- .../webconsole/test/fixtures/stub-generators/head.js | 1 + .../mochitest/browser_webconsole_cached_messages.js | 12 +++++++++--- .../shared/webconsole/test/test_cached_messages.html | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/devtools/client/webconsole/test/fixtures/stub-generators/head.js b/devtools/client/webconsole/test/fixtures/stub-generators/head.js index 3c999d2b92b1..2f71ef607b03 100644 --- a/devtools/client/webconsole/test/fixtures/stub-generators/head.js +++ b/devtools/client/webconsole/test/fixtures/stub-generators/head.js @@ -370,6 +370,7 @@ async function generateCssMessageStubs() { gBrowser.selectedBrowser, [key, code], function([subKey, subCode]) { + content.document.docShell.cssErrorReportingEnabled = true; let style = content.document.createElement("style"); // eslint-disable-next-line no-unsanitized/property style.innerHTML = subCode; diff --git a/devtools/client/webconsole/test/mochitest/browser_webconsole_cached_messages.js b/devtools/client/webconsole/test/mochitest/browser_webconsole_cached_messages.js index 3c06c0497389..92b965383183 100644 --- a/devtools/client/webconsole/test/mochitest/browser_webconsole_cached_messages.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_cached_messages.js @@ -25,17 +25,18 @@ add_task(async function() { info("Open the console"); let hud = await openConsole(); - testMessagesVisibility(hud); + + await testMessagesVisibility(hud, true); info("Close the toolbox"); await closeToolbox(); info("Open the console again"); hud = await openConsole(); - testMessagesVisibility(hud); + await testMessagesVisibility(hud, false); }); -function testMessagesVisibility(hud) { +async function testMessagesVisibility(hud, waitForCSSMessage) { let message = findMessage(hud, "log Bazzle", ".message.log"); ok(message, "console.log message is visible"); @@ -45,6 +46,11 @@ function testMessagesVisibility(hud) { message = findMessage(hud, "bazBug611032", ".message.error"); ok(message, "exception message is visible"); + // The CSS message arrives lazily, so spin a bit for it unless it should be + // cached. + if (waitForCSSMessage) { + await waitForMessage(hud, "cssColorBug611032"); + } message = findMessage(hud, "cssColorBug611032", ".message.warn.css"); ok(message, "css warning message is visible"); } diff --git a/devtools/shared/webconsole/test/test_cached_messages.html b/devtools/shared/webconsole/test/test_cached_messages.html index e14348c7ecee..7080c9f84169 100644 --- a/devtools/shared/webconsole/test/test_cached_messages.html +++ b/devtools/shared/webconsole/test/test_cached_messages.html @@ -12,6 +12,7 @@

Test for cached messages