diff --git a/common/content/buffer.js b/common/content/buffer.js index be2362bf..7315f2f1 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -578,8 +578,8 @@ const Buffer = Module("buffer", { let offsetX = 1; let offsetY = 1; - if (elem instanceof HTMLFrameElement || elem instanceof HTMLIFrameElement) { - elem.contentWindow.focus(); + if (isinstance(elem [HTMLFrameElement, HTMLIFrameElement])) { + buffer.focusElement(elem); return; } else if (elem instanceof HTMLAreaElement) { // for imagemap @@ -608,7 +608,7 @@ const Buffer = Module("buffer", { liberator.log("Invalid where argument for followLink()", 0); } - elem.focus(); + buffer.focusElement(elem); options.withContext(function () { options.setPref("browser.tabs.loadInBackground", true); diff --git a/common/content/events.js b/common/content/events.js index 4ec214d2..c9860b82 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -735,13 +735,15 @@ const Events = Module("events", { } }, + // TODO: Merge with onFocusChange onFocus: function (event) { function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument let elem = event.originalTarget; let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; - if (hasHTMLDocument(win) && !buffer.focusAllowed(win)) + if (hasHTMLDocument(win) && !buffer.focusAllowed(win) + && isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement])) elem.blur(); },