summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/tests/browser_search_within_preferences_command.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/preferences/tests/browser_search_within_preferences_command.js')
-rw-r--r--browser/components/preferences/tests/browser_search_within_preferences_command.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_search_within_preferences_command.js b/browser/components/preferences/tests/browser_search_within_preferences_command.js
new file mode 100644
index 0000000000..736493b418
--- /dev/null
+++ b/browser/components/preferences/tests/browser_search_within_preferences_command.js
@@ -0,0 +1,45 @@
+"use strict";
+
+/**
+ * Test for "command" event on search input (when user clicks the x button)
+ */
+add_task(async function () {
+ await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });
+ let generalPane = gBrowser.contentDocument.getElementById("generalCategory");
+
+ is_element_hidden(generalPane, "Should not be in general");
+
+ // Performs search
+ let searchInput = gBrowser.contentDocument.getElementById("searchInput");
+ is(
+ searchInput,
+ gBrowser.contentDocument.activeElement.closest("#searchInput"),
+ "Search input should be focused when visiting preferences"
+ );
+
+ let query = "x";
+ let searchCompletedPromise = BrowserTestUtils.waitForEvent(
+ gBrowser.contentWindow,
+ "PreferencesSearchCompleted",
+ evt => evt.detail == query
+ );
+ EventUtils.sendString(query);
+ await searchCompletedPromise;
+
+ is_element_hidden(generalPane, "Should not be in generalPane");
+
+ // Takes search off with "command"
+ searchCompletedPromise = BrowserTestUtils.waitForEvent(
+ gBrowser.contentWindow,
+ "PreferencesSearchCompleted",
+ evt => evt.detail == ""
+ );
+ searchInput.value = "";
+ searchInput.doCommand();
+ await searchCompletedPromise;
+
+ // Checks if back to normal
+ is_element_visible(generalPane, "Should be in generalPane");
+
+ BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});