https://bugzilla.wikimedia.org/show_bug.cgi?id=44299

--- Comment #19 from Krinkle <[email protected]> ---
(In reply to comment #18)
> Oh, array filter unsupported in IE versions prior to 9,
> https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/
> Array/filter
> 
> There are lots of ways to do it.  The following should produce an empty
> string,
> otherwise it produces a string identifying problematic modules and their
> state. 
> 
> var modules = mw.loader.getModuleNames(),
>     len = modules.length,
>     name, state,
>     bad = [],
>     err = '';
> 
> for (var i = 0; i < len; i++) {
>     state = mw.loader.getState( modules[i] );
>     if ( state !== 'ready' && state !== 'registered' ) {
>         bad.push ( modules[i] + ' state is ' + state );
>     }
> }
> if ( bad.length ) {
>     err = "troubled modules: " + bad.join( '; ') + '.';
> }
> err;
> // Something like assertEmptyString( err );

Unnecessarily complex, and produces output that is hard to use.

Probably more like (untested):

var i, len, state,
 modules = mw.loader.getModuleNames(),
 error = [],
 missing = [];

for ( i = 0, len = modules.length; i < len; i++ ) {
    state = mw.loader.getState( modules[i] );
    if ( state === 'error' ) {
        error.push( modules[i] );
    }
    if ( state === 'missing' ) {
        missing.push( modules[i] );
    }
}

assert.deepEqual( error, [], 'Modules in error state' );
assert.deepEqual( missing, [], 'Modules in missing state' );


Anyway, patch something like this up for mediawiki core's qunit test.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to