mediawiki.debug: Fix crash in browsers without Function#bind
authorErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 25 Aug 2014 23:59:29 +0000 (16:59 -0700)
committerEBernhardson <ebernhardson@wikimedia.org>
Wed, 27 Aug 2014 19:55:41 +0000 (19:55 +0000)
PhantomJS has a partial ECMAScript 5 implementation but it does
not include Function.prototype.bind.  Detect that and error gracefully
instead of erroring out in the middle of a phantomjs qunit run.

Change-Id: Ic06e08490e8f297fda479c4adaf9b2d8735f63ad

resources/src/mediawiki/mediawiki.debug.profile.js

index 64ec6c3..b4d5773 100644 (file)
                 * @param string tag to create
                 * @return DOMElement
                 */
-               createSvgElement: document.createElementNS
+               createSvgElement: ( document.createElementNS && Function.prototype.bind )
                        ? document.createElementNS.bind( document, 'http://www.w3.org/2000/svg' )
                        // throw a error for browsers which does not support document.createElementNS (IE<8)
-                       : function () { throw new Error( 'document.createElementNS not supported' ); },
+                       : function () { throw new Error( 'An ES5 compatible javascript engine is required for the profile visualization.' ); },
 
                /**
                 * @param DOMElement|undefined