diff options
| author | Stephen Blott | 2016-04-01 13:48:30 +0100 |
|---|---|---|
| committer | Stephen Blott | 2016-04-01 13:51:34 +0100 |
| commit | 8574dec533e5c2b3d4623de359c30a16846cd0e6 (patch) | |
| tree | 997444c09ca7232b01ab01417d87017680ae434e | |
| parent | 777af41df142e2a461073aed8c5941d2dfdc24d1 (diff) | |
| download | vimium-8574dec533e5c2b3d4623de359c30a16846cd0e6.tar.bz2 | |
Ensure settings are loaded.
With global link hints, hints might be launched in one frame when the
settings are not yet loaded in another. This could lead to one frame
using one settings value, and another another value. (Because we use
the default value if the settings are not yet loaded.) And this in turn
could cause link hints to crash if filetered hints are used (because, in
that case, we would not calculate hint.linkText in one frame, but then
try to use that value later in another frame).
| -rw-r--r-- | content_scripts/link_hints.coffee | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 254d9811..0295aa3e 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -64,17 +64,21 @@ HintCoordinator = @sendMessage "prepareToActivateMode", modeIndex: availableModes.indexOf mode getHintDescriptors: -> - @localHints = LocalHints.getLocalHints() - @sendMessage "postHintDescriptors", hintDescriptors: - @localHints.map ({rect, linkText, showLinkText, hasHref}, localIndex) -> - {rect, linkText, showLinkText, hasHref, frameId, localIndex} + # Ensure that the settings are loaded. The request might have been initiated in another frame. + Settings.onLoaded => + @localHints = LocalHints.getLocalHints() + @sendMessage "postHintDescriptors", hintDescriptors: + @localHints.map ({rect, linkText, showLinkText, hasHref}, localIndex) -> + {rect, linkText, showLinkText, hasHref, frameId, localIndex} # We activate LinkHintsMode() in every frame and provide every frame with exactly the same hint descriptors. # We also propagate the key state between frames. Therefore, the hint-selection process proceeds in lock # step in every frame, and @linkHintsMode is in the same state in every frame. activateMode: ({hintDescriptors, modeIndex, originatingFrameId}) -> - @onExit = [] unless frameId == originatingFrameId - @linkHintsMode = new LinkHintsMode hintDescriptors, availableModes[modeIndex] + # Ensure that the settings are loaded. The request might have been initiated in another frame. + Settings.onLoaded => + @onExit = [] unless frameId == originatingFrameId + @linkHintsMode = new LinkHintsMode hintDescriptors, availableModes[modeIndex] # The following messages are exchanged between frames while link-hints mode is active. updateKeyState: (request) -> @linkHintsMode.updateKeyState request |
