Commit d6ded5cb d6ded5cb428a0d7847c1f5e97b8e5a704491eb8e by Nicolas Perriault

Merge branch 'issue-114'

2 parents dcba4fdb 2af64a19
...@@ -156,7 +156,6 @@ Casper.prototype.back = function back() { ...@@ -156,7 +156,6 @@ Casper.prototype.back = function back() {
156 * @return string Base64 encoded result 156 * @return string Base64 encoded result
157 */ 157 */
158 Casper.prototype.base64encode = function base64encode(url, method, data) { 158 Casper.prototype.base64encode = function base64encode(url, method, data) {
159 this.injectClientUtils();
160 return this.evaluate(function _evaluate(url, method, data) { 159 return this.evaluate(function _evaluate(url, method, data) {
161 return __utils__.getBase64(url, method, data); 160 return __utils__.getBase64(url, method, data);
162 }, { url: url, method: method, data: data }); 161 }, { url: url, method: method, data: data });
...@@ -420,6 +419,9 @@ Casper.prototype.echo = function echo(text, style, pad) { ...@@ -420,6 +419,9 @@ Casper.prototype.echo = function echo(text, style, pad) {
420 * @see WebPage#evaluate 419 * @see WebPage#evaluate
421 */ 420 */
422 Casper.prototype.evaluate = function evaluate(fn, context) { 421 Casper.prototype.evaluate = function evaluate(fn, context) {
422 // ensure client utils are always injected
423 this.injectClientUtils();
424 // function processing
423 context = utils.isObject(context) ? context : {}; 425 context = utils.isObject(context) ? context : {};
424 var newFn = require('injector').create(fn).process(context); 426 var newFn = require('injector').create(fn).process(context);
425 return this.page.evaluate(newFn); 427 return this.page.evaluate(newFn);
...@@ -628,7 +630,7 @@ Casper.prototype.getTitle = function getTitle() { ...@@ -628,7 +630,7 @@ Casper.prototype.getTitle = function getTitle() {
628 * 630 *
629 */ 631 */
630 Casper.prototype.injectClientUtils = function injectClientUtils() { 632 Casper.prototype.injectClientUtils = function injectClientUtils() {
631 var clientUtilsInjected = this.evaluate(function() { 633 var clientUtilsInjected = this.page.evaluate(function() {
632 return typeof __utils__ === "object"; 634 return typeof __utils__ === "object";
633 }); 635 });
634 if (true === clientUtilsInjected) { 636 if (true === clientUtilsInjected) {
......