Bug 1295390 - Don't hold search result after clearing inspector-searchbox by inspector-searchinput-clear. r=ntim
authorSteve Chung <schung@mozilla.com>
Tue, 16 Aug 2016 18:18:48 +0800
changeset 336340 e5f3c2ed25f511cb5882574c300026cb0765a697
parent 336339 0faec8f3a8b59106a3437d954d1ccc38da7ec705
child 336341 352d2e43336522a95c803d25a48c0df63dff931d
child 336586 c2208aa0321830a520d2aea54c536ee981bb93c5
push id10033
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:50:26 +0000
treeherdermozilla-aurora@5dddbefdf759 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersntim
bugs1295390
milestone51.0a1
Bug 1295390 - Don't hold search result after clearing inspector-searchbox by inspector-searchinput-clear. r=ntim MozReview-Commit-ID: xmLhuQBgaV
devtools/client/inspector/inspector-search.js
devtools/client/inspector/test/browser.ini
devtools/client/inspector/test/browser_inspector_search-label.js
--- a/devtools/client/inspector/inspector-search.js
+++ b/devtools/client/inspector/inspector-search.js
@@ -149,16 +149,17 @@ InspectorSearch.prototype = {
       console.error(e);
     }
   },
 
   _onClearSearch: function () {
     this.searchBox.classList.remove("devtools-style-searchbox-no-match");
     this.searchBox.value = "";
     this.searchClearButton.hidden = true;
+    this.emit("search-cleared");
   }
 };
 
 /**
  * Converts any input box on a page to a CSS selector search and suggestion box.
  *
  * Emits 'processing-done' event when it is done processing the current
  * keypress, search request or selection from the list, whether that led to a
--- a/devtools/client/inspector/test/browser.ini
+++ b/devtools/client/inspector/test/browser.ini
@@ -141,16 +141,17 @@ skip-if = os == "mac" # Full keyboard na
 [browser_inspector_search-03.js]
 [browser_inspector_search-04.js]
 [browser_inspector_search-05.js]
 [browser_inspector_search-06.js]
 [browser_inspector_search-07.js]
 [browser_inspector_search-08.js]
 [browser_inspector_search-filter_context-menu.js]
 [browser_inspector_search_keyboard_trap.js]
+[browser_inspector_search-label.js]
 [browser_inspector_search-reserved.js]
 [browser_inspector_search-selection.js]
 [browser_inspector_search-sidebar.js]
 [browser_inspector_select-docshell.js]
 [browser_inspector_select-last-selected.js]
 [browser_inspector_search-navigation.js]
 [browser_inspector_sidebarstate.js]
 [browser_inspector_switch-to-inspector-on-pick.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/test/browser_inspector_search-label.js
@@ -0,0 +1,33 @@
+/* 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/. */
+
+"use strict";
+
+// Check that search label updated correctcly based on the search result.
+
+const TEST_URL = URL_ROOT + "doc_inspector_search.html";
+
+add_task(function* () {
+  let { inspector } = yield openInspectorForURL(TEST_URL);
+  let { panelWin, searchResultsLabel } = inspector;
+
+  info("Searching for test node #d1");
+  // Expect the label shows 1 result
+  yield focusSearchBoxUsingShortcut(panelWin);
+  synthesizeKeys("#d1", panelWin);
+  EventUtils.synthesizeKey("VK_RETURN", {}, panelWin);
+
+  yield inspector.search.once("search-result");
+  is(searchResultsLabel.textContent, "1 of 1");
+
+  info("Click the clear button");
+  // Expect the label is cleared after clicking the clear button.
+
+  inspector.searchClearButton.click();
+  is(searchResultsLabel.textContent, "");
+
+  // Catch-all event for remaining server requests when searching for the new
+  // node.
+  yield inspector.once("inspector-updated");
+});