tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_console_clear_method.js (1167B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // XXX Remove this when the file is migrated to the new frontend.
      5 /* eslint-disable no-undef */
      6 
      7 // Check that console.clear() does not clear the output of the browser console.
      8 
      9 "use strict";
     10 
     11 const TEST_URI = "data:text/html;charset=utf8,<!DOCTYPE html><p>Bug 1296870";
     12 
     13 add_task(async function () {
     14  await loadTab(TEST_URI);
     15  const hud = await BrowserConsoleManager.toggleBrowserConsole();
     16 
     17  info("Log a new message from the content page");
     18  SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
     19    content.wrappedJSObject.console.log("msg");
     20  });
     21  await waitForMessageByType(hud, "msg", ".console-api");
     22 
     23  info("Send a console.clear() from the content page");
     24  SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
     25    content.wrappedJSObject.console.clear();
     26  });
     27  await waitForMessageByType(hud, "Console was cleared", ".console-api");
     28 
     29  info(
     30    "Check that the messages logged after the first clear are still displayed"
     31  );
     32  ok(hud.ui.outputNode.textContent.includes("msg"), "msg is in the output");
     33 });