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
2.0
John Gozde 2014-06-11 23:32:50 -06:00 committed by Ariya Hidayat
parent a86ae1948c
commit de2a19da9c
1 changed files with 1 additions and 1 deletions

View File

@ -76,7 +76,7 @@
#define BLANK_HTML "<html><head></head><body></body></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"