2017-05-11 07:06:41 +00:00
|
|
|
test(function () {
|
|
|
|
var webpage = require('webpage');
|
|
|
|
|
|
|
|
var page = webpage.create();
|
|
|
|
|
|
|
|
page.evaluate(function() {
|
|
|
|
window.addEventListener('keydown', function(event) {
|
|
|
|
window.loggedEvent = window.loggedEvent || [];
|
2017-07-18 01:49:52 +00:00
|
|
|
window.loggedEvent.push(event.which);
|
2017-05-11 07:06:41 +00:00
|
|
|
}, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
page.sendEvent('keydown', page.event.key.A);
|
|
|
|
var loggedEvent = page.evaluate(function() {
|
|
|
|
return window.loggedEvent;
|
|
|
|
});
|
|
|
|
|
|
|
|
assert_equals(loggedEvent.length, 1);
|
2017-07-18 01:49:52 +00:00
|
|
|
assert_equals(loggedEvent[0], page.event.key.A);
|
2017-05-11 07:06:41 +00:00
|
|
|
}, "key-down events");
|