- // Embed page-specific mw.config variables.
- // The current Special page shouldn't be relevant to tests, but various modules (which
- // are loaded before the test suites), reference mw.config while initialising.
- $code = ResourceLoader::makeConfigSetScript( $out->getJSVars() );
- // Embed private modules as they're not allowed to be loaded dynamically
- $code .= $rl->makeModuleResponse( $embedContext, [
- 'user.options' => $rl->getModule( 'user.options' ),
- 'user.tokens' => $rl->getModule( 'user.tokens' ),
- ] );
- // Catch exceptions (such as "dependency missing" or "unknown module") so that we
- // always start QUnit. Re-throw so that they are caught and reported as global exceptions
- // by QUnit and Karma.
- $modules = Xml::encodeJsVar( $modules );
- $code .= <<<CODE
-(function () {
+ $code .= <<<JAVASCRIPT
+ // Disable module storage.
+ // The unit test for mw.loader.store will enable it
+ // explicitly with a mock timer.
+ mw.loader.store.enabled = false;
+JAVASCRIPT;
+ // The following has to be deferred via RLQ because the startup module is asynchronous.
+ $code .= ResourceLoader::makeLoaderConditionalScript(
+ // Embed page-specific mw.config variables.
+ // The current Special page shouldn't be relevant to tests, but various modules (which
+ // are loaded before the test suites), reference mw.config while initialising.
+ ResourceLoader::makeConfigSetScript( $out->getJSVars() )
+ // Embed private modules as they're not allowed to be loaded dynamically
+ . $rl->makeModuleResponse( $embedContext, [
+ 'user.options' => $rl->getModule( 'user.options' ),
+ 'user.tokens' => $rl->getModule( 'user.tokens' ),
+ ] )
+ // Load all the test suites
+ . Xml::encodeJsCall( 'mw.loader.load', [ $modules ] )
+ );
+ $encModules = Xml::encodeJsVar( $modules );
+ $code .= ResourceLoader::makeInlineCodeWithModule( 'mediawiki.base', <<<JAVASCRIPT