Commit 2d2525ce 2d2525ceb748d5e1700698148bfc8356af20b1d7 by Nicolas Perriault

fixed #323 - Casper.thenEvaluate() args handling

1 parent 81b2094d
......@@ -4,6 +4,7 @@ CasperJS Changelog
XXXX-XX-XX, v1.0.0
------------------
- fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility.
- 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.
- `Casper.userAgent()` does not require the instance to be started anymore
......
......@@ -1523,8 +1523,9 @@ Casper.prototype.thenClick = function thenClick(selector, then, fallbackToHref)
Casper.prototype.thenEvaluate = function thenEvaluate(fn, context) {
"use strict";
this.checkStarted();
var args = [fn].concat([].slice.call(arguments, 1));
return this.then(function _step() {
this.evaluate(fn, context);
this.evaluate.apply(this, args);
});
};
......
......@@ -70,4 +70,18 @@ casper.test.assertEquals(casper.evaluate(function(a, b, c) {
return [a, b, c];
}, "foo", "bar", "baz"), ["foo", "bar", "baz"], 'Casper.evaluate() accepts natural arguments context');
casper.test.done(11);
casper.start().thenEvaluate(function(a, b) {
window.a = a
window.b = b;
}, "foo", "bar");
casper.then(function() {
this.test.comment('Casper.thenEvaluate()');
this.test.assertEquals(this.getGlobal('a'), "foo", "Casper.thenEvaluate() sets args");
this.test.assertEquals(this.getGlobal('b'), "bar",
"Casper.thenEvaluate() sets args the same way evaluate() does");
});
casper.run(function() {
this.test.done(13);
});
......