30 parent::__construct(
'JavaScriptTest' );
37 $out->disallowUserJs();
42 $out->allowClickjacking();
45 if ( $par ===
'qunit/export' ) {
52 if ( $par ===
null || $par ===
'' || $par ===
'qunit' || $par ===
'qunit/plain' ) {
58 $out->setStatusCode( 404 );
59 $out->setPageTitle( $this->
msg(
'javascripttest' ) );
62 . $this->
msg(
'javascripttest-pagetext-unknownaction' )
63 ->plaintextParams( $par )->parseAsBlock()
74 $summary = $this->
msg(
'javascripttest-qunit-intro' )
75 ->params(
'https://www.mediawiki.org/wiki/Manual:JavaScript_unit_testing' )
77 return "<div id=\"mw-javascripttest-summary\">$summary</div>";
94 $rl =
$out->getResourceLoader();
98 'skin' => $this->
getSkin()->getSkinName(),
103 $query[
'only'] =
'scripts';
106 $modules = $rl->getTestModuleNames(
'qunit' );
111 $qunitConfig =
'QUnit.config.autostart = false;'
112 .
'if (window.__karma__) {'
116 .
'window.__karma__.loaded = function () {};'
120 $code = $rl->makeModuleResponse( $startupContext, [
121 'startup' => $rl->getModule(
'startup' ),
123 $code .= <<<JAVASCRIPT
127 mw.loader.store.enabled =
false;
136 . $rl->makeModuleResponse( $embedContext, [
137 'user.options' => $rl->getModule(
'user.options' ),
138 'user.tokens' => $rl->getModule(
'user.tokens' ),
141 . Xml::encodeJsCall(
'mw.loader.load', [
$modules ] )
143 $encModules = Xml::encodeJsVar(
$modules );
145 var start = window.__karma__ ? window.__karma__.start : QUnit.start;
146 mw.loader.using( $encModules ).always( start );
147 mw.trackSubscribe(
'resourceloader.exception',
function ( topic, err ) {
150 setTimeout(
function () {
157 header(
'Content-Type: text/javascript; charset=utf-8' );
158 header(
'Cache-Control: private, no-cache, must-revalidate' );
159 header(
'Pragma: no-cache' );
168 $styles =
$out->makeResourceLoaderLink(
'jquery.qunit',
175 $scripts =
$out->makeResourceLoaderLink(
'jquery.qunit',
177 [
'raw' =>
true,
'sync' =>
true ]
180 $head = implode(
"\n", [ $styles, $scripts ] );
190 $url = $this->
getPageTitle(
'qunit/export' )->getFullURL( [
193 $html .=
"\n" . Html::linkedScript( $url );
195 header(
'Content-Type: text/html; charset=utf-8' );
WebRequest clone which takes values from a provided array.
Object passed around to modules which contains information about the state of a specific loader reque...
static makeLoaderConditionalScript( $script)
Wraps JavaScript code to run after the startup module.
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie,...
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
static makeInlineCodeWithModule( $modules, $script)
Wraps JavaScript code to run after a required module.
exportQUnit()
Generate self-sufficient JavaScript payload to run the tests elsewhere.
execute( $par)
Default execute method Checks user permissions.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getSummaryHtml()
Get summary text wrapped in a container.
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getSkin()
Shortcut to get the skin being used for this instance.
msg( $key)
Wrapper around wfMessage that sets the current context.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query