mw.loader: Log unknown modules in load() to console
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 8 Jul 2017 04:29:36 +0000 (21:29 -0700)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 11 Jul 2017 15:40:54 +0000 (15:40 +0000)
Follows-up If8ff31b530dfbd882. Now that we have resolveStubbornly,
we don't need to filter out unknown modules ahead of time.

Aside from removing the needless filter condition, it also has
the benefit of causing a message to be logged to the console,
which can help discover problems. Previously these were silently
ignored.

Change-Id: I700db4931dfd0a412a8eca66c4a74b8831ab0086

resources/src/mediawiki/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js

index 7a835a8..18f7f0a 100644 (file)
                                        // Filter out top-level modules that are unknown or failed to load before.
                                        filtered = $.grep( modules, function ( module ) {
                                                var state = mw.loader.getState( module );
-                                               return state !== null && state !== 'error' && state !== 'missing';
+                                               return state !== 'error' && state !== 'missing';
                                        } );
                                        // Resolve remaining list using the known dependency tree.
                                        // This also filters out modules with unknown dependencies. (T36853)
index 9dc9e5d..a00b3cb 100644 (file)
                ).always( done );
        } );
 
-       QUnit.test( '.load() - Error: Unregistered (ignored)', function ( assert ) {
-               assert.expect( 0 );
-               mw.loader.load( 'test.using.unreg2' );
+       QUnit.test( '.load() - Error: Unregistered', function ( assert ) {
+               var capture = [];
+               this.sandbox.stub( mw, 'track', function ( topic, data ) {
+                       capture.push( {
+                               topic: topic,
+                               error: data.exception && data.exception.message,
+                               source: data.source
+                       } );
+               } );
+
+               mw.loader.load( 'test.load.unreg' );
+               assert.deepEqual(
+                       [ {
+                               topic: 'resourceloader.exception',
+                               error: 'Unknown dependency: test.load.unreg',
+                               source: 'resolve'
+                       } ],
+                       capture
+               );
        } );
 
        // Regression test for T36853