+ $embedContext = new ResourceLoaderContext( $rl, new FauxRequest( $query ) );
+ $query['only'] = 'scripts';
+ $startupContext = new ResourceLoaderContext( $rl, new FauxRequest( $query ) );
+
+ $modules = $rl->getTestModuleNames( 'qunit' );
+
+ // The below is essentially a pure-javascript version of OutputPage::getHeadScripts.
+ $startup = $rl->makeModuleResponse( $startupContext, array(
+ 'startup' => $rl->getModule( 'startup' ),
+ ) );
+ // 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, array(
+ 'user.options' => $rl->getModule( 'user.options' ),
+ 'user.tokens' => $rl->getModule( 'user.tokens' ),
+ ) );
+ $code .= Xml::encodeJsCall( 'mw.loader.load', array( $modules ) );
+
+ header( 'Content-Type: text/javascript; charset=utf-8' );
+ header( 'Cache-Control: private, no-cache, must-revalidate' );
+ header( 'Pragma: no-cache' );
+ echo $startup;
+ echo "\n";
+ // Note: The following has to be wrapped in a script tag because the startup module also
+ // writes a script tag (the one loading mediawiki.js). Script tags are synchronous, block
+ // each other, and run in order. But they don't nest. The code appended after the startup
+ // module runs before the added script tag is parsed and executed.
+ echo Xml::encodeJsCall( 'document.write', array( Html::inlineScript( $code ) ) );
+ }
+
+ private function plainQUnit() {
+ $out = $this->getOutput();
+ $out->disable();
+
+ $url = $this->getPageTitle( 'qunit/export' )->getFullURL( array(
+ 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
+ ) );
+
+ $styles = $out->makeResourceLoaderLink( 'jquery.qunit', ResourceLoaderModule::TYPE_STYLES, false );
+ // Use 'raw' since this is a plain HTML page without ResourceLoader
+ $scripts = $out->makeResourceLoaderLink( 'jquery.qunit', ResourceLoaderModule::TYPE_SCRIPTS, false, array( 'raw' => 'true' ) );
+
+ $head = trim( $styles['html'] . $scripts['html'] );
+ $html = <<<HTML
+<!DOCTYPE html>
+<title>QUnit</title>
+$head
+<div id="qunit"></div>
+HTML;
+ $html .= "\n" . Html::linkedScript( $url );
+
+ header( 'Content-Type: text/html; charset=utf-8' );
+ echo $html;
+ }
+
+ /**
+ * Return an array of subpages that this special page will accept.
+ *
+ * @return string[] subpages
+ */
+ public function getSubpagesForPrefixSearch() {
+ return self::$frameworks;