From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../browser/browser_console_nsiconsolemessage.js | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 devtools/client/webconsole/test/browser/browser_console_nsiconsolemessage.js (limited to 'devtools/client/webconsole/test/browser/browser_console_nsiconsolemessage.js') diff --git a/devtools/client/webconsole/test/browser/browser_console_nsiconsolemessage.js b/devtools/client/webconsole/test/browser/browser_console_nsiconsolemessage.js new file mode 100644 index 0000000000..a1f1b85669 --- /dev/null +++ b/devtools/client/webconsole/test/browser/browser_console_nsiconsolemessage.js @@ -0,0 +1,86 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Check that nsIConsoleMessages are displayed in the Browser Console. + +"use strict"; + +const TEST_URI = `data:text/html;charset=utf8, +browser_console_nsiconsolemessage.js +

hello world

+nsIConsoleMessages ftw!`; + +add_task(async function () { + // We don't use `openNewTabAndConsole()` here because we need to log a message + // before opening the web console. + await addTab(TEST_URI); + + // Test for cached nsIConsoleMessages. + Services.console.logStringMessage("cachedBrowserConsoleMessage"); + + info("open web console"); + let hud = await openConsole(); + + ok(hud, "web console opened"); + + // This "liveBrowserConsoleMessage" message should not be displayed. + Services.console.logStringMessage("liveBrowserConsoleMessage"); + + // Log a "foobarz" message so that we can be certain the previous message is + // not displayed. + let text = "foobarz"; + const onFooBarzMessage = waitForMessageByType(hud, text, ".console-api"); + SpecialPowers.spawn(gBrowser.selectedBrowser, [text], function (msg) { + content.console.log(msg); + }); + await onFooBarzMessage; + ok(true, `"${text}" log is displayed in the Web Console as expected`); + + // Ensure the "liveBrowserConsoleMessage" and "cachedBrowserConsoleMessage" + // messages are not displayed. + text = hud.ui.outputNode.textContent; + ok( + !text.includes("cachedBrowserConsoleMessage"), + "cached nsIConsoleMessages are not displayed" + ); + ok( + !text.includes("liveBrowserConsoleMessage"), + "nsIConsoleMessages are not displayed" + ); + + await closeConsole(); + + info("web console closed"); + hud = await BrowserConsoleManager.toggleBrowserConsole(); + ok(hud, "browser console opened"); + + await waitFor(() => + findConsoleAPIMessage(hud, "cachedBrowserConsoleMessage") + ); + Services.console.logStringMessage("liveBrowserConsoleMessage2"); + await waitFor(() => findConsoleAPIMessage(hud, "liveBrowserConsoleMessage2")); + + const msg = await waitFor(() => + findConsoleAPIMessage(hud, "liveBrowserConsoleMessage") + ); + ok(msg, "message element for liveBrowserConsoleMessage (nsIConsoleMessage)"); + + // Disable the log filter. + await setFilterState(hud, { + log: false, + }); + + // And then checking that the log messages are hidden. + await waitFor( + () => + findConsoleAPIMessages(hud, "cachedBrowserConsoleMessage").length === 0 + ); + await waitFor( + () => findConsoleAPIMessages(hud, "liveBrowserConsoleMessage").length === 0 + ); + await waitFor( + () => findConsoleAPIMessages(hud, "liveBrowserConsoleMessage2").length === 0 + ); + + resetFilters(hud); +}); -- cgit v1.2.3