philc / vimium

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

On restart, content scripts only reinjected into main/top frame #1628

Closed smblott-github closed 9 years ago

smblott-github commented 9 years ago

Notwithstand this:

allFrames: contentScripts.allFrames

when Vimum restarts and we reinject the content scripts, only the main/top frame seems to restart. Try it here.

(Separately, I wonder whether we wouldn't be better moving the reinjection code to the bottom of main.coffee, after everything else is initialised.)

gdh1995 commented 9 years ago

It seems that this part should be:

allFrames: content_scripts.all_frames

Here is an example of chrome.runtime.getManifest().content_scripts[0]:

{
    "all_frames": true,
    "css": [
        "content_scripts/vimium.css"
    ],
    "js": [
        "lib/keyboard_utils.js",
        "lib/dom_utils.js",
        "content_scripts/vimium_frontend.js"
    ],
    "matches": [
        "<all_urls>"
    ],
    "run_at": "document_start"
}
smblott-github commented 9 years ago

Excellent. Thanks for that, @gdh1995. See https://github.com/philc/vimium/commit/9fdb630d891019620041041001b9dff022008ee0.

gdh1995 commented 9 years ago

Firstly, main.coffee usually runs much faster than so many content_scripts/*.coffee.

So, if we keep it at the top, nothing will go into an error - moving it to the bottom also does not do any harm, though.

mrmr1993 commented 9 years ago

@gdh1995 the actual injection code is inside an asynchronous callback, so it shouldn't slow down the normal initialisation of main.coffee at all. Or am I missing something?

gdh1995 commented 9 years ago

Sorry I forgot this. Yes, it is indeed executed in 0 ms or 16ms in my tests. So nothing should be changed.