browser_console_clear_method.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. // Check that console.clear() does not clear the output of the browser console.
  5. "use strict";
  6. const TEST_URI = "data:text/html;charset=utf8,<p>Bug 1296870";
  7. add_task(function* () {
  8. yield loadTab(TEST_URI);
  9. let hud = yield HUDService.toggleBrowserConsole();
  10. info("Log a new message from the content page");
  11. ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
  12. content.wrappedJSObject.console.log("msg");
  13. });
  14. yield waitForMessage("msg", hud);
  15. info("Send a console.clear() from the content page");
  16. ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
  17. content.wrappedJSObject.console.clear();
  18. });
  19. yield waitForMessage("Console was cleared", hud);
  20. info("Check that the messages logged after the first clear are still displayed");
  21. isnot(hud.outputNode.textContent.indexOf("msg"), -1, "msg is in the output");
  22. });
  23. function waitForMessage(message, webconsole) {
  24. return waitForMessages({
  25. webconsole,
  26. messages: [{
  27. text: message,
  28. category: CATEGORY_WEBDEV,
  29. severity: SEVERITY_LOG,
  30. }],
  31. });
  32. }