Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
fa3ed042
...
fa3ed0426711f5cd29323a0c9eddc13742980200
authored
2012-05-20 16:38:31 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refs #114 - ensure client utils are always injected when calling Casper.evaluate()
1 parent
5b02d6c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
modules/casper.js
modules/casper.js
View file @
fa3ed04
...
...
@@ -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
)
{
...
...
Please
register
or
sign in
to post a comment