Matmarex has uploaded a new change for review.

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


Change subject: jquery.client: Detect Opera 15
......................................................................

jquery.client: Detect Opera 15

Opera 15 pretends to be Chrome, Safari, Gecko, Mozilla, *and* KHTML.
I don't even.

Also fixed some typos in comments.

Change-Id: I200def556c3891864235ba0f8f2f29278263e030
---
M resources/jquery/jquery.client.js
M tests/qunit/suites/resources/jquery/jquery.client.test.js
2 files changed, 31 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/67/72467/1

diff --git a/resources/jquery/jquery.client.js 
b/resources/jquery/jquery.client.js
index 2da022c..6941ec4 100644
--- a/resources/jquery/jquery.client.js
+++ b/resources/jquery/jquery.client.js
@@ -61,13 +61,13 @@
                                                ['KHTML', 'Konqueror'],
                                                // Firefox nightly builds
                                                ['Minefield', 'Firefox'],
-                                               // This helps keep differnt 
versions consistent
+                                               // This helps keep different 
versions consistent
                                                ['Navigator', 'Netscape'],
                                                // This prevents version 
extraction issues, otherwise translation would happen later
                                                ['PLAYSTATION 3', 'PS3']
                                        ],
-                                       // Strings which precede a version 
number in a user agent string - combined and used as match 1 in
-                                       // version detectection
+                                       // Strings which precede a version 
number in a user agent string - combined and used as
+                                       // match 1 in version detection
                                        versionPrefixes = [
                                                'camino', 'chrome', 'firefox', 
'iceweasel', 'netscape', 'netscape6', 'opera', 'version', 'konqueror',
                                                'lynx', 'msie', 'safari', 
'ps3', 'android'
@@ -147,14 +147,22 @@
                                        version = '2.0';
                                }
                                // Expose Opera 10's lies about being Opera 9.8
-                               if ( name === 'opera' && version >= 9.8) {
-                                       match = ua.match( 
/version\/([0-9\.]*)/i );
+                               if ( name === 'opera' && version >= 9.8 ) {
+                                       match = ua.match( /version\/([0-9\.]*)/ 
);
                                        if ( match && match[1] ) {
                                                version = match[1];
                                        } else {
                                                version = '10';
                                        }
                                }
+                               // And Opera 15's lies about being Chrome
+                               if ( name === 'chrome' && ( match = ua.match( 
/opr\/([0-9\.]*)/ ) ) ) {
+                                       if ( match[1] ) {
+                                               name = 'opera';
+                                               version = match[1];
+                                       }
+                               }
+
                                versionNumber = parseFloat( version, 10 ) || 
0.0;
 
                                /* Caching */
diff --git a/tests/qunit/suites/resources/jquery/jquery.client.test.js 
b/tests/qunit/suites/resources/jquery/jquery.client.test.js
index b2a6fd5..4163e9e 100644
--- a/tests/qunit/suites/resources/jquery/jquery.client.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.client.test.js
@@ -264,6 +264,24 @@
                                        rtl: true
                                }
                        },
+                       // Opera 15 (WebKit-based)
+                       'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 
(KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.130': {
+                               title: 'Opera 15',
+                               platform: 'Win32',
+                               profile: {
+                                       name: 'opera',
+                                       layout: 'webkit',
+                                       layoutVersion: 537,
+                                       platform: 'win',
+                                       version: '15.0.1147.130',
+                                       versionBase: '15',
+                                       versionNumber: 15
+                               },
+                               wikiEditor: {
+                                       ltr: true,
+                                       rtl: true
+                               }
+                       },
                        // Chrome 5
                        // Chrome 6
                        // Chrome 7

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I200def556c3891864235ba0f8f2f29278263e030
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matmarex <matma....@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to