*
* Other browsers that pass the check are considered Grade X.
*
- * @param {string} [str] User agent, defaults to navigator.userAgent
+ * @private
+ * @param {string} ua User agent string
* @return {boolean} User agent is compatible with MediaWiki JS
*/
-function isCompatible( str ) {
- var ua = str || navigator.userAgent;
+function isCompatible( ua ) {
return !!(
// https://caniuse.com/#feat=es5
// https://caniuse.com/#feat=use-strict
// https://caniuse.com/#feat=addeventlistener
'addEventListener' in window &&
- // Hardcoded exceptions for browsers that pass the requirement but we don't want to
- // support in the modern run-time.
- // Note: Please extend the regex instead of adding new ones
+ // Hardcoded exceptions for browsers that pass the requirement but we don't
+ // want to support in the modern run-time.
+ //
+ // Please extend the regex instead of adding new ones!
+ // And add a test case to startup.test.js
!ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
);
}
-if ( !isCompatible() ) {
+if ( !isCompatible( navigator.userAgent ) ) {
// Handle Grade C
// Undo speculative Grade A <html> class. See ResourceLoaderClientHtml::getDocumentAttributes().
document.documentElement.className = document.documentElement.className
* The $CODE and $VARS placeholders are substituted in ResourceLoaderStartUpModule.php.
*/
( function () {
+ /* global mw */
mw.config = new mw.Map( $VARS.wgLegacyJavaScriptGlobals );
$CODE.registrations();
mw.config.set( $VARS.configuration );
// Process callbacks for Grade A
- // Must be after registrations and mw.config.set, which mw.loader depends on.
var queue = window.RLQ;
- // Redefine push(), but keep type as array for storing callbacks that require modules.
+ // Replace RLQ placeholder from ResourceLoaderClientHtml with an implementation
+ // that executes simple callbacks, but continues to store callbacks that require
+ // modules.
window.RLQ = [];
/* global RLQ */
RLQ.push = function ( fn ) {
}
};
while ( queue && queue[ 0 ] ) {
- // Re-use our push()
+ // Re-use our new push() method
RLQ.push( queue.shift() );
}