This seems to have been caused by a weird race condition that caused the
loader to run while the module in question was also running; could also
have been caused by the module calling mw.loader, but that didn't seem
to be the case here.
The fix is to set .state='ready' before executing the module rather than
after. We can't do this in debug mode (where we're loading raw files and
can't execute things at will), but we have to do this in production
mode to prevent these freakish double executions.
Change-Id: I7e8dbd361fb265e520d3935e3a1fc7e3b6710b66
was initialized.
* (bug 38093) Gender of changed user groups missing in Special:Log/rights
* (bug 35893) Special:Block needs to load mediawiki.special.block.js.
+* (bug 37331) ResourceLoader modules sometimes execute twice in Firefox
=== API changes in 1.20 ===
* (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
registry[module].state = 'loading';
nestedAddScript( script, markModuleReady, registry[module].async, 0 );
} else if ( $.isFunction( script ) ) {
+ registry[module].state = 'ready';
script( $ );
- markModuleReady();
+ handlePending( module );
}
} catch ( e ) {
// This needs to NOT use mw.log because these errors are common in production mode
strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
isJsExecuted = true;
- equal( mw.loader.getState( 'test.implement' ), 'loaded', 'module state is "loaded" while implement() is executing javascript' );
+ equal( mw.loader.getState( 'test.implement' ), 'ready', 'module state is "ready" while implement() is executing javascript' );
$element = $( '<div class="mw-test-loaderimplement">Foo bar</div>' ).appendTo( '#qunit-fixture' );