aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJez Ng2012-01-26 12:55:40 -0500
committerJez Ng2012-01-26 13:21:31 -0500
commita4286bc54fcccfbddfe1b77babd02c652b71ab49 (patch)
tree7f46a2690f948852a4ba9ffa99b859db81864dc7
parentad981199cbb0d3542550713f7658a1726c0c8b24 (diff)
downloadvimium-a4286bc54fcccfbddfe1b77babd02c652b71ab49.tar.bz2
Simulate the full sequence of mouse click events.
Some sites expect it, e.g. GMail.
-rw-r--r--lib/domUtils.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/domUtils.js b/lib/domUtils.js
index 700e1920..fd182c59 100644
--- a/lib/domUtils.js
+++ b/lib/domUtils.js
@@ -80,13 +80,15 @@ var domUtils = {
simulateClick: function(element, modifiers) {
modifiers = modifiers || {};
- var event = document.createEvent("MouseEvents");
- event.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, modifiers.ctrlKey, false, false,
- modifiers.metaKey, 0, null);
-
- // Debugging note: Firefox will not execute the element's default action if we dispatch this click event,
- // but Webkit will. Dispatching a click on an input box does not seem to focus it; we do that separately
- element.dispatchEvent(event);
+ var eventSequence = [ "mouseover", "mousedown", "mouseup", "click" ];
+ for (var i = 0; i < eventSequence.length; i++) {
+ var event = document.createEvent("MouseEvents");
+ event.initMouseEvent(eventSequence[i], true, true, window, 1, 0, 0, 0, 0, modifiers.ctrlKey, false, false,
+ modifiers.metaKey, 0, null);
+ // Debugging note: Firefox will not execute the element's default action if we dispatch this click event,
+ // but Webkit will. Dispatching a click on an input box does not seem to focus it; we do that separately
+ element.dispatchEvent(event);
+ }
},
};