From: Timo Tijhof Date: Sat, 8 Jul 2017 04:29:36 +0000 (-0700) Subject: mw.loader: Log unknown modules in load() to console X-Git-Tag: 1.31.0-rc.0~2740 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=12cca1c68e9803692a8f3cf71992f3cc96702cda mw.loader: Log unknown modules in load() to console 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 --- diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 7a835a805b..18f7f0abda 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -2083,7 +2083,7 @@ // 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) diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js index 9dc9e5d661..a00b3cb889 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js @@ -230,9 +230,25 @@ ).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