puppeteer/third_party/phantomjs/test/module/webpage/mousedoubleclick-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

31 lines
1.4 KiB
JavaScript

test(function () {
var page = require('webpage').create();
page.content = '<input id="doubleClickField" type="text" onclick="document.getElementById(\'doubleClickField\').value=\'clicked\';" ondblclick="document.getElementById(\'doubleClickField\').value=\'doubleclicked\';" oncontextmenu="document.getElementById(\'doubleClickField\').value=\'rightclicked\'; return false;" value="hello"/>';
var point = page.evaluate(function () {
var el = document.querySelector('input');
var rect = el.getBoundingClientRect();
return { x: rect.left + Math.floor(rect.width / 2), y: rect.top + (rect.height / 2) };
});
page.sendEvent('doubleclick', point.x, point.y);
var text = page.evaluate(function () {
return document.querySelector('input').value;
});
assert_equals(text, "doubleclicked");
// click with modifier key
page.evaluate(function() {
window.addEventListener('dblclick', function(event) {
window.loggedEvent = window.loggedEvent || {};
window.loggedEvent.dblclick = {clientX: event.clientX, clientY: event.clientY, shiftKey: event.shiftKey};
}, false);
});
page.sendEvent('doubleclick', 100, 100, 'left', page.event.modifier.shift);
var event = page.evaluate(function() {
return window.loggedEvent.dblclick;
});
assert_is_true(event.shiftKey);
}, "mouse double-click events");