puppeteer/third_party/phantomjs/test/module/webpage/contextclick-event.js
JoelEinbinder 98ee35655f Mouse (#101)
This patch:
- adds Mouse class which holds mouse state and implements mouse primitives,
such as moving, button down and button up.
- implements high-level mouse api, such as `page.click` and `page.hover`.

References #40, References #89
2017-07-21 20:29:31 -07:00

33 lines
1.2 KiB
JavaScript

test(function () {
var page = require('webpage').create();
page.evaluate(function() {
window.addEventListener('contextmenu', function(event) {
window.loggedEvent = window.loggedEvent || {};
window.loggedEvent.contextmenu = {clientX: event.clientX, clientY: event.clientY, shiftKey: event.shiftKey};
}, false);
});
page.sendEvent('contextmenu', 42, 217);
var event = page.evaluate(function() {
return window.loggedEvent;
});
assert_equals(event.contextmenu.clientX, 42);
assert_equals(event.contextmenu.clientY, 217);
// click with modifier key
page.evaluate(function() {
window.addEventListener('contextmenu', function(event) {
window.loggedEvent = window.loggedEvent || {};
window.loggedEvent.contextmenu = {clientX: event.clientX, clientY: event.clientY, shiftKey: event.shiftKey};
}, false);
});
page.sendEvent('contextmenu', 100, 100, 'left', page.event.modifier.shift);
var event = page.evaluate(function() {
return window.loggedEvent.contextmenu;
});
assert_is_true(event.shiftKey);
}, "context click events");