diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2014-05-21 11:38:25 +0200 |
commit | d25ba7d760b017b038e5aa6c0a605b4a330eb68d (patch) | |
tree | 16ec27edc7d5f83986f16236d3a36a2682a0f37e /browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js | |
parent | a942906574671868daf122284a9c4689e6924f74 (diff) | |
download | palemoon-gre-d25ba7d760b017b038e5aa6c0a605b4a330eb68d.tar.gz |
Recommit working copy to repo with proper line endings.
Diffstat (limited to 'browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js')
-rw-r--r-- | browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js b/browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js new file mode 100644 index 000000000..4d8a1d492 --- /dev/null +++ b/browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js @@ -0,0 +1,146 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Tests that the basic console.log()-style APIs and filtering work. + +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; + +let testDriver = null; +let subtestDriver = null; + +function test() { + addTab(TEST_URI); + + browser.addEventListener("DOMContentLoaded", onLoad, false); +} + +function onLoad() { + browser.removeEventListener("DOMContentLoaded", onLoad, false); + + openConsole(null, function(aHud) { + hud = aHud; + hudId = hud.hudId; + outputNode = hud.outputNode; + testDriver = testGen(); + testDriver.next(); + }); +} + +function testGen() { + subtestGen("log"); + yield; + + subtestGen("info"); + yield; + + subtestGen("warn"); + yield; + + subtestGen("error"); + yield; + + subtestGen("debug"); // bug 616742 + yield; + + testDriver = subtestDriver = null; + finishTest(); + + yield; +} + +function subtestGen(aMethod) { + subtestDriver = testConsoleLoggingAPI(aMethod); + subtestDriver.next(); +} + +function testConsoleLoggingAPI(aMethod) { + let console = content.wrappedJSObject.console; + + hud.jsterm.clearOutput(); + + setStringFilter("foo"); + console[aMethod]("foo-bar-baz"); + console[aMethod]("bar-baz"); + + function nextTest() { + subtestDriver.next(); + } + + waitForSuccess({ + name: "1 hidden " + aMethod + " node via string filtering", + validatorFn: function() + { + return outputNode.querySelectorAll(".hud-filtered-by-string").length == 1; + }, + successFn: nextTest, + failureFn: nextTest, + }); + + yield; + + hud.jsterm.clearOutput(); + + // now toggle the current method off - make sure no visible message + + // TODO: move all filtering tests into a separate test file: see bug 608135 + setStringFilter(""); + hud.setFilterState(aMethod, false); + console[aMethod]("foo-bar-baz"); + + waitForSuccess({ + name: "1 message hidden for " + aMethod + " (logging turned off)", + validatorFn: function() + { + return outputNode.querySelectorAll("description").length == 1; + }, + successFn: nextTest, + failureFn: nextTest, + }); + + yield; + + hud.jsterm.clearOutput(); + hud.setFilterState(aMethod, true); + console[aMethod]("foo-bar-baz"); + + waitForSuccess({ + name: "1 message shown for " + aMethod + " (logging turned on)", + validatorFn: function() + { + return outputNode.querySelectorAll("description").length == 1; + }, + successFn: nextTest, + failureFn: nextTest, + }); + + yield; + + hud.jsterm.clearOutput(); + setStringFilter(""); + + // test for multiple arguments. + console[aMethod]("foo", "bar"); + + waitForSuccess({ + name: "show both console arguments for " + aMethod, + validatorFn: function() + { + let node = outputNode.querySelector(".hud-msg-node"); + return node && /"foo" "bar"/.test(node.textContent); + }, + successFn: nextTest, + failureFn: nextTest, + }); + + yield; + testDriver.next(); + yield; +} + +function setStringFilter(aValue) { + hud.ui.filterBox.value = aValue; + hud.ui.adjustVisibilityOnSearchStringChange(); +} + |