Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Another tweak for "evaluateAsync".
Browse files Browse the repository at this point in the history
Making sure all the parameters are passed on correctly.

http://code.google.com/p/phantomjs/issues/detail?id=593
  • Loading branch information
detro authored and ariya committed Jun 15, 2012
1 parent caf1365 commit ebc1855
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/modules/webpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,15 @@ exports.create = function (opts) {
* @param {...} args function arguments
*/
page.evaluateAsync = function (func, timeMs, args) {
var funcAsync;
var args = Array.prototype.splice.call(arguments, 0);

if (!(func instanceof Function || typeof func === 'string' || func instanceof String)) {
throw "Wrong use of WebPage#evaluateAsync";
}
funcAsync = "function() { setTimeout(" + func.toString() + ", " + timeMs + "); }";
// Wrapping the "func" argument into a setTimeout
args.splice(0, 0, "function() { setTimeout(" + func.toString() + ", " + timeMs + "); }");

this.evaluate(funcAsync, arguments);
this.evaluate.apply(this, args);
};

// Copy options into page
Expand Down

0 comments on commit ebc1855

Please sign in to comment.