<commit_before>/* See license.txt for terms of usage */

"use strict";

const { Cu } = require("chrome");
const { openToolbox } = require("./common.js");
const { waitForMessage } = require("./console.js");

// Content of the test page (one console log is coming from the content).
const content =
  "<html><head></head><body><script>" +
  "console.log('hello')" +
  "</script></body></html>";

exports["test Console clear button"] = function(assert, done) {
  // Configuration flags for toolbox opening.
  let config = {
    panelId: "webconsole",
    pageContent: content
  };

  // Start HTTP server, open new tab and the toolbox.
  openToolbox(config).then(({toolbox, cleanUp, overlay}) => {
    assert.ok(overlay, "The Console panel must be overlaid");

    let doc = overlay.getPanelDocument();
    let clearButton = doc.querySelector(".webconsole-clear-console-button");
    assert.ok(clearButton, "The clear button must exist");

    // Wait for console log.
    let config = {
      cssSelector: ".message[category=console] .console-string"
    };

    waitForMessage(toolbox, config).then(result => {
      assert.ok(true, "There must not be a log in the Console panel");

      overlay.clearConsole();

      let log = doc.querySelector(config.cssSelector);
      assert.ok(!log, "There must not be a log in the Console panel");

      cleanUp(done);
    });
  });
};

require("sdk/test").run(exports);
<commit_msg>Test: adopt test for console clear action<commit_after>/* See license.txt for terms of usage */

"use strict";

const { Cu } = require("chrome");
const { loadFirebug } = require("./common.js");
const { waitForMessage } = require("./console.js");
const { getToolboxWhenReady, closeTab } = require("./toolbox.js");
const { startServer, stopServer } = require("./httpd.js");

// Content of the test page (one console log is coming from the content).
const content =
  "<html><head></head><body><script>" +
  "console.log('hello')" +
  "</script></body></html>";

exports["test Console clear button"] = function(assert, done) {
  loadFirebug();

  // Start HTTP server
  let {server, url} = startServer({
    pageContent: content
  });

  // Open the toolbox on our test page.
  getToolboxWhenReady(url, "webconsole").then(({toolbox, overlay, tab}) => {
    assert.ok(overlay, "The Console panel must be overlaid");

    let doc = overlay.getPanelDocument();
    let clearButton = doc.querySelector(".webconsole-clear-console-button");
    assert.ok(clearButton, "The clear button must exist");

    // Wait for console log.
    let config = {
      cssSelector: ".message[category=console] .console-string"
    };

    waitForMessage(toolbox, config).then(result => {
      assert.ok(true, "There must not be a log in the Console panel");

      overlay.clearConsole();

      let log = doc.querySelector(config.cssSelector);
      assert.ok(!log, "There must not be a log in the Console panel");

      // Close the tab an stop HTTP server.
      closeTab(tab);
      stopServer(server, done);
    });
  });
};

require("sdk/test").run(exports);

{'fraction_non_alphanumeric': 0.14921135646687697, 'fraction_numerical': 0.0, 'mean_word_length': 3.086340206185567, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798926', 'n_tokens_mistral': 950, 'n_tokens_neox': 904, 'n_words': 267}