Another tweak for "evaluateAsync".

Making sure all the parameters are passed on correctly.

http://code.google.com/p/phantomjs/issues/detail?id=593
1.6
Ivan De Marino 2012-05-16 17:10:26 +01:00 committed by Ariya Hidayat
parent caf13651b7
commit ebc1855483
1 changed files with 4 additions and 3 deletions

View File

@ -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