} else if ( $.isFunction( script ) ) {
// Pass jQuery twice so that the signature of the closure which wraps
// the script can bind both '$' and 'jQuery'.
- registry[module].state = 'ready';
script( $, $ );
- handlePending( module );
+ markModuleReady();
} else if ( typeof script === 'string' ) {
// Site and user modules are a legacy scripts that run in the global scope.
// This is transported as a string instead of a function to avoid needing
// Implicit dependency on the site module. Not real dependency because
// it should run after 'site' regardless of whether it succeeds or fails.
mw.loader.using( 'site' ).always( function () {
- registry[module].state = 'ready';
$.globalEval( script );
- handlePending( module );
+ markModuleReady();
} );
} else {
- registry[module].state = 'ready';
$.globalEval( script );
- handlePending( module );
+ markModuleReady();
}
}
} );
} );
// @import (bug 31676)
- QUnit.asyncTest( 'mw.loader.implement( styles has @import)', 5, function ( assert ) {
+ QUnit.asyncTest( 'mw.loader.implement( styles has @import)', 7, function ( assert ) {
var isJsExecuted, $element;
mw.loader.implement(
'test.implement.import',
function () {
- assert.strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
+ assert.strictEqual( isJsExecuted, undefined, 'script not executed multiple times' );
isJsExecuted = true;
- assert.equal( mw.loader.getState( 'test.implement.import' ), 'ready', 'module state is "ready" while implement() is executing javascript' );
+ assert.equal( mw.loader.getState( 'test.implement.import' ), 'loading', 'module state during implement() script execution' );
$element = $( '<div class="mw-test-implement-import">Foo bar</div>' ).appendTo( '#qunit-fixture' );
- assert.equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded before javascript execution' );
+ assert.equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'messages load before script execution' );
assertStyleAsync( assert, $element, 'float', 'right', function () {
assert.equal( $element.css( 'text-align' ), 'center',
}
);
- mw.loader.load( 'test.implement' );
-
+ mw.loader.using( 'test.implement.import' ).always( function () {
+ assert.strictEqual( isJsExecuted, true, 'script executed' );
+ assert.equal( mw.loader.getState( 'test.implement.import' ), 'ready', 'module state after script execution' );
+ } );
} );
QUnit.asyncTest( 'mw.loader.implement( dependency with styles )', 4, function ( assert ) {