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(),
99 'debug' => ResourceLoader::inDebugMode() ?
'true' :
'false',
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;
130 $code .= ResourceLoader::makeLoaderConditionalScript(
134 ResourceLoader::makeConfigSetScript(
$out->getJSVars() )
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 );
144 $code .= ResourceLoader::makeInlineCodeWithModule(
'mediawiki.base', <<<JAVASCRIPT
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( [
191 'debug' => ResourceLoader::inDebugMode() ?
'true' :
'false',
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...
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 When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php