30 parent::__construct(
'JavaScriptTest' );
36 if ( $par ===
'qunit/export' ) {
39 } elseif ( $par ===
null || $par ===
'' || $par ===
'qunit' || $par ===
'qunit/plain' ) {
44 wfHttpError( 404,
'Unknown action',
"Unknown action \"$par\"." );
55 $rl = $out->getResourceLoader();
59 $out->allowClickjacking();
68 $query[
'only'] =
'scripts';
71 $modules = $rl->getTestSuiteModuleNames();
76 new HashConfig( [
'ResourceLoaderStorageEnabled' =>
false ] ),
83 $qunitConfig =
'QUnit.config.autostart = false;'
84 .
'if (window.__karma__) {'
88 .
'window.__karma__.loaded = function () {};'
92 $startupModule = $rl->getModule(
'startup' );
93 $startupModule->setConfig( $config );
94 $code = $rl->makeModuleResponse( $startupContext, [
'startup' => $startupModule ] );
102 . $rl->makeModuleResponse( $embedContext, [
103 'user.options' => $rl->getModule(
'user.options' ),
106 . Xml::encodeJsCall(
'mw.loader.load', [
$modules ] )
108 $encModules = Xml::encodeJsVar(
$modules );
110 var start = window.__karma__ ? window.__karma__.start : QUnit.start;
111 mw.loader.using( $encModules ).always( start );
112 mw.trackSubscribe(
'resourceloader.exception',
function ( topic, err ) {
115 setTimeout(
function () {
122 header(
'Content-Type: text/javascript; charset=utf-8' );
123 header(
'Cache-Control: private, no-cache, must-revalidate' );
124 header(
'Pragma: no-cache' );
130 $basePath = $this->
getConfig()->get(
'ResourceBasePath' );
131 $headHtml = implode(
"\n", [
132 Html::linkedScript(
"$basePath/resources/lib/qunitjs/qunit.js" ),
133 Html::linkedStyle(
"$basePath/resources/lib/qunitjs/qunit.css" ),
134 Html::linkedStyle(
"$basePath/resources/src/qunitjs/qunit-local.css" ),
137 $introHtml = $this->
msg(
'javascripttest-qunit-intro' )
138 ->params(
'https://www.mediawiki.org/wiki/Manual:JavaScript_unit_testing' )
141 $scriptUrl = $this->
getPageTitle(
'qunit/export' )->getFullURL( [
144 $script = Html::linkedScript( $scriptUrl );
146 header(
'Content-Type: text/html; charset=utf-8' );
152<div
id=
"qunit"></div>
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
WebRequest clone which takes values from a provided array.
A Config instance which stores all settings as a member variable.
Provides a fallback sequence for Config objects.
Context object that contains information about the state of a specific ResourceLoader web request.
static makeLoaderConditionalScript( $script)
Wrap JavaScript code to run after the startup module.
static inDebugMode()
Determine whether debug mode is on.
static makeConfigSetScript(array $configuration)
Return JS code which will set the MediaWiki configuration array to the given value.
static makeInlineCodeWithModule( $modules, $script)
Wrap JavaScript code to run after a required module.
execute( $par)
Default execute method Checks user permissions.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
exportJS()
Send the standalone JavaScript payload.
Parent class for all special pages.
getOutput()
Get the OutputPage being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getPageTitle( $subpage=false)
Get a self-referential title object.