Files
firefox/devtools/client/webconsole/test/browser/browser_console_clear_cache.js
T
Kris Maglione 8c0d38f33d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740
2019-12-13 20:36:16 +00:00

51 lines
1.8 KiB
JavaScript

/* 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,Test browser console clear cache";
add_task(async function() {
await pushPref("devtools.browserconsole.contentMessages", true);
await addTab(TEST_URI);
let hud = await BrowserConsoleManager.toggleBrowserConsole();
const CACHED_MESSAGE = "CACHED_MESSAGE";
await logTextToConsole(hud, CACHED_MESSAGE);
info("Click the clear output button");
const onBrowserConsoleOutputCleared = waitFor(
() => !findMessage(hud, CACHED_MESSAGE)
);
hud.ui.window.document.querySelector(".devtools-clear-icon").click();
await onBrowserConsoleOutputCleared;
// Check that there are no other messages logged (see Bug 1457478).
// Log a message to make sure the console handled any prior log.
await logTextToConsole(hud, "after clear");
const messages = hud.ui.outputNode.querySelectorAll(".message");
is(messages.length, 1, "There is only the new message in the output");
info("Close and re-open the browser console");
await BrowserConsoleManager.toggleBrowserConsole();
hud = await BrowserConsoleManager.toggleBrowserConsole();
info("Log a smoke message in order to know that the console is ready");
await logTextToConsole(hud, "Smoke message");
is(
findMessage(hud, CACHED_MESSAGE),
null,
"The cached message is not visible anymore"
);
});
function logTextToConsole(hud, text) {
const onMessage = waitForMessage(hud, text);
SpecialPowers.spawn(gBrowser.selectedBrowser, [text], function(str) {
content.wrappedJSObject.console.log(str);
});
return onMessage;
}