diff options
author | Virgil Dupras <hsoft@hardcoded.net> | 2017-05-08 20:10:35 -0400 |
---|---|---|
committer | Virgil Dupras <hsoft@hardcoded.net> | 2017-05-08 20:12:52 -0400 |
commit | 798e2e1080e208f89c6bf49ad202ba4490dcb03d (patch) | |
tree | 5892485bea5bffabcc4cb1e3a2f3acb566687fb3 | |
parent | 904f8267fce2037a87025d0dd06007daf5b4c208 (diff) |
hints: open links in async mode
When firing hints, open them (either by simulating a click or through
`window.open()`) in async mode with `window.setTimeout()`. If we don't
do that, the `EvalJS` dbus call will itself timeout and we'll end up
in an inconsistent state, that is, not back to Normal mode.
ref #349
-rw-r--r-- | src/scripts/hints.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/scripts/hints.js b/src/scripts/hints.js index 1b69c06..d70d3b2 100644 --- a/src/scripts/hints.js +++ b/src/scripts/hints.js @@ -384,15 +384,23 @@ var hints = Object.freeze((function(){ /* internal used methods */ function open(e, newWin) { + /* We call open() and click() in async mode to avoid return as fast as possible. + * If we don't return immediately, the EvalJS dbus call will probably timeout and cause + * errors. + */ if (newWin && e.hasAttribute('href')) { /* Since the "noopener" vulnerability thing, it's not possible to set an anchor's * target to _blank. Therefore, we can't simulate ctrl-click through _blank like we * used to. Therefore, we limit ourselves to "window.open()" in cases we're firing a * simple <a> link. In other cases, we fire the even normally. */ - window.open(e.getAttribute('href'), '_blank'); + + window.setTimeout(function() { + window.open(e.getAttribute('href'), '_blank'); + }, 0 + ); } - e.click(); + window.setTimeout(function() {e.click();}, 0); } /* set focus on hint with given index valid hints array */ |