browser/devtools/webconsole/test/browser_webconsole_assert.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /* Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 4
michael@0 5 // Test that console.assert() works as expected (i.e. outputs only on falsy
michael@0 6 // asserts). See bug 760193.
michael@0 7
michael@0 8 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-assert.html";
michael@0 9
michael@0 10 function test() {
michael@0 11 addTab(TEST_URI);
michael@0 12 browser.addEventListener("load", function onLoad() {
michael@0 13 browser.removeEventListener("load", onLoad, true);
michael@0 14 openConsole(null, consoleOpened);
michael@0 15 }, true);
michael@0 16 }
michael@0 17
michael@0 18 function consoleOpened(hud) {
michael@0 19 waitForMessages({
michael@0 20 webconsole: hud,
michael@0 21 messages: [{
michael@0 22 text: "start",
michael@0 23 category: CATEGORY_WEBDEV,
michael@0 24 severity: SEVERITY_LOG,
michael@0 25 },
michael@0 26 {
michael@0 27 text: "false assert",
michael@0 28 category: CATEGORY_WEBDEV,
michael@0 29 severity: SEVERITY_ERROR,
michael@0 30 },
michael@0 31 {
michael@0 32 text: "falsy assert",
michael@0 33 category: CATEGORY_WEBDEV,
michael@0 34 severity: SEVERITY_ERROR,
michael@0 35 },
michael@0 36 {
michael@0 37 text: "end",
michael@0 38 category: CATEGORY_WEBDEV,
michael@0 39 severity: SEVERITY_LOG,
michael@0 40 }],
michael@0 41 }).then(() => {
michael@0 42 let nodes = hud.outputNode.querySelectorAll(".message");
michael@0 43 is(nodes.length, 4, "only four messages are displayed, no output from the true assert");
michael@0 44 finishTest();
michael@0 45 });
michael@0 46
michael@0 47 let button = content.document.querySelector("button");
michael@0 48 ok(button, "we have the button");
michael@0 49 EventUtils.sendMouseEvent({ type: "click" }, button, content);
michael@0 50 }

mercurial