Bug 1260235 - Only accept ctrl+f in computed and rule view if it happened in the relevant container;r=gl a=ritu
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 29 Mar 2016 14:25:02 -0700
changeset 326067 ddef17d3f117c3aedf092b2763503001b00dd0f1
parent 326066 259d41769207bbf0a55afe7475fc3a71f8a5d724
child 326068 4f87619148365dcc28bdf536c39e574b2f13a336
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl, ritu
bugs1260235
milestone47.0
Bug 1260235 - Only accept ctrl+f in computed and rule view if it happened in the relevant container;r=gl a=ritu 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