Merge pull request #850 from tohann/master
Add an event emit for clicking
Showing
3 changed files
with
10 additions
and
1 deletions
... | @@ -467,6 +467,7 @@ Casper.prototype.click = function click(selector) { | ... | @@ -467,6 +467,7 @@ Casper.prototype.click = function click(selector) { |
467 | element.focus(); | 467 | element.focus(); |
468 | } | 468 | } |
469 | }, selector); | 469 | }, selector); |
470 | this.emit('click', selector); | ||
470 | return success; | 471 | return success; |
471 | }; | 472 | }; |
472 | 473 | ... | ... |
... | @@ -32,6 +32,9 @@ | ... | @@ -32,6 +32,9 @@ |
32 | results.test4 = true; | 32 | results.test4 = true; |
33 | event.preventDefault(); | 33 | event.preventDefault(); |
34 | }; | 34 | }; |
35 | document.querySelector('#test5').onclick = function(event) { | ||
36 | results.testclick = [event.clientX, event.clientY]; | ||
37 | }; | ||
35 | window.onmousedown = function(event) { | 38 | window.onmousedown = function(event) { |
36 | results.testdown = [event.clientX, event.clientY]; | 39 | results.testdown = [event.clientX, event.clientY]; |
37 | }; | 40 | }; |
... | @@ -51,6 +54,9 @@ | ... | @@ -51,6 +54,9 @@ |
51 | test5elem.addEventListener('mouseup', function(event) { | 54 | test5elem.addEventListener('mouseup', function(event) { |
52 | results.test5.push('mouseup'); | 55 | results.test5.push('mouseup'); |
53 | }); | 56 | }); |
57 | test5elem.addEventListener('click', function(event) { | ||
58 | results.test5.push('click'); | ||
59 | }); | ||
54 | document.querySelector('#test6').onclick = function(event) { | 60 | document.querySelector('#test6').onclick = function(event) { |
55 | results.test6 = true; | 61 | results.test6 = true; |
56 | event.preventDefault(); | 62 | event.preventDefault(); | ... | ... |
... | @@ -111,7 +111,7 @@ casper.test.begin('element focus on click', 1, function(test) { | ... | @@ -111,7 +111,7 @@ casper.test.begin('element focus on click', 1, function(test) { |
111 | }); | 111 | }); |
112 | }); | 112 | }); |
113 | 113 | ||
114 | casper.test.begin('mouse events on click', 2, function(test) { | 114 | casper.test.begin('mouse events on click', 3, function(test) { |
115 | casper.start('tests/site/click.html', function() { | 115 | casper.start('tests/site/click.html', function() { |
116 | this.click('#test5'); | 116 | this.click('#test5'); |
117 | }).then(function() { | 117 | }).then(function() { |
... | @@ -120,6 +120,8 @@ casper.test.begin('mouse events on click', 2, function(test) { | ... | @@ -120,6 +120,8 @@ casper.test.begin('mouse events on click', 2, function(test) { |
120 | 'Casper.click() triggers mousedown event'); | 120 | 'Casper.click() triggers mousedown event'); |
121 | test.assert(results.test5.indexOf('mouseup') !== -1, | 121 | test.assert(results.test5.indexOf('mouseup') !== -1, |
122 | 'Casper.click() triggers mouseup event'); | 122 | 'Casper.click() triggers mouseup event'); |
123 | test.assert(results.test5.indexOf('click') !== -1, | ||
124 | 'Casper.click() triggers click event'); | ||
123 | }).run(function() { | 125 | }).run(function() { |
124 | test.done(); | 126 | test.done(); |
125 | }); | 127 | }); | ... | ... |
-
Please register or sign in to post a comment