mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
fix right click spec and implementation
This commit is contained in:
parent
47ac51e4dc
commit
cb02ea7752
2 changed files with 9 additions and 5 deletions
|
@ -991,12 +991,9 @@ describe Capybara::Webkit::Driver do
|
||||||
<ul id="events"></ul>
|
<ul id="events"></ul>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var events = document.getElementById("events");
|
var events = document.getElementById("events");
|
||||||
// https://developer.mozilla.org/en-US/docs/DOM/MouseEvent
|
|
||||||
var RIGHT_BUTTON = 2;
|
|
||||||
var recordEvent = function (event) {
|
var recordEvent = function (event) {
|
||||||
var element = document.createElement("li");
|
var element = document.createElement("li");
|
||||||
var type = event.button == RIGHT_BUTTON ? 'contextmenu' : event.type;
|
element.innerHTML = event.type;
|
||||||
element.innerHTML = type;
|
|
||||||
events.appendChild(element);
|
events.appendChild(element);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1032,7 +1029,7 @@ describe Capybara::Webkit::Driver do
|
||||||
|
|
||||||
it "triggers right click" do
|
it "triggers right click" do
|
||||||
watch.right_click
|
watch.right_click
|
||||||
fired_events.should == %w(contextmenu)
|
fired_events.should == %w(mousedown contextmenu mouseup)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "InvocationResult.h"
|
#include "InvocationResult.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
|
||||||
JavascriptInvocation::JavascriptInvocation(const QString &functionName, const QStringList &arguments, WebPage *page, QObject *parent) : QObject(parent) {
|
JavascriptInvocation::JavascriptInvocation(const QString &functionName, const QStringList &arguments, WebPage *page, QObject *parent) : QObject(parent) {
|
||||||
m_functionName = functionName;
|
m_functionName = functionName;
|
||||||
|
@ -48,6 +49,12 @@ void JavascriptInvocation::rightClick(int x, int y) {
|
||||||
|
|
||||||
hover(mousePos);
|
hover(mousePos);
|
||||||
JavascriptInvocation::mouseEvent(QEvent::MouseButtonPress, mousePos, Qt::RightButton);
|
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) {
|
void JavascriptInvocation::doubleClick(int x, int y) {
|
||||||
|
|
Loading…
Reference in a new issue