fixes #410 - click() triggers mousedown and mousedown events
Showing
4 changed files
with
28 additions
and
3 deletions
... | @@ -103,11 +103,12 @@ Last, all the casper test suites have been upgraded to use the new testing featu | ... | @@ -103,11 +103,12 @@ Last, all the casper test suites have been upgraded to use the new testing featu |
103 | 103 | ||
104 | ### Bugfixes & enhancements | 104 | ### Bugfixes & enhancements |
105 | 105 | ||
106 | - heavy lifint of casperjs bootstrap script | 106 | - heavy lifting of casperjs bootstrap script |
107 | - closed [#392](https://github.com/n1k0/casperjs/issues/392) - `--direct` & `--log-level` options available for the `casperjs` executable | 107 | - closed [#392](https://github.com/n1k0/casperjs/issues/392) - `--direct` & `--log-level` options available for the `casperjs` executable |
108 | - closed [#350](https://github.com/n1k0/casperjs/issues/350) - Add a [`Casper#waitForSelectorTextChange()`](http://docs.casperjs.org/en/latest/modules/casper.html#waitforselectortextchange) method | 108 | - closed [#350](https://github.com/n1k0/casperjs/issues/350) - Add a [`Casper#waitForSelectorTextChange()`](http://docs.casperjs.org/en/latest/modules/casper.html#waitforselectortextchange) method |
109 | - fixed [#387](https://github.com/n1k0/casperjs/issues/387) - Setting viewport isn't quite synchronous | 109 | - fixed [#387](https://github.com/n1k0/casperjs/issues/387) - Setting viewport isn't quite synchronous |
110 | - Added [`Casper#bypass`](http://docs.casperjs.org/en/latest/modules/casper.html#bypass), [`Casper#thenBypass`](http://docs.casperjs.org/en/latest/modules/casper.html#thenbypass), [`Casper#thenBypassIf`](http://docs.casperjs.org/en/latest/modules/casper.html#thenbypassif), [`Casper#thenBypassUnless`](http://docs.casperjs.org/en/latest/modules/casper.html#thenbypassunless) methods | 110 | - Added [`Casper#bypass`](http://docs.casperjs.org/en/latest/modules/casper.html#bypass), [`Casper#thenBypass`](http://docs.casperjs.org/en/latest/modules/casper.html#thenbypass), [`Casper#thenBypassIf`](http://docs.casperjs.org/en/latest/modules/casper.html#thenbypassif), [`Casper#thenBypassUnless`](http://docs.casperjs.org/en/latest/modules/casper.html#thenbypassunless) methods |
111 | - fixes [#410](https://github.com/n1k0/casperjs/issues/410) - trigger `mousedown` and `mousedown` events on click | ||
111 | - Added [`Tester#skip`](http://docs.casperjs.org/en/latest/modules/tester.html#skip) method | 112 | - Added [`Tester#skip`](http://docs.casperjs.org/en/latest/modules/tester.html#skip) method |
112 | 113 | ||
113 | 2013-02-08, v1.0.2 | 114 | 2013-02-08, v1.0.2 | ... | ... |
... | @@ -420,14 +420,15 @@ Casper.prototype.clear = function clear() { | ... | @@ -420,14 +420,15 @@ Casper.prototype.clear = function clear() { |
420 | Casper.prototype.click = function click(selector) { | 420 | Casper.prototype.click = function click(selector) { |
421 | "use strict"; | 421 | "use strict"; |
422 | this.checkStarted(); | 422 | this.checkStarted(); |
423 | var success = this.mouseEvent('click', selector); | 423 | var success = this.mouseEvent('mousedown', selector); |
424 | success = success && this.mouseEvent('click', selector); | ||
424 | this.evaluate(function(selector) { | 425 | this.evaluate(function(selector) { |
425 | var element = __utils__.findOne(selector); | 426 | var element = __utils__.findOne(selector); |
426 | if (element) { | 427 | if (element) { |
427 | element.focus(); | 428 | element.focus(); |
428 | } | 429 | } |
429 | }, selector); | 430 | }, selector); |
430 | return success; | 431 | return success && this.mouseEvent('mouseup', selector); |
431 | }; | 432 | }; |
432 | 433 | ||
433 | /** | 434 | /** | ... | ... |
... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
9 | <a id="test2" href="#" onclick="results.test2 = true;">test2</a> | 9 | <a id="test2" href="#" onclick="results.test2 = true;">test2</a> |
10 | <a id="test3" href="page1.html" onclick="results.test3 = true; return false">test3</a> | 10 | <a id="test3" href="page1.html" onclick="results.test3 = true; return false">test3</a> |
11 | <a id="test4" href="http://www.google.com/">test4</a> | 11 | <a id="test4" href="http://www.google.com/">test4</a> |
12 | <a id="test5" href="#">test5</a> | ||
12 | <script> | 13 | <script> |
13 | (function(window) { | 14 | (function(window) { |
14 | window.results = { | 15 | window.results = { |
... | @@ -16,6 +17,7 @@ | ... | @@ -16,6 +17,7 @@ |
16 | test2: false, | 17 | test2: false, |
17 | test3: false, | 18 | test3: false, |
18 | test4: false, | 19 | test4: false, |
20 | test5: [], | ||
19 | testdown: [], | 21 | testdown: [], |
20 | testup: [], | 22 | testup: [], |
21 | testmove: [], | 23 | testmove: [], |
... | @@ -38,6 +40,13 @@ | ... | @@ -38,6 +40,13 @@ |
38 | window.ondblclick = function(event) { | 40 | window.ondblclick = function(event) { |
39 | results.testdoubleclick = [event.x, event.y]; | 41 | results.testdoubleclick = [event.x, event.y]; |
40 | }; | 42 | }; |
43 | var test5elem = document.querySelector('#test5'); | ||
44 | test5elem.addEventListener('mousedown', function(event) { | ||
45 | results.test5.push('mousedown'); | ||
46 | }); | ||
47 | test5elem.addEventListener('mouseup', function(event) { | ||
48 | results.test5.push('mouseup'); | ||
49 | }); | ||
41 | })(window); | 50 | })(window); |
42 | </script> | 51 | </script> |
43 | </body> | 52 | </body> | ... | ... |
... | @@ -92,3 +92,17 @@ casper.test.begin('element focus on click', 1, function(test) { | ... | @@ -92,3 +92,17 @@ casper.test.begin('element focus on click', 1, function(test) { |
92 | test.done(); | 92 | test.done(); |
93 | }); | 93 | }); |
94 | }); | 94 | }); |
95 | |||
96 | casper.test.begin('mouse events on click', 2, function(test) { | ||
97 | casper.start('tests/site/click.html', function() { | ||
98 | this.click('#test5'); | ||
99 | }).then(function() { | ||
100 | var results = this.getGlobal('results'); | ||
101 | test.assert(results.test5.indexOf('mousedown') !== -1, | ||
102 | 'Casper.click() triggers mousedown event'); | ||
103 | test.assert(results.test5.indexOf('mouseup') !== -1, | ||
104 | 'Casper.click() triggers mouseup event'); | ||
105 | }).run(function() { | ||
106 | test.done(); | ||
107 | }); | ||
108 | }); | ... | ... |
-
Please register or sign in to post a comment