Bug 1401018 Don't let about:addons steal keypresses from options pages draft
authorAndrew Swan <aswan@mozilla.com>
Mon, 18 Sep 2017 14:29:17 -0700
changeset 666502 b824d5d0f4c37ad079f96ca0e204274b9c5a6316
parent 666416 42151fcd6cfc216d147730d0f2c6a2acd52d22fd
child 732142 945e4d2dd781ff50cf3bb8819751a581dfe3ca55
push id80446
push useraswan@mozilla.com
push dateMon, 18 Sep 2017 21:36:22 +0000
bugs1401018, 1381032
milestone57.0a1
Bug 1401018 Don't let about:addons steal keypresses from options pages Revise the bug 1381032 fix to work whether or not oop webextensions are enabled. MozReview-Commit-ID: EIfli8D5I7H
toolkit/mozapps/extensions/content/extensions.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -158,23 +158,16 @@ function initialize(event) {
   });
   addonPage.addEventListener("dragover", function(event) {
     gDragDrop.onDragOver(event);
   });
   addonPage.addEventListener("drop", function(event) {
     gDragDrop.onDrop(event);
   });
   addonPage.addEventListener("keypress", function(event) {
-    // If there is an embedded preferences <browser> running in a remote
-    // process, we will see the event here first before it gets a chance
-    // to bubble up through the embedded page.  To avoid stealing focus,
-    // we just ignore events when focus is in an options browser.
-    if (event.target.classList.contains("inline-options-browser")) {
-      return;
-    }
     gHeader.onKeyPress(event);
   });
 
   if (!isDiscoverEnabled()) {
     gViewDefault = "addons://list/extension";
   }
 
   gViewController.initialize();
@@ -3766,16 +3759,23 @@ var gDetailView = {
     let browser = document.createElement("browser");
     browser.setAttribute("type", "content");
     browser.setAttribute("disableglobalhistory", "true");
     browser.setAttribute("id", "addon-options");
     browser.setAttribute("class", "inline-options-browser");
     browser.setAttribute("forcemessagemanager", "true");
     browser.setAttribute("selectmenulist", "ContentSelectDropdown");
 
+    // The outer about:addons document listens for key presses to focus
+    // the search box when / is pressed.  But if we're focused inside an
+    // options page, don't let those keypresses steal focus.
+    browser.addEventListener("keypress", event => {
+      event.stopPropagation();
+    });
+
     let {optionsURL} = this._addon;
     let remote = !E10SUtils.canLoadURIInProcess(optionsURL, Services.appinfo.PROCESS_TYPE_DEFAULT);
 
     let readyPromise;
     if (remote) {
       browser.setAttribute("remote", "true");
       browser.setAttribute("remoteType", E10SUtils.EXTENSION_REMOTE_TYPE);
       readyPromise = promiseEvent("XULFrameLoaderCreated", browser);