Bug 1260235 - Only accept ctrl+f in computed and rule view if it happened in the relevant container;r=gl
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 29 Mar 2016 14:25:02 -0700
changeset 290812 2b4d5580c46da0d6e83cf597cbfc3811b64332d0
parent 290811 8edeb8f0ca56598918f4e5f6b018d5bb989cf133
child 290813 d8b9796cb557cdfa7d57abb586a0bcedf60cf676
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1260235
milestone48.0a1
Bug 1260235 - Only accept ctrl+f in computed and rule view if it happened in the relevant container;r=gl MozReview-Commit-ID: 4kMiWcqTra
devtools/client/inspector/computed/computed.js
devtools/client/inspector/computed/test/browser_computed_search-filter.js
devtools/client/inspector/rules/rules.js
--- a/devtools/client/inspector/computed/computed.js
+++ b/devtools/client/inspector/computed/computed.js
@@ -497,21 +497,24 @@ CssComputedView.prototype = {
       return deferred.promise;
     }).then(null, (err) => console.error(err));
   },
 
   /**
    * Handle the keypress event in the computed view.
    */
   _onKeypress: function(event) {
+    if (!event.target.closest("#sidebar-panel-computedview")) {
+      return;
+    }
     let isOSX = Services.appinfo.OS === "Darwin";
 
     if (((isOSX && event.metaKey && !event.ctrlKey && !event.altKey) ||
         (!isOSX && event.ctrlKey && !event.metaKey && !event.altKey)) &&
-        event.code === "KeyF") {
+        event.key === "f") {
       this.searchField.focus();
       event.preventDefault();
     }
   },
 
   /**
    * Set the filter style search value.
    * @param {String} value
--- a/devtools/client/inspector/computed/test/browser_computed_search-filter.js
+++ b/devtools/client/inspector/computed/test/browser_computed_search-filter.js
@@ -30,19 +30,28 @@ function* testToggleDefaultStyles(inspec
   checkbox.click();
   yield onRefreshed;
 }
 
 function* testAddTextInFilter(inspector, computedView) {
   info("setting filter text to \"color\"");
   let searchField = computedView.searchField;
   let onRefreshed = inspector.once("computed-view-refreshed");
-  searchField.focus();
+  let win = computedView.styleWindow;
 
-  let win = computedView.styleWindow;
+  // First check to make sure that accel + F doesn't focus search if the container
+  // isn't focused
+  inspector.panelWin.focus();
+  EventUtils.synthesizeKey("f", { accelKey: true });
+  isnot(inspector.panelDoc.activeElement, searchField, "Search field isn't focused");
+
+  computedView.element.focus();
+  EventUtils.synthesizeKey("f", { accelKey: true });
+  is(inspector.panelDoc.activeElement, searchField, "Search field is focused");
+
   synthesizeKeys("color", win);
   yield onRefreshed;
 
   info("check that the correct properties are visible");
 
   let propertyViews = computedView.propertyViews;
   propertyViews.forEach(function(propView) {
     let name = propView.name;
--- a/devtools/client/inspector/rules/rules.js
+++ b/devtools/client/inspector/rules/rules.js
@@ -1494,21 +1494,25 @@ CssRuleView.prototype = {
       event.preventDefault();
     }
   },
 
   /**
    * Handle the keypress event in the rule view.
    */
   _onKeypress: function(event) {
+    if (!event.target.closest("#sidebar-panel-ruleview")) {
+      return;
+    }
+
     let isOSX = Services.appinfo.OS === "Darwin";
 
     if (((isOSX && event.metaKey && !event.ctrlKey && !event.altKey) ||
         (!isOSX && event.ctrlKey && !event.metaKey && !event.altKey)) &&
-        event.code === "KeyF") {
+        event.key === "f") {
       this.searchField.focus();
       event.preventDefault();
     }
   }
 };
 
 /**
  * Helper functions