From 6df16c591219d87058b4c48682d503382e44693f Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Mon, 3 Sep 2012 23:19:35 -0400 Subject: Set up PhantomJS testing. --- tests/dom_tests/bind.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/dom_tests/bind.js (limited to 'tests/dom_tests/bind.js') diff --git a/tests/dom_tests/bind.js b/tests/dom_tests/bind.js new file mode 100644 index 00000000..833f8006 --- /dev/null +++ b/tests/dom_tests/bind.js @@ -0,0 +1,27 @@ +/* + * Polyfill taken from https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind + * Necessary because the current version of PhantomJS doesn't yet support bind(). + */ +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} -- cgit v1.2.3