From de2a19da9c48e5f7de803134446db8b691d69994 Mon Sep 17 00:00:00 2001 From: John Gozde Date: Wed, 11 Jun 2014 23:32:50 -0600 Subject: [PATCH] Use Array.prototype.slice in window.callPhantom. window.callPhantom formerly used Array.prototype.splice for cloning its arguments to the internal _phantom.call. This relied on non-standard behaviour of the splice method when only a single argument was passed to it (it requires 2 arguments). The correct method for cloning the arguments array is to use Array.prototype.slice, which accepts a single argument (index) and returns a new array from the specified index. https://github.com/ariya/phantomjs/issues/12306 --- src/webpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webpage.cpp b/src/webpage.cpp index aaa26e06..095e5f83 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -76,7 +76,7 @@ #define BLANK_HTML "" #define CALLBACKS_OBJECT_NAME "_phantom" #define INPAGE_CALL_NAME "window.callPhantom" -#define CALLBACKS_OBJECT_INJECTION INPAGE_CALL_NAME" = function() { return window."CALLBACKS_OBJECT_NAME".call.call(_phantom, Array.prototype.splice.call(arguments, 0)); };" +#define CALLBACKS_OBJECT_INJECTION INPAGE_CALL_NAME" = function() { return window."CALLBACKS_OBJECT_NAME".call.call(_phantom, Array.prototype.slice.call(arguments, 0)); };" #define CALLBACKS_OBJECT_PRESENT "typeof(window."CALLBACKS_OBJECT_NAME") !== \"undefined\";" #define STDOUT_FILENAME "/dev/stdout"