Browse Source

Tests now work under phantomjs again

JC Brand 11 years ago
parent
commit
e62ee8836a
2 changed files with 23 additions and 1 deletions
  1. 3 0
      README.rst
  2. 20 1
      tests_main.js

+ 3 - 0
README.rst

@@ -2,6 +2,9 @@
 converse.js
 ===========
 
+.. figure:: https://api.travis-ci.org/jcbrand/converse.js.png?branch=master
+   :alt: Build Status
+
 Converse.js_ is a web based `XMPP/Jabber`_ instant messaging client.
 
 It enables you to add chat functionality to your website, independent of any

+ 20 - 1
tests_main.js

@@ -1,4 +1,3 @@
-
 require.config({
     paths: {
         "jquery": "components/jquery/jquery",
@@ -61,6 +60,26 @@ require.config({
     }
 });
 
+// Polyfill 'bind' which is not available in phantomjs < 2.0
+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;
+    };
+}
+
 require([
     "jquery",
     "converse",