Commit 2d2525ce 2d2525ceb748d5e1700698148bfc8356af20b1d7 by Nicolas Perriault

fixed #323 - Casper.thenEvaluate() args handling

1 parent 81b2094d
...@@ -4,6 +4,7 @@ CasperJS Changelog ...@@ -4,6 +4,7 @@ CasperJS Changelog
4 XXXX-XX-XX, v1.0.0 4 XXXX-XX-XX, v1.0.0
5 ------------------ 5 ------------------
6 6
7 - fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility.
7 - merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file. 8 - merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file.
8 - `Casper.userAgent()` does not require the instance to be started anymore 9 - `Casper.userAgent()` does not require the instance to be started anymore
9 10
......
...@@ -1523,8 +1523,9 @@ Casper.prototype.thenClick = function thenClick(selector, then, fallbackToHref) ...@@ -1523,8 +1523,9 @@ Casper.prototype.thenClick = function thenClick(selector, then, fallbackToHref)
1523 Casper.prototype.thenEvaluate = function thenEvaluate(fn, context) { 1523 Casper.prototype.thenEvaluate = function thenEvaluate(fn, context) {
1524 "use strict"; 1524 "use strict";
1525 this.checkStarted(); 1525 this.checkStarted();
1526 var args = [fn].concat([].slice.call(arguments, 1));
1526 return this.then(function _step() { 1527 return this.then(function _step() {
1527 this.evaluate(fn, context); 1528 this.evaluate.apply(this, args);
1528 }); 1529 });
1529 }; 1530 };
1530 1531
......
...@@ -70,4 +70,18 @@ casper.test.assertEquals(casper.evaluate(function(a, b, c) { ...@@ -70,4 +70,18 @@ casper.test.assertEquals(casper.evaluate(function(a, b, c) {
70 return [a, b, c]; 70 return [a, b, c];
71 }, "foo", "bar", "baz"), ["foo", "bar", "baz"], 'Casper.evaluate() accepts natural arguments context'); 71 }, "foo", "bar", "baz"), ["foo", "bar", "baz"], 'Casper.evaluate() accepts natural arguments context');
72 72
73 casper.test.done(11); 73 casper.start().thenEvaluate(function(a, b) {
74 window.a = a
75 window.b = b;
76 }, "foo", "bar");
77
78 casper.then(function() {
79 this.test.comment('Casper.thenEvaluate()');
80 this.test.assertEquals(this.getGlobal('a'), "foo", "Casper.thenEvaluate() sets args");
81 this.test.assertEquals(this.getGlobal('b'), "bar",
82 "Casper.thenEvaluate() sets args the same way evaluate() does");
83 });
84
85 casper.run(function() {
86 this.test.done(13);
87 });
......