Commit b00b295f b00b295fe9c8292d5a87912b60c0e35405d078ae by Nicolas Perriault

Merge pull request #850 from tohann/master

Add an event emit for clicking
2 parents 89cfda79 d306b927
......@@ -467,6 +467,7 @@ Casper.prototype.click = function click(selector) {
element.focus();
}
}, selector);
this.emit('click', selector);
return success;
};
......
......@@ -32,6 +32,9 @@
results.test4 = true;
event.preventDefault();
};
document.querySelector('#test5').onclick = function(event) {
results.testclick = [event.clientX, event.clientY];
};
window.onmousedown = function(event) {
results.testdown = [event.clientX, event.clientY];
};
......@@ -51,6 +54,9 @@
test5elem.addEventListener('mouseup', function(event) {
results.test5.push('mouseup');
});
test5elem.addEventListener('click', function(event) {
results.test5.push('click');
});
document.querySelector('#test6').onclick = function(event) {
results.test6 = true;
event.preventDefault();
......
......@@ -111,7 +111,7 @@ casper.test.begin('element focus on click', 1, function(test) {
});
});
casper.test.begin('mouse events on click', 2, function(test) {
casper.test.begin('mouse events on click', 3, function(test) {
casper.start('tests/site/click.html', function() {
this.click('#test5');
}).then(function() {
......@@ -120,6 +120,8 @@ casper.test.begin('mouse events on click', 2, function(test) {
'Casper.click() triggers mousedown event');
test.assert(results.test5.indexOf('mouseup') !== -1,
'Casper.click() triggers mouseup event');
test.assert(results.test5.indexOf('click') !== -1,
'Casper.click() triggers click event');
}).run(function() {
test.done();
});
......