philc / vimium

The hacker's browser.
https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
MIT License
23.48k stars 2.49k forks source link

gf makes vimium unresponsive, then only a mouse click could awaken it #2551

Open gnarendran opened 7 years ago

gnarendran commented 7 years ago

Chrome/Linux: 59.0.3071.86 Vimium: 1.59 A sample page where this happens: https://www.w3schools.com/

After gf, keys such as Esc / etc., don't have any effect.

gdh1995 commented 7 years ago

Um, this page is unusual: it has an <iframe> with large-positive height and width, but hidden by [style=display:none].

Vimium can not know it's hidden and gf will make the page "focused", so you can not see anything. Then one more gf should have makd Vimium focus the top window again, but in fact the first gf makes Vimium:

  1. its backend finds one next frame to focus, and here is the only <iframe>
  2. during the listener to chrome.runtime.onMessage, Vimium tries to focus the iframe by calling window.focus() in focusThisFrame on the iframe's context
  3. in this case, there MAY be no "focus" event triggered (comment 1), and both frame's document.hasFocus() is true
  4. so Vimium's backend think the iframe is not focused.

Then a second gf just does the same things as the first one.

Comment 1: the "MAY" is because, when the page is first loaded, a gf won't generate a "focus" event, but if you click the main page and press gf again, correct "focus" events will occur (edited: this statement is not correct). I don't know why.

Comment 2: using my vimium-plus:master, it supports a second gf to return focus to the top window, and then next gf will generate correct "focus" events on the <iframe>. Things are too complicated for me. I've given up further tests.

Tested on Chrome 59.0.3071.115 stable x64 on Windows 10 x64.