mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
Merge "Remove duplication from browser whitelist"
This commit is contained in:
commit
0fbf8971c1
|
@ -107,7 +107,8 @@ ve.init.mw.DesktopArticleTarget.static.actionGroups = [
|
|||
];
|
||||
|
||||
/**
|
||||
* Compatibility map used with jQuery.client to black-list incompatible browsers.
|
||||
* Compatibility map used with jQuery.client to decide if a browser should
|
||||
* receive a compatibility warning. Blacklisting is handled in DesktopArticleTarget.init.
|
||||
*
|
||||
* @static
|
||||
* @property
|
||||
|
@ -117,13 +118,14 @@ ve.init.mw.DesktopArticleTarget.static.compatibility = {
|
|||
// The value is either null (match all versions) or a list of tuples
|
||||
// containing an inequality (<,>,<=,>=) and a version number
|
||||
whitelist: {
|
||||
firefox: [ [ '>=', 12 ] ],
|
||||
iceweasel: [ [ '>=', 10 ] ],
|
||||
safari: [ [ '>=', 7 ] ],
|
||||
chrome: [ [ '>=', 19 ] ],
|
||||
msie: [ [ '>=', 10 ] ],
|
||||
edge: [ [ '>=', 12 ] ],
|
||||
opera: [ [ '>=', 15 ] ]
|
||||
iceweasel: [ [ '>=', 10 ] ],
|
||||
opera: [ [ '>=', 15 ] ],
|
||||
// All non-blacklisted versions are whitelisted:
|
||||
firefox: null,
|
||||
safari: null,
|
||||
msie: null,
|
||||
edge: null
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
QUnit.module( 've.init.mw.DesktopArticleTarget', ve.test.utils.mwEnvironment );
|
||||
|
||||
QUnit.test( 'compatibility', function ( assert ) {
|
||||
var i, profile, list, matches, compatibility,
|
||||
var i, profile, matches, compatibility,
|
||||
cases = [
|
||||
{
|
||||
msg: 'Unidentified browser',
|
||||
|
@ -150,6 +150,11 @@ QUnit.test( 'compatibility', function ( assert ) {
|
|||
userAgent: 'Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.16',
|
||||
matches: []
|
||||
},
|
||||
{
|
||||
msg: 'Opera 15.0',
|
||||
userAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100',
|
||||
matches: [ 'whitelist' ]
|
||||
},
|
||||
{
|
||||
msg: 'BlackBerry',
|
||||
userAgent: 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+',
|
||||
|
@ -176,11 +181,15 @@ QUnit.test( 'compatibility', function ( assert ) {
|
|||
for ( i = 0; i < cases.length; i++ ) {
|
||||
profile = $.client.profile( { userAgent: cases[ i ].userAgent, platform: '' } );
|
||||
matches = [];
|
||||
for ( list in compatibility ) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
[ 'blacklist', 'whitelist' ].every( function ( list ) {
|
||||
if ( $.client.test( compatibility[ list ], profile, true ) ) {
|
||||
matches.push( list );
|
||||
// Don't check whitelist if on blacklist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} );
|
||||
assert.deepEqual( matches, cases[ i ].matches,
|
||||
cases[ i ].msg + ': ' + ( cases[ i ].matches.length ? cases[ i ].matches.join() : 'greylist (no matches)' ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue