From: MatmaRex Date: Sat, 1 Dec 2012 13:34:29 +0000 (+0100) Subject: (bug 42604) fix faulty browser detection code for Opera X-Git-Tag: 1.31.0-rc.0~21334^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=cd19809f11b56b0621115c51a62b2aa94b571362;p=lhc%2Fweb%2Fwiklou.git (bug 42604) fix faulty browser detection code for Opera Opera's `navigator.userAgent` might not include the "Version/major.minor" part, causing the code relying on it being present to blow up. This patch fixes the issue. Also added tests for Opera. Change-Id: I9ceb7517e00042366e45cf13aa89262ed19709c0 --- diff --git a/resources/jquery/jquery.client.js b/resources/jquery/jquery.client.js index b35dbbbe1d..ae6f2b0b3a 100644 --- a/resources/jquery/jquery.client.js +++ b/resources/jquery/jquery.client.js @@ -148,7 +148,12 @@ } // Expose Opera 10's lies about being Opera 9.8 if ( name === 'opera' && version >= 9.8) { - version = ua.match( /version\/([0-9\.]*)/i )[1] || 10; + match = ua.match( /version\/([0-9\.]*)/i ); + if ( match && match[1] ) { + version = match[1]; + } else { + version = '10'; + } } versionNumber = parseFloat( version, 10 ) || 0.0; diff --git a/tests/qunit/suites/resources/jquery/jquery.client.test.js b/tests/qunit/suites/resources/jquery/jquery.client.test.js index bbc88525a5..29c665702d 100644 --- a/tests/qunit/suites/resources/jquery/jquery.client.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.client.test.js @@ -161,7 +161,42 @@ } }, // Safari 5 - // Opera 10 + // Opera 10+ + 'Opera/9.80 (Windows NT 5.1)': { + title: 'Opera 10+ (exact version unspecified)', + platform: 'Win32', + profile: { + name: 'opera', + layout: 'presto', + layoutVersion: 'unknown', + platform: 'win', + version: '10', + versionBase: '10', + versionNumber: 10 + }, + wikiEditor: { + ltr: true, + rtl: true + } + }, + // Opera 12 + 'Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.11': { + title: 'Opera 12', + platform: 'Win32', + profile: { + name: 'opera', + layout: 'presto', + layoutVersion: 'unknown', + platform: 'win', + version: '12.11', + versionBase: '12', + versionNumber: 12.11 + }, + wikiEditor: { + ltr: true, + rtl: true + } + }, // Chrome 5 // Chrome 6 // Chrome 7