browser/devtools/webconsole/test/browser_webconsole_assert.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_assert.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +// Test that console.assert() works as expected (i.e. outputs only on falsy
     1.9 +// asserts). See bug 760193.
    1.10 +
    1.11 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-assert.html";
    1.12 +
    1.13 +function test() {
    1.14 +  addTab(TEST_URI);
    1.15 +  browser.addEventListener("load", function onLoad() {
    1.16 +    browser.removeEventListener("load", onLoad, true);
    1.17 +    openConsole(null, consoleOpened);
    1.18 +  }, true);
    1.19 +}
    1.20 +
    1.21 +function consoleOpened(hud) {
    1.22 +  waitForMessages({
    1.23 +    webconsole: hud,
    1.24 +    messages: [{
    1.25 +      text: "start",
    1.26 +      category: CATEGORY_WEBDEV,
    1.27 +      severity: SEVERITY_LOG,
    1.28 +    },
    1.29 +    {
    1.30 +      text: "false assert",
    1.31 +      category: CATEGORY_WEBDEV,
    1.32 +      severity: SEVERITY_ERROR,
    1.33 +    },
    1.34 +    {
    1.35 +      text: "falsy assert",
    1.36 +      category: CATEGORY_WEBDEV,
    1.37 +      severity: SEVERITY_ERROR,
    1.38 +    },
    1.39 +    {
    1.40 +      text: "end",
    1.41 +      category: CATEGORY_WEBDEV,
    1.42 +      severity: SEVERITY_LOG,
    1.43 +    }],
    1.44 +  }).then(() => {
    1.45 +    let nodes = hud.outputNode.querySelectorAll(".message");
    1.46 +    is(nodes.length, 4, "only four messages are displayed, no output from the true assert");
    1.47 +    finishTest();
    1.48 +  });
    1.49 +
    1.50 +  let button = content.document.querySelector("button");
    1.51 +  ok(button, "we have the button");
    1.52 +  EventUtils.sendMouseEvent({ type: "click" }, button, content);
    1.53 +}

mercurial