aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.coffee
diff options
context:
space:
mode:
authorStephen Blott2017-09-06 12:36:13 +0100
committerGitHub2017-09-06 12:36:13 +0100
commit0d21fb070e93030beb591540face9138f7df557a (patch)
tree4b7939f01ed3f336ac65f11b5fee64521a57c5d2 /lib/utils.coffee
parentdd7dc27f2ddc11e2eba15803c5d880e2393e04cf (diff)
parentd946a98df10bf1ae5bb02e5cd7eaa2a0c3a06aad (diff)
downloadvimium-0d21fb070e93030beb591540face9138f7df557a.tar.bz2
Merge pull request #2605 from mrmr1993/isTrusted-events
Check whether events are trusted before executing listeners
Diffstat (limited to 'lib/utils.coffee')
-rw-r--r--lib/utils.coffee8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index babb5f96..78eed12c 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -1,3 +1,11 @@
+# Only pass events to the handler if they are marked as trusted by the browser.
+# This is kept in the global namespace for brevity and ease of use.
+window.forTrusted ?= (handler) -> (event) ->
+ if event?.isTrusted
+ handler.apply this, arguments
+ else
+ true
+
Utils =
getCurrentVersion: ->
chrome.runtime.getManifest().version