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
--- 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);