Bug 923281 - Console filter output does not match source filenames; r=msucan
authorRatnadeep Debnath <rtnpro@gmail.com>
Wed, 23 Oct 2013 14:49:51 +0300
changeset 166562 e22ba40a686c3cffba6f31df98c86cc797f76456
parent 166561 3e9c2f29f4cad19f364779920c1a7001570a0031
child 166563 53382ea36e36910b61329897a5bbc88d6e425048
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmsucan
bugs923281
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 923281 - Console filter output does not match source filenames; r=msucan
browser/devtools/webconsole/test/browser.ini
browser/devtools/webconsole/test/browser_webconsole_log_file_filter.js
browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html
browser/devtools/webconsole/test/test-bug_923281_test1.js
browser/devtools/webconsole/test/test-bug_923281_test2.js
browser/devtools/webconsole/webconsole.js
--- a/browser/devtools/webconsole/test/browser.ini
+++ b/browser/devtools/webconsole/test/browser.ini
@@ -89,16 +89,19 @@ support-files =
   test-repeated-messages.html
   test-result-format-as-string.html
   test-webconsole-error-observer.html
   test_bug_770099_bad_policy_uri.html
   test_bug_770099_bad_policy_uri.html^headers^
   test_bug_770099_violation.html
   test_bug_770099_violation.html^headers^
   testscript.js
+  test-bug_923281_console_log_filter.html
+  test-bug_923281_test1.js
+  test-bug_923281_test2.js
 
 [browser_bug664688_sandbox_update_after_navigation.js]
 [browser_bug_638949_copy_link_location.js]
 [browser_bug_862916_console_dir_and_filter_off.js]
 [browser_bug_865288_repeat_different_objects.js]
 [browser_bug_865871_variables_view_close_on_esc_key.js]
 [browser_bug_869003_inspect_cross_domain_object.js]
 [browser_bug_871156_ctrlw_close_tab.js]
@@ -226,8 +229,9 @@ support-files =
 [browser_webconsole_netlogging.js]
 [browser_webconsole_network_panel.js]
 [browser_webconsole_notifications.js]
 [browser_webconsole_output_copy_newlines.js]
 [browser_webconsole_output_order.js]
 [browser_webconsole_property_provider.js]
 [browser_webconsole_scratchpad_panel_link.js]
 [browser_webconsole_view_source.js]
+[browser_webconsole_log_file_filter.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webconsole/test/browser_webconsole_log_file_filter.js
@@ -0,0 +1,80 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Tests that the text filter box works to filter based on filenames
+// where the logs were generated.
+
+const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html";
+
+let hud;
+
+function test() {
+  addTab(TEST_URI);
+  browser.addEventListener("load", function onLoad() {
+    browser.removeEventListener("load", onLoad, true);
+    openConsole(null, consoleOpened);
+  }, true);
+}
+
+function consoleOpened(aHud) {
+  hud = aHud;
+  let console = content.console;
+  console.log("sentinel log");
+  waitForMessages({
+    webconsole: hud,
+    messages: [{
+      text: "sentinel log",
+      category: CATEGORY_WEBDEV,
+      severity: SEVERITY_LOG
+    }],
+  }).then(testLiveFilteringOnSearchStrings);
+}
+
+function testLiveFilteringOnSearchStrings() {
+  is(hud.outputNode.children.length, 4, "number of messages");
+
+  setStringFilter("random");
+  is(countMessageNodes(), 1, "the log nodes not containing string " +
+      "\"random\" are hidden");
+
+  setStringFilter("test2.js");
+  is(countMessageNodes(), 2, "show only log nodes containing string " +
+      "\"test2.js\" or log nodes created from files with filename " +
+      "containing \"test2.js\" as substring.");
+
+  setStringFilter("test1");
+  is(countMessageNodes(), 2, "show only log nodes containing string " +
+      "\"test1\" or log nodes created from files with filename " +
+      "containing \"test1\" as substring.");
+
+  setStringFilter("");
+  is(countMessageNodes(), 4, "show all log nodes on setting filter string " +
+      "as \"\".");
+
+  finishTest();
+}
+
+function countMessageNodes() {
+  let outputNode = hud.outputNode;
+
+  let messageNodes = outputNode.querySelectorAll(".message");
+  content.console.log(messageNodes.length);
+  let displayedMessageNodes = 0;
+  let view = hud.iframeWindow;
+  for (let i = 0; i < messageNodes.length; i++) {
+    let computedStyle = view.getComputedStyle(messageNodes[i], null);
+    if (computedStyle.display !== "none") {
+      displayedMessageNodes++;
+    }
+  }
+
+  return displayedMessageNodes;
+}
+
+function setStringFilter(aValue)
+{
+  hud.ui.filterBox.value = aValue;
+  hud.ui.adjustVisibilityOnSearchStringChange();
+}
+
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webconsole/test/test-bug_923281_console_log_filter.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html dir="ltr" xml:lang="en-US" lang="en-US">
+  <head>
+    <meta charset="utf-8">
+    <title>Console test</title>
+    <!-- Any copyright is dedicated to the Public Domain.
+       - http://creativecommons.org/publicdomain/zero/1.0/ -->
+    <script type="text/javascript" src="test-bug_923281_test1.js"></script>
+    <script type="text/javascript" src="test-bug_923281_test2.js"></script>
+  </head>
+  <body></body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webconsole/test/test-bug_923281_test1.js
@@ -0,0 +1,5 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+console.log("Sample log.");
+console.log("This log should be filtered when filtered for test2.js.");
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webconsole/test/test-bug_923281_test2.js
@@ -0,0 +1,4 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+console.log("This is a random text.");
--- a/browser/devtools/webconsole/webconsole.js
+++ b/browser/devtools/webconsole/webconsole.js
@@ -868,17 +868,17 @@ WebConsoleFrame.prototype = {
   {
     let nodes = this.outputNode.getElementsByClassName("message");
     let searchString = this.filterBox.value;
 
     for (let i = 0, n = nodes.length; i < n; ++i) {
       let node = nodes[i];
 
       // hide nodes that match the strings
-      let text = node.clipboardText;
+      let text = node.textContent;
 
       // if the text matches the words in aSearchString...
       if (this.stringMatchesFilters(text, searchString)) {
         node.classList.remove("filtered-by-string");
       }
       else {
         node.classList.add("filtered-by-string");
       }