Bug 1295390 - Don't hold search result after clearing inspector-searchbox by inspector-searchinput-clear. r=ntim
MozReview-Commit-ID: xmLhuQBgaV
--- 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");
+});