diff options
| author | Jez Ng | 2012-09-03 23:19:35 -0400 | 
|---|---|---|
| committer | Jez Ng | 2012-09-08 04:30:26 -0400 | 
| commit | 6df16c591219d87058b4c48682d503382e44693f (patch) | |
| tree | 3ec4044a51c557cd59df6d6a9ff712e6491a9c18 /tests/dom_tests/bind.js | |
| parent | 8437dd96144475343562c9a6aa2f14469bc75a56 (diff) | |
| download | vimium-6df16c591219d87058b4c48682d503382e44693f.tar.bz2 | |
Set up PhantomJS testing.
Diffstat (limited to 'tests/dom_tests/bind.js')
| -rw-r--r-- | tests/dom_tests/bind.js | 27 | 
1 files changed, 27 insertions, 0 deletions
| 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; +  }; +} | 
