mediawiki.user: Check crypto.getRandomValues before use
authorumherirrender <umherirrender_de.wp@web.de>
Tue, 3 Mar 2015 18:21:51 +0000 (19:21 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 3 Mar 2015 22:19:26 +0000 (22:19 +0000)
Firefox in version 16 implements crypto, but not function
getRandomValues, which causes a JavaScript error.

Bug: T91378
Change-Id: If4320e83af74bb1e90cc16d739d143a4bac7471b

resources/src/mediawiki/mediawiki.user.js

index b777cd3..817c856 100644 (file)
@@ -78,7 +78,7 @@
                                crypto = window.crypto || window.msCrypto;
 
                        // Based on https://github.com/broofa/node-uuid/blob/bfd9f96127/uuid.js
-                       if ( crypto ) {
+                       if ( crypto && crypto.getRandomValues ) {
                                // Fill an array with 8 random values, each of which is 8 bits.
                                // Note that Uint8Array is array-like but does not implement Array.
                                rnds = new Uint8Array( 8 );