summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/test/browser_inspector_search-sidebar.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/inspector/test/browser_inspector_search-sidebar.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/inspector/test/browser_inspector_search-sidebar.js')
-rw-r--r--devtools/client/inspector/test/browser_inspector_search-sidebar.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_search-sidebar.js b/devtools/client/inspector/test/browser_inspector_search-sidebar.js
new file mode 100644
index 000000000..d65a670ac
--- /dev/null
+++ b/devtools/client/inspector/test/browser_inspector_search-sidebar.js
@@ -0,0 +1,74 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+// Test that depending where the user last clicked in the inspector, the right search
+// field is focused when ctrl+F is pressed.
+
+add_task(function* () {
+ let {inspector} = yield openInspectorForURL("data:text/html;charset=utf-8,Search!");
+
+ info("Check that by default, the inspector search field gets focused");
+ pressCtrlF();
+ isInInspectorSearchBox(inspector);
+
+ info("Click somewhere in the rule-view");
+ clickInRuleView(inspector);
+
+ info("Check that the rule-view search field gets focused");
+ pressCtrlF();
+ isInRuleViewSearchBox(inspector);
+
+ info("Click in the inspector again");
+ yield clickContainer("head", inspector);
+
+ info("Check that now we're back in the inspector, its search field gets focused");
+ pressCtrlF();
+ isInInspectorSearchBox(inspector);
+
+ info("Switch to the computed view, and click somewhere inside it");
+ selectComputedView(inspector);
+ clickInComputedView(inspector);
+
+ info("Check that the computed-view search field gets focused");
+ pressCtrlF();
+ isInComputedViewSearchBox(inspector);
+
+ info("Click in the inspector yet again");
+ yield clickContainer("body", inspector);
+
+ info("We're back in the inspector again, check the inspector search field focuses");
+ pressCtrlF();
+ isInInspectorSearchBox(inspector);
+});
+
+function pressCtrlF() {
+ EventUtils.synthesizeKey("f", {accelKey: true});
+}
+
+function clickInRuleView(inspector) {
+ let el = inspector.panelDoc.querySelector("#sidebar-panel-ruleview");
+ EventUtils.synthesizeMouseAtCenter(el, {}, inspector.panelDoc.defaultView);
+}
+
+function clickInComputedView(inspector) {
+ let el = inspector.panelDoc.querySelector("#sidebar-panel-computedview");
+ EventUtils.synthesizeMouseAtCenter(el, {}, inspector.panelDoc.defaultView);
+}
+
+function isInInspectorSearchBox(inspector) {
+ // Focus ends up in an anonymous child of the XUL textbox.
+ ok(inspector.panelDoc.activeElement.closest("#inspector-searchbox"),
+ "The inspector search field is focused when ctrl+F is pressed");
+}
+
+function isInRuleViewSearchBox(inspector) {
+ is(inspector.panelDoc.activeElement, inspector.ruleview.view.searchField,
+ "The rule-view search field is focused when ctrl+F is pressed");
+}
+
+function isInComputedViewSearchBox(inspector) {
+ is(inspector.panelDoc.activeElement, inspector.computedview.computedView.searchField,
+ "The computed-view search field is focused when ctrl+F is pressed");
+}