summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_console_clear_cache.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/webconsole/test/browser/browser_console_clear_cache.js')
-rw-r--r--devtools/client/webconsole/test/browser/browser_console_clear_cache.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/browser/browser_console_clear_cache.js b/devtools/client/webconsole/test/browser/browser_console_clear_cache.js
new file mode 100644
index 0000000000..8fc536e67a
--- /dev/null
+++ b/devtools/client/webconsole/test/browser/browser_console_clear_cache.js
@@ -0,0 +1,48 @@
+/* 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/. */
+
+// Check that clearing the browser console output also clears the console cache.
+
+"use strict";
+
+const TEST_URI =
+ "data:text/html;charset=utf8,<!DOCTYPE html>Test browser console clear cache";
+
+add_task(async function () {
+ await pushPref("devtools.browsertoolbox.scope", "everything");
+
+ await addTab(TEST_URI);
+ let hud = await BrowserConsoleManager.toggleBrowserConsole();
+
+ const CACHED_MESSAGE = "CACHED_MESSAGE";
+ await logTextInContentAndWaitForMessage(hud, CACHED_MESSAGE);
+
+ info("Click the clear output button");
+ const onBrowserConsoleOutputCleared = waitFor(
+ () => !findConsoleAPIMessage(hud, CACHED_MESSAGE)
+ );
+ hud.ui.window.document.querySelector(".devtools-clear-icon").click();
+ await onBrowserConsoleOutputCleared;
+ ok(true, "Message was cleared");
+
+ info("Close and re-open the browser console");
+ await safeCloseBrowserConsole();
+ hud = await BrowserConsoleManager.toggleBrowserConsole();
+
+ info("Log a smoke message in order to know that the console is ready");
+ await logTextInContentAndWaitForMessage(hud, "Smoke message");
+ is(
+ findConsoleAPIMessage(hud, CACHED_MESSAGE),
+ undefined,
+ "The cached message is not visible anymore"
+ );
+});
+
+function logTextInContentAndWaitForMessage(hud, text) {
+ const onMessage = waitForMessageByType(hud, text, ".console-api");
+ SpecialPowers.spawn(gBrowser.selectedBrowser, [text], function (str) {
+ content.wrappedJSObject.console.log(str);
+ });
+ return onMessage;
+}