MCPcopy Index your code
hub / github.com/philc/vimium / focusThisFrame

Function focusThisFrame

content_scripts/vimium_frontend.js:319–336  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

317// Called from the backend in order to change frame focus.
318//
319function focusThisFrame(request) {
320 // It should never be the case that we get a forceFocusThisFrame request on a window that isn't
321 // focusable, because the background script checks that the window is focusable before sending the
322 // focusFrame message.
323 if (!request.forceFocusThisFrame && !isWindowFocusable()) return;
324
325 Utils.nextTick(function () {
326 globalThis.focus();
327 // On Firefox, window.focus doesn't always draw focus back from a child frame (bug 554039). We
328 // blur the active element if it is an iframe, which gives the window back focus as intended.
329 if (document.activeElement.tagName.toLowerCase() === "iframe") {
330 document.activeElement.blur();
331 }
332 if (request.highlight) {
333 flashFrame();
334 }
335 });
336}
337
338// Used by the focusInput command.
339globalThis.lastFocusedInput = (function () {

Callers 3

activateLinkMethod · 0.85
mainFrameFunction · 0.85
focusFrameFunction · 0.85

Calls 1

isWindowFocusableFunction · 0.85

Tested by

no test coverage detected