Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/111674

Change subject: jquery.client: Include platform in the profile cache key
......................................................................

jquery.client: Include platform in the profile cache key

When different tests run a similar userAgent string but with
a different platform, it returns an inappropiate cache object

e.g.
 userAgent: Firefox
 platform: Linux x86_64
 -> { platform: 'linux' }
 userAgent: Firefox
 platform: MacIntel
 -> { platform: 'linux' }
 (instead of platform: 'mac' )

Change-Id: Iaf2a5711ace82cbd2b68486e9680c7a6bcb7f9da
---
M resources/jquery/jquery.client.js
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/74/111674/1

diff --git a/resources/jquery/jquery.client.js 
b/resources/jquery/jquery.client.js
index f35782b..d0f61cb 100644
--- a/resources/jquery/jquery.client.js
+++ b/resources/jquery/jquery.client.js
@@ -9,7 +9,7 @@
         * @var {Object} profileCache Keyed by userAgent string,
         * value is the parsed $.client.profile object for that user agent.
         */
-       var profileCache = {};
+       var profileCache = window.xprofileCache = {};
 
        /* Public Methods */
 
@@ -33,12 +33,16 @@
                 */
                profile: function ( nav ) {
                        /*jshint boss: true */
+                       var key;
 
                        if ( nav === undefined ) {
                                nav = window.navigator;
                        }
+
+                       key = nav.userAgent + '|' + nav.platform;
+
                        // Use the cached version if possible
-                       if ( profileCache[nav.userAgent] === undefined ) {
+                       if ( profileCache[ key ] === undefined ) {
 
                                var
                                        versionNumber,
@@ -174,7 +178,7 @@
 
                                /* Caching */
 
-                               profileCache[nav.userAgent] = {
+                               profileCache[ key ] = {
                                        name: name,
                                        layout: layout,
                                        layoutVersion: layoutversion,
@@ -184,7 +188,7 @@
                                        versionNumber: versionNumber
                                };
                        }
-                       return profileCache[nav.userAgent];
+                       return profileCache[ key ];
                },
 
                /**

-- 
To view, visit https://gerrit.wikimedia.org/r/111674
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf2a5711ace82cbd2b68486e9680c7a6bcb7f9da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to