Permalink
Browse files

fix right click spec and implementation

  • Loading branch information...
1 parent 47ac51e commit cb02ea7752a000c74bb2eae76a4109e8237d9bbb @mikz mikz committed Feb 27, 2013
Showing with 9 additions and 5 deletions.
  1. +2 −5 spec/driver_spec.rb
  2. +7 −0 src/JavascriptInvocation.cpp
View
@@ -991,12 +991,9 @@ def visit(url, driver=driver)
<ul id="events"></ul>
<script type="text/javascript">
var events = document.getElementById("events");
- // https://developer.mozilla.org/en-US/docs/DOM/MouseEvent
- var RIGHT_BUTTON = 2;
var recordEvent = function (event) {
var element = document.createElement("li");
- var type = event.button == RIGHT_BUTTON ? 'contextmenu' : event.type;
- element.innerHTML = type;
+ element.innerHTML = event.type;
events.appendChild(element);
};
@@ -1032,7 +1029,7 @@ def visit(url, driver=driver)
it "triggers right click" do
watch.right_click
- fired_events.should == %w(contextmenu)
+ fired_events.should == %w(mousedown contextmenu mouseup)
end
end
@@ -3,6 +3,7 @@
#include "InvocationResult.h"
#include <QApplication>
#include <QEvent>
+#include <QContextMenuEvent>
JavascriptInvocation::JavascriptInvocation(const QString &functionName, const QStringList &arguments, WebPage *page, QObject *parent) : QObject(parent) {
m_functionName = functionName;
@@ -48,6 +49,12 @@ void JavascriptInvocation::rightClick(int x, int y) {
hover(mousePos);
JavascriptInvocation::mouseEvent(QEvent::MouseButtonPress, mousePos, Qt::RightButton);
+
+ // swallowContextMenuEvent tries to fire contextmenu event in html page
+ QContextMenuEvent *event = new QContextMenuEvent(QContextMenuEvent::Mouse, mousePos);
+ m_page->swallowContextMenuEvent(event);
+
+ JavascriptInvocation::mouseEvent(QEvent::MouseButtonRelease, mousePos, Qt::RightButton);
}
void JavascriptInvocation::doubleClick(int x, int y) {

0 comments on commit cb02ea7

Please sign in to comment.