Bug 1367318 - Trim console filter input. r=Honza
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Fri, 02 Jun 2017 09:52:27 +0200
changeset 410189 9ddef50dea793835299e1cc007db31fd12f26944
parent 410188 39b358a1d0ca52dd1a0292700e424853131b366f
child 410190 39bbafe0ef81b6d16438bc7de2549ae595adaf86
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1367318
milestone55.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 1367318 - Trim console filter input. r=Honza MozReview-Commit-ID: 8OAEUh6ekiP
devtools/client/webconsole/new-console-output/reducers/messages.js
devtools/client/webconsole/new-console-output/test/store/filters.test.js
--- a/devtools/client/webconsole/new-console-output/reducers/messages.js
+++ b/devtools/client/webconsole/new-console-output/reducers/messages.js
@@ -390,17 +390,17 @@ function matchNetworkFilters(message, fi
 function matchCssFilters(message, filters) {
   return (
     message.source != MESSAGE_SOURCE.CSS
     || filters.get("css") === true
   );
 }
 
 function matchSearchFilters(message, filters) {
-  let text = filters.text || "";
+  let text = (filters.text || "").trim();
   return (
     text === ""
     // Look for a match in parameters.
     || isTextInParameters(text, message.parameters)
     // Look for a match in location.
     || isTextInFrame(text, message.frame)
     // Look for a match in net events.
     || isTextInNetEvent(text, message.request)
--- a/devtools/client/webconsole/new-console-output/test/store/filters.test.js
+++ b/devtools/client/webconsole/new-console-output/test/store/filters.test.js
@@ -95,20 +95,30 @@ describe("Filtering", () => {
 
       store.dispatch(actions.filterToggle("net"));
       messages = getVisibleMessages(store.getState());
       expect(messages.length).toEqual(numMessages + 1);
     });
   });
 
   describe("Text filter", () => {
+    it("set the expected property on the store", () => {
+      store.dispatch(actions.filterTextSet("danger"));
+      expect(getAllFilters(store.getState()).text).toEqual("danger");
+    });
+
     it("matches on value grips", () => {
       store.dispatch(actions.filterTextSet("danger"));
       let messages = getVisibleMessages(store.getState());
       expect(messages.length - numUnfilterableMessages).toEqual(1);
+
+      // Checks that trimming works.
+      store.dispatch(actions.filterTextSet("    danger    "));
+      messages = getVisibleMessages(store.getState());
+      expect(messages.length - numUnfilterableMessages).toEqual(1);
     });
 
     it("matches unicode values", () => {
       store.dispatch(actions.filterTextSet("ιΌ¬"));
 
       let messages = getVisibleMessages(store.getState());
       expect(messages.length - numUnfilterableMessages).toEqual(1);
     });