Merge "maintenance: Document secondary purpose of --server"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.user.js
index 65e9e41..5fc1990 100644 (file)
@@ -4,7 +4,7 @@
  */
 /* global Uint32Array */
 ( function ( mw, $ ) {
-       var userInfoPromise;
+       var userInfoPromise, stickyRandomSessionId;
 
        /**
         * Get the current user's groups or rights
@@ -48,7 +48,7 @@
                                // Support: IE 11
                                crypto = window.crypto || window.msCrypto;
 
-                       if ( crypto && crypto.getRandomValues ) {
+                       if ( crypto && crypto.getRandomValues && typeof Uint32Array === 'function' ) {
                                // Fill an array with 2 random values, each of which is 32 bits.
                                // Note that Uint32Array is array-like but does not implement Array.
                                rnds = new Uint32Array( 2 );
                        return hexRnds.join( '' );
                },
 
+               /**
+                * A sticky generateRandomSessionId for the current JS execution context,
+                * cached within this class.
+                *
+                * @return {string} 64 bit integer in hex format, padded
+                */
+               stickyRandomId: function () {
+                       if ( !stickyRandomSessionId ) {
+                               stickyRandomSessionId = mw.user.generateRandomSessionId();
+                       }
+
+                       return stickyRandomSessionId;
+               },
+
                /**
                 * Get the current user's database id
                 *