Commit fa3ed042 fa3ed0426711f5cd29323a0c9eddc13742980200 by Nicolas Perriault

refs #114 - ensure client utils are always injected when calling Casper.evaluate()

1 parent 5b02d6c6
......@@ -156,7 +156,6 @@ Casper.prototype.back = function back() {
* @return string Base64 encoded result
*/
Casper.prototype.base64encode = function base64encode(url, method, data) {
this.injectClientUtils();
return this.evaluate(function _evaluate(url, method, data) {
return __utils__.getBase64(url, method, data);
}, { url: url, method: method, data: data });
......@@ -422,6 +421,9 @@ Casper.prototype.echo = function echo(text, style, pad) {
* @see WebPage#evaluate
*/
Casper.prototype.evaluate = function evaluate(fn, context) {
// ensure client utils are always injected
this.injectClientUtils();
// function processing
context = utils.isObject(context) ? context : {};
var newFn = require('injector').create(fn).process(context);
return this.page.evaluate(newFn);
......@@ -625,7 +627,7 @@ Casper.prototype.getTitle = function getTitle() {
*
*/
Casper.prototype.injectClientUtils = function injectClientUtils() {
var clientUtilsInjected = this.evaluate(function() {
var clientUtilsInjected = this.page.evaluate(function() {
return typeof __utils__ === "object";
});
if (true === clientUtilsInjected) {
......