TableDiffFormatter: Don't repeatedly call array_shift()
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.jqueryMsg.test.js
1 ( function ( mw, $ ) {
2 var formatText, formatParse, formatnumTests, specialCharactersPageName, expectedListUsers,
3 expectedListUsersSitename, expectedEntrypoints,
4 mwLanguageCache = {},
5 hasOwn = Object.hasOwnProperty;
6
7 // When the expected result is the same in both modes
8 function assertBothModes( assert, parserArguments, expectedResult, assertMessage ) {
9 assert.equal( formatText.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'text\'' );
10 assert.equal( formatParse.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'parse\'' );
11 }
12
13 QUnit.module( 'mediawiki.jqueryMsg', QUnit.newMwEnvironment( {
14 setup: function () {
15 this.originalMwLanguage = mw.language;
16 this.parserDefaults = mw.jqueryMsg.getParserDefaults();
17 mw.jqueryMsg.setParserDefaults( {
18 magic: {
19 SITENAME: 'Wiki'
20 }
21 } );
22
23 specialCharactersPageName = '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
24
25 expectedListUsers = '注册<a title="Special:ListUsers" href="/wiki/Special:ListUsers">用户</a>';
26 expectedListUsersSitename = '注册<a title="Special:ListUsers" href="/wiki/Special:ListUsers">用户' +
27 'Wiki</a>';
28
29 expectedEntrypoints = '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>';
30
31 formatText = mw.jqueryMsg.getMessageFunction( {
32 format: 'text'
33 } );
34
35 formatParse = mw.jqueryMsg.getMessageFunction( {
36 format: 'parse'
37 } );
38 },
39 teardown: function () {
40 mw.language = this.originalMwLanguage;
41 mw.jqueryMsg.setParserDefaults( this.parserDefaults );
42 },
43 config: {
44 wgArticlePath: '/wiki/$1',
45 // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
46 wgNamespaceIds: {
47 template: 10,
48 template_talk: 11,
49 // Localised
50 szablon: 10,
51 dyskusja_szablonu: 11
52 },
53 // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
54 wgFormattedNamespaces: {
55 // Localised
56 10: 'Szablon',
57 11: 'Dyskusja szablonu'
58 }
59 },
60 // Messages that are reused in multiple tests
61 messages: {
62 // The values for gender are not significant,
63 // what matters is which of the values is choosen by the parser
64 'gender-msg': '$1: {{GENDER:$2|blue|pink|green}}',
65 'gender-msg-currentuser': '{{GENDER:|blue|pink|green}}',
66
67 'plural-msg': 'Found $1 {{PLURAL:$1|item|items}}',
68 // See https://phabricator.wikimedia.org/T71993
69 'plural-msg-explicit-forms-nested': 'Found {{PLURAL:$1|$1 results|0=no results in {{SITENAME}}|1=$1 result}}',
70 // Assume the grammar form grammar_case_foo is not valid in any language
71 'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
72
73 'formatnum-msg': '{{formatnum:$1}}',
74
75 'portal-url': 'Project:Community portal',
76 'see-portal-url': '{{Int:portal-url}} is an important community page.',
77
78 'jquerymsg-test-statistics-users': '注册[[Special:ListUsers|用户]]',
79 'jquerymsg-test-statistics-users-sitename': '注册[[Special:ListUsers|用户{{SITENAME}}]]',
80
81 'jquerymsg-test-version-entrypoints-index-php': '[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
82
83 'external-link-replace': 'Foo [$1 bar]',
84 'external-link-plural': 'Foo {{PLURAL:$1|is [$2 one]|are [$2 some]|2=[$2 two]|3=three|4=a=b|5=}} things.',
85 'plural-only-explicit-forms': 'It is a {{PLURAL:$1|1=single|2=double}} room.'
86 }
87 } ) );
88
89 /**
90 * Be careful to no run this in parallel as it uses a global identifier (mw.language)
91 * to transport the module back to the test. It musn't be overwritten concurrentely.
92 *
93 * This function caches the mw.language data to avoid having to request the same module
94 * multiple times. There is more than one test case for any given language.
95 */
96 function getMwLanguage( langCode ) {
97 if ( !hasOwn.call( mwLanguageCache, langCode ) ) {
98 mwLanguageCache[ langCode ] = $.ajax( {
99 url: mw.util.wikiScript( 'load' ),
100 data: {
101 skin: mw.config.get( 'skin' ),
102 lang: langCode,
103 debug: mw.config.get( 'debug' ),
104 modules: [
105 'mediawiki.language.data',
106 'mediawiki.language'
107 ].join( '|' ),
108 only: 'scripts'
109 },
110 dataType: 'script',
111 cache: true
112 } ).then( function () {
113 return mw.language;
114 } );
115 }
116 return mwLanguageCache[ langCode ];
117 }
118
119 /**
120 * @param {Function[]} tasks List of functions that perform tasks
121 * that may be asynchronous. Invoke the callback parameter when done.
122 */
123 function process( tasks ) {
124 /*jshint latedef:false */
125 function abort() {
126 tasks.splice( 0, tasks.length );
127 next();
128 }
129 function next() {
130 if ( !tasks ) {
131 // This happens if after the process is completed, one of our callbacks is
132 // invoked. This can happen if a test timed out but the process was still
133 // running. In that case, ignore it. Don't invoke complete() a second time.
134 return;
135 }
136 var task = tasks.shift();
137 if ( task ) {
138 task( next, abort );
139 } else {
140 // Remove tasks list to indicate the process is final.
141 tasks = null;
142 }
143 }
144 next();
145 }
146
147 QUnit.test( 'Replace', 16, function ( assert ) {
148 mw.messages.set( 'simple', 'Foo $1 baz $2' );
149
150 assert.equal( formatParse( 'simple' ), 'Foo $1 baz $2', 'Replacements with no substitutes' );
151 assert.equal( formatParse( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' );
152 assert.equal( formatParse( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' );
153
154 mw.messages.set( 'plain-input', '<foo foo="foo">x$1y&lt;</foo>z' );
155
156 assert.equal(
157 formatParse( 'plain-input', 'bar' ),
158 '&lt;foo foo="foo"&gt;xbary&amp;lt;&lt;/foo&gt;z',
159 'Input is not considered html'
160 );
161
162 mw.messages.set( 'plain-replace', 'Foo $1' );
163
164 assert.equal(
165 formatParse( 'plain-replace', '<bar bar="bar">&gt;</bar>' ),
166 'Foo &lt;bar bar="bar"&gt;&amp;gt;&lt;/bar&gt;',
167 'Replacement is not considered html'
168 );
169
170 mw.messages.set( 'object-replace', 'Foo $1' );
171
172 assert.equal(
173 formatParse( 'object-replace', $( '<div class="bar">&gt;</div>' ) ),
174 'Foo <div class="bar">&gt;</div>',
175 'jQuery objects are preserved as raw html'
176 );
177
178 assert.equal(
179 formatParse( 'object-replace', $( '<div class="bar">&gt;</div>' ).get( 0 ) ),
180 'Foo <div class="bar">&gt;</div>',
181 'HTMLElement objects are preserved as raw html'
182 );
183
184 assert.equal(
185 formatParse( 'object-replace', $( '<div class="bar">&gt;</div>' ).toArray() ),
186 'Foo <div class="bar">&gt;</div>',
187 'HTMLElement[] arrays are preserved as raw html'
188 );
189
190 assert.equal(
191 formatParse( 'external-link-replace', 'http://example.org/?x=y&z' ),
192 'Foo <a href="http://example.org/?x=y&amp;z">bar</a>',
193 'Href is not double-escaped in wikilink function'
194 );
195 assert.equal(
196 formatParse( 'external-link-plural', 1, 'http://example.org' ),
197 'Foo is <a href="http://example.org">one</a> things.',
198 'Link is expanded inside plural and is not escaped html'
199 );
200 assert.equal(
201 formatParse( 'external-link-plural', 2, 'http://example.org' ),
202 'Foo <a href=\"http://example.org\">two</a> things.',
203 'Link is expanded inside an explicit plural form and is not escaped html'
204 );
205 assert.equal(
206 formatParse( 'external-link-plural', 3 ),
207 'Foo three things.',
208 'A simple explicit plural form co-existing with complex explicit plural forms'
209 );
210 assert.equal(
211 formatParse( 'external-link-plural', 4, 'http://example.org' ),
212 'Foo a=b things.',
213 'Only first equal sign is used as delimiter for explicit plural form. Repeated equal signs does not create issue'
214 );
215 assert.equal(
216 formatParse( 'external-link-plural', 5, 'http://example.org' ),
217 'Foo are <a href="http://example.org">some</a> things.',
218 'Invalid explicit plural form. Plural fallback to the "other" plural form'
219 );
220 assert.equal(
221 formatParse( 'external-link-plural', 6, 'http://example.org' ),
222 'Foo are <a href="http://example.org">some</a> things.',
223 'Plural fallback to the "other" plural form'
224 );
225 assert.equal(
226 formatParse( 'plural-only-explicit-forms', 2 ),
227 'It is a double room.',
228 'Plural with explicit forms alone.'
229 );
230 } );
231
232 QUnit.test( 'Plural', 6, function ( assert ) {
233 assert.equal( formatParse( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' );
234 assert.equal( formatParse( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' );
235 assert.equal( formatParse( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' );
236 assert.equal( formatParse( 'plural-msg-explicit-forms-nested', 6 ), 'Found 6 results', 'Plural message with explicit plural forms' );
237 assert.equal( formatParse( 'plural-msg-explicit-forms-nested', 0 ), 'Found no results in Wiki', 'Plural message with explicit plural forms, with nested {{SITENAME}}' );
238 assert.equal( formatParse( 'plural-msg-explicit-forms-nested', 1 ), 'Found 1 result', 'Plural message with explicit plural forms with placeholder nested' );
239 } );
240
241 QUnit.test( 'Gender', 15, function ( assert ) {
242 var originalGender = mw.user.options.get( 'gender' );
243
244 // TODO: These tests should be for mw.msg once mw.msg integrated with mw.jqueryMsg
245 // TODO: English may not be the best language for these tests. Use a language like Arabic or Russian
246 mw.user.options.set( 'gender', 'male' );
247 assert.equal(
248 formatParse( 'gender-msg', 'Bob', 'male' ),
249 'Bob: blue',
250 'Masculine from string "male"'
251 );
252 assert.equal(
253 formatParse( 'gender-msg', 'Bob', mw.user ),
254 'Bob: blue',
255 'Masculine from mw.user object'
256 );
257 assert.equal(
258 formatParse( 'gender-msg-currentuser' ),
259 'blue',
260 'Masculine for current user'
261 );
262
263 mw.user.options.set( 'gender', 'female' );
264 assert.equal(
265 formatParse( 'gender-msg', 'Alice', 'female' ),
266 'Alice: pink',
267 'Feminine from string "female"' );
268 assert.equal(
269 formatParse( 'gender-msg', 'Alice', mw.user ),
270 'Alice: pink',
271 'Feminine from mw.user object'
272 );
273 assert.equal(
274 formatParse( 'gender-msg-currentuser' ),
275 'pink',
276 'Feminine for current user'
277 );
278
279 mw.user.options.set( 'gender', 'unknown' );
280 assert.equal(
281 formatParse( 'gender-msg', 'Foo', mw.user ),
282 'Foo: green',
283 'Neutral from mw.user object' );
284 assert.equal(
285 formatParse( 'gender-msg', 'User' ),
286 'User: green',
287 'Neutral when no parameter given' );
288 assert.equal(
289 formatParse( 'gender-msg', 'User', 'unknown' ),
290 'User: green',
291 'Neutral from string "unknown"'
292 );
293 assert.equal(
294 formatParse( 'gender-msg-currentuser' ),
295 'green',
296 'Neutral for current user'
297 );
298
299 mw.messages.set( 'gender-msg-one-form', '{{GENDER:$1|User}}: $2 {{PLURAL:$2|edit|edits}}' );
300
301 assert.equal(
302 formatParse( 'gender-msg-one-form', 'male', 10 ),
303 'User: 10 edits',
304 'Gender neutral and plural form'
305 );
306 assert.equal(
307 formatParse( 'gender-msg-one-form', 'female', 1 ),
308 'User: 1 edit',
309 'Gender neutral and singular form'
310 );
311
312 mw.messages.set( 'gender-msg-lowercase', '{{gender:$1|he|she}} is awesome' );
313 assert.equal(
314 formatParse( 'gender-msg-lowercase', 'male' ),
315 'he is awesome',
316 'Gender masculine'
317 );
318 assert.equal(
319 formatParse( 'gender-msg-lowercase', 'female' ),
320 'she is awesome',
321 'Gender feminine'
322 );
323
324 mw.messages.set( 'gender-msg-wrong', '{{gender}} test' );
325 assert.equal(
326 formatParse( 'gender-msg-wrong', 'female' ),
327 ' test',
328 'Invalid syntax should result in {{gender}} simply being stripped away'
329 );
330
331 mw.user.options.set( 'gender', originalGender );
332 } );
333
334 QUnit.test( 'Case changing', 8, function ( assert ) {
335 mw.messages.set( 'to-lowercase', '{{lc:thIS hAS MEsSed uP CapItaliZatiON}}' );
336 assert.equal( formatParse( 'to-lowercase' ), 'this has messed up capitalization', 'To lowercase' );
337
338 mw.messages.set( 'to-caps', '{{uc:thIS hAS MEsSed uP CapItaliZatiON}}' );
339 assert.equal( formatParse( 'to-caps' ), 'THIS HAS MESSED UP CAPITALIZATION', 'To caps' );
340
341 mw.messages.set( 'uc-to-lcfirst', '{{lcfirst:THis hAS MEsSed uP CapItaliZatiON}}' );
342 mw.messages.set( 'lc-to-lcfirst', '{{lcfirst:thIS hAS MEsSed uP CapItaliZatiON}}' );
343 assert.equal( formatParse( 'uc-to-lcfirst' ), 'tHis hAS MEsSed uP CapItaliZatiON', 'Lcfirst caps' );
344 assert.equal( formatParse( 'lc-to-lcfirst' ), 'thIS hAS MEsSed uP CapItaliZatiON', 'Lcfirst lowercase' );
345
346 mw.messages.set( 'uc-to-ucfirst', '{{ucfirst:THis hAS MEsSed uP CapItaliZatiON}}' );
347 mw.messages.set( 'lc-to-ucfirst', '{{ucfirst:thIS hAS MEsSed uP CapItaliZatiON}}' );
348 assert.equal( formatParse( 'uc-to-ucfirst' ), 'THis hAS MEsSed uP CapItaliZatiON', 'Ucfirst caps' );
349 assert.equal( formatParse( 'lc-to-ucfirst' ), 'ThIS hAS MEsSed uP CapItaliZatiON', 'Ucfirst lowercase' );
350
351 mw.messages.set( 'mixed-to-sentence', '{{ucfirst:{{lc:thIS hAS MEsSed uP CapItaliZatiON}}}}' );
352 assert.equal( formatParse( 'mixed-to-sentence' ), 'This has messed up capitalization', 'To sentence case' );
353 mw.messages.set( 'all-caps-except-first', '{{lcfirst:{{uc:thIS hAS MEsSed uP CapItaliZatiON}}}}' );
354 assert.equal( formatParse( 'all-caps-except-first' ), 'tHIS HAS MESSED UP CAPITALIZATION', 'To opposite sentence case' );
355 } );
356
357 QUnit.test( 'Grammar', 2, function ( assert ) {
358 assert.equal( formatParse( 'grammar-msg' ), 'Przeszukaj Wiki', 'Grammar Test with sitename' );
359
360 mw.messages.set( 'grammar-msg-wrong-syntax', 'Przeszukaj {{GRAMMAR:grammar_case_xyz}}' );
361 assert.equal( formatParse( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ', 'Grammar Test with wrong grammar template syntax' );
362 } );
363
364 QUnit.test( 'Match PHP parser', mw.libs.phpParserData.tests.length, function ( assert ) {
365 mw.messages.set( mw.libs.phpParserData.messages );
366 var tasks = $.map( mw.libs.phpParserData.tests, function ( test ) {
367 return function ( next, abort ) {
368 var done = assert.async();
369 getMwLanguage( test.lang )
370 .then( function ( langClass ) {
371 mw.config.set( 'wgUserLanguage', test.lang );
372 var parser = new mw.jqueryMsg.parser( { language: langClass } );
373 assert.equal(
374 parser.parse( test.key, test.args ).html(),
375 test.result,
376 test.name
377 );
378 }, function () {
379 assert.ok( false, 'Language "' + test.lang + '" failed to load.' );
380 } )
381 .then( done, done )
382 .then( next, abort );
383 };
384 } );
385
386 process( tasks );
387 } );
388
389 QUnit.test( 'Links', 14, function ( assert ) {
390 var testCases,
391 expectedDisambiguationsText,
392 expectedMultipleBars,
393 expectedSpecialCharacters;
394
395 // The below three are all identical to or based on real messages. For disambiguations-text,
396 // the bold was removed because it is not yet implemented.
397
398 assert.htmlEqual(
399 formatParse( 'jquerymsg-test-statistics-users' ),
400 expectedListUsers,
401 'Piped wikilink'
402 );
403
404 expectedDisambiguationsText = 'The following pages contain at least one link to a disambiguation page.\nThey may have to link to a more appropriate page instead.\nA page is treated as a disambiguation page if it uses a template that is linked from ' +
405 '<a title="MediaWiki:Disambiguationspage" href="/wiki/MediaWiki:Disambiguationspage">MediaWiki:Disambiguationspage</a>.';
406
407 mw.messages.set( 'disambiguations-text', 'The following pages contain at least one link to a disambiguation page.\nThey may have to link to a more appropriate page instead.\nA page is treated as a disambiguation page if it uses a template that is linked from [[MediaWiki:Disambiguationspage]].' );
408 assert.htmlEqual(
409 formatParse( 'disambiguations-text' ),
410 expectedDisambiguationsText,
411 'Wikilink without pipe'
412 );
413
414 assert.htmlEqual(
415 formatParse( 'jquerymsg-test-version-entrypoints-index-php' ),
416 expectedEntrypoints,
417 'External link'
418 );
419
420 // Pipe trick is not supported currently, but should not parse as text either.
421 mw.messages.set( 'pipe-trick', '[[Tampa, Florida|]]' );
422 mw.messages.set( 'reverse-pipe-trick', '[[|Tampa, Florida]]' );
423 mw.messages.set( 'empty-link', '[[]]' );
424 this.suppressWarnings();
425 assert.equal(
426 formatParse( 'pipe-trick' ),
427 '[[Tampa, Florida|]]',
428 'Pipe trick should not be parsed.'
429 );
430 assert.equal(
431 formatParse( 'reverse-pipe-trick' ),
432 '[[|Tampa, Florida]]',
433 'Reverse pipe trick should not be parsed.'
434 );
435 assert.equal(
436 formatParse( 'empty-link' ),
437 '[[]]',
438 'Empty link should not be parsed.'
439 );
440 this.restoreWarnings();
441
442 expectedMultipleBars = '<a title="Main Page" href="/wiki/Main_Page">Main|Page</a>';
443 mw.messages.set( 'multiple-bars', '[[Main Page|Main|Page]]' );
444 assert.htmlEqual(
445 formatParse( 'multiple-bars' ),
446 expectedMultipleBars,
447 'Bar in anchor'
448 );
449
450 expectedSpecialCharacters = '<a title="&quot;Who&quot; wants to be a millionaire &amp; live on &#039;Exotic Island&#039;?" href="/wiki/%22Who%22_wants_to_be_a_millionaire_%26_live_on_%27Exotic_Island%27%3F">&quot;Who&quot; wants to be a millionaire &amp; live on &#039;Exotic Island&#039;?</a>';
451
452 mw.messages.set( 'special-characters', '[[' + specialCharactersPageName + ']]' );
453 assert.htmlEqual(
454 formatParse( 'special-characters' ),
455 expectedSpecialCharacters,
456 'Special characters'
457 );
458
459 mw.messages.set( 'leading-colon', '[[:File:Foo.jpg]]' );
460 assert.htmlEqual(
461 formatParse( 'leading-colon' ),
462 '<a title="File:Foo.jpg" href="/wiki/File:Foo.jpg">File:Foo.jpg</a>',
463 'Leading colon in links is stripped'
464 );
465
466 assert.htmlEqual(
467 formatParse( 'jquerymsg-test-statistics-users-sitename' ),
468 expectedListUsersSitename,
469 'Piped wikilink with parser function in the text'
470 );
471
472 testCases = [
473 [
474 'extlink-html-full',
475 'asd [http://example.org <strong>Example</strong>] asd',
476 'asd <a href="http://example.org"><strong>Example</strong></a> asd'
477 ],
478 [
479 'extlink-html-partial',
480 'asd [http://example.org foo <strong>Example</strong> bar] asd',
481 'asd <a href="http://example.org">foo <strong>Example</strong> bar</a> asd'
482 ],
483 [
484 'wikilink-html-full',
485 'asd [[Example|<strong>Example</strong>]] asd',
486 'asd <a title="Example" href="/wiki/Example"><strong>Example</strong></a> asd'
487 ],
488 [
489 'wikilink-html-partial',
490 'asd [[Example|foo <strong>Example</strong> bar]] asd',
491 'asd <a title="Example" href="/wiki/Example">foo <strong>Example</strong> bar</a> asd'
492 ]
493 ];
494
495 $.each( testCases, function () {
496 var
497 key = this[ 0 ],
498 input = this[ 1 ],
499 output = this[ 2 ];
500 mw.messages.set( key, input );
501 assert.htmlEqual(
502 formatParse( key ),
503 output,
504 'HTML in links: ' + key
505 );
506 } );
507 } );
508
509 QUnit.test( 'Replacements in links', 14, function ( assert ) {
510 var testCases = [
511 [
512 'extlink-param-href-full',
513 'asd [$1 Example] asd',
514 'asd <a href="http://example.com">Example</a> asd'
515 ],
516 [
517 'extlink-param-href-partial',
518 'asd [$1/example Example] asd',
519 'asd <a href="http://example.com/example">Example</a> asd'
520 ],
521 [
522 'extlink-param-text-full',
523 'asd [http://example.org $2] asd',
524 'asd <a href="http://example.org">Text</a> asd'
525 ],
526 [
527 'extlink-param-text-partial',
528 'asd [http://example.org Example $2] asd',
529 'asd <a href="http://example.org">Example Text</a> asd'
530 ],
531 [
532 'extlink-param-both-full',
533 'asd [$1 $2] asd',
534 'asd <a href="http://example.com">Text</a> asd'
535 ],
536 [
537 'extlink-param-both-partial',
538 'asd [$1/example Example $2] asd',
539 'asd <a href="http://example.com/example">Example Text</a> asd'
540 ],
541 [
542 'wikilink-param-href-full',
543 'asd [[$1|Example]] asd',
544 'asd <a title="Example" href="/wiki/Example">Example</a> asd'
545 ],
546 [
547 'wikilink-param-href-partial',
548 'asd [[$1/Test|Example]] asd',
549 'asd <a title="Example/Test" href="/wiki/Example/Test">Example</a> asd'
550 ],
551 [
552 'wikilink-param-text-full',
553 'asd [[Example|$2]] asd',
554 'asd <a title="Example" href="/wiki/Example">Text</a> asd'
555 ],
556 [
557 'wikilink-param-text-partial',
558 'asd [[Example|Example $2]] asd',
559 'asd <a title="Example" href="/wiki/Example">Example Text</a> asd'
560 ],
561 [
562 'wikilink-param-both-full',
563 'asd [[$1|$2]] asd',
564 'asd <a title="Example" href="/wiki/Example">Text</a> asd'
565 ],
566 [
567 'wikilink-param-both-partial',
568 'asd [[$1/Test|Example $2]] asd',
569 'asd <a title="Example/Test" href="/wiki/Example/Test">Example Text</a> asd'
570 ],
571 [
572 'wikilink-param-unpiped-full',
573 'asd [[$1]] asd',
574 'asd <a title="Example" href="/wiki/Example">Example</a> asd'
575 ],
576 [
577 'wikilink-param-unpiped-partial',
578 'asd [[$1/Test]] asd',
579 'asd <a title="Example/Test" href="/wiki/Example/Test">Example/Test</a> asd'
580 ]
581 ];
582
583 $.each( testCases, function () {
584 var
585 key = this[ 0 ],
586 input = this[ 1 ],
587 output = this[ 2 ],
588 paramHref = key.slice( 0, 8 ) === 'wikilink' ? 'Example' : 'http://example.com',
589 paramText = 'Text';
590 mw.messages.set( key, input );
591 assert.htmlEqual(
592 formatParse( key, paramHref, paramText ),
593 output,
594 'Replacements in links: ' + key
595 );
596 } );
597 } );
598
599 // Tests that {{-transformation vs. general parsing are done as requested
600 QUnit.test( 'Curly brace transformation', 16, function ( assert ) {
601 var oldUserLang = mw.config.get( 'wgUserLanguage' );
602
603 assertBothModes( assert, [ 'gender-msg', 'Bob', 'male' ], 'Bob: blue', 'gender is resolved' );
604
605 assertBothModes( assert, [ 'plural-msg', 5 ], 'Found 5 items', 'plural is resolved' );
606
607 assertBothModes( assert, [ 'grammar-msg' ], 'Przeszukaj Wiki', 'grammar is resolved' );
608
609 mw.config.set( 'wgUserLanguage', 'en' );
610 assertBothModes( assert, [ 'formatnum-msg', '987654321.654321' ], '987,654,321.654', 'formatnum is resolved' );
611
612 // Test non-{{ wikitext, where behavior differs
613
614 // Wikilink
615 assert.equal(
616 formatText( 'jquerymsg-test-statistics-users' ),
617 mw.messages.get( 'jquerymsg-test-statistics-users' ),
618 'Internal link message unchanged when format is \'text\''
619 );
620 assert.htmlEqual(
621 formatParse( 'jquerymsg-test-statistics-users' ),
622 expectedListUsers,
623 'Internal link message parsed when format is \'parse\''
624 );
625
626 // External link
627 assert.equal(
628 formatText( 'jquerymsg-test-version-entrypoints-index-php' ),
629 mw.messages.get( 'jquerymsg-test-version-entrypoints-index-php' ),
630 'External link message unchanged when format is \'text\''
631 );
632 assert.htmlEqual(
633 formatParse( 'jquerymsg-test-version-entrypoints-index-php' ),
634 expectedEntrypoints,
635 'External link message processed when format is \'parse\''
636 );
637
638 // External link with parameter
639 assert.equal(
640 formatText( 'external-link-replace', 'http://example.com' ),
641 'Foo [http://example.com bar]',
642 'External link message only substitutes parameter when format is \'text\''
643 );
644 assert.htmlEqual(
645 formatParse( 'external-link-replace', 'http://example.com' ),
646 'Foo <a href="http://example.com">bar</a>',
647 'External link message processed when format is \'parse\''
648 );
649 assert.htmlEqual(
650 formatParse( 'external-link-replace', $( '<i>' ) ),
651 'Foo <i>bar</i>',
652 'External link message processed as jQuery object when format is \'parse\''
653 );
654 assert.htmlEqual(
655 formatParse( 'external-link-replace', function () {} ),
656 'Foo <a href="#">bar</a>',
657 'External link message processed as function when format is \'parse\''
658 );
659
660 mw.config.set( 'wgUserLanguage', oldUserLang );
661 } );
662
663 QUnit.test( 'Int', 4, function ( assert ) {
664 var newarticletextSource = 'You have followed a link to a page that does not exist yet. To create the page, start typing in the box below (see the [[{{Int:Foobar}}|foobar]] for more info). If you are here by mistake, click your browser\'s back button.',
665 expectedNewarticletext,
666 helpPageTitle = 'Help:Foobar';
667
668 mw.messages.set( 'foobar', helpPageTitle );
669
670 expectedNewarticletext = 'You have followed a link to a page that does not exist yet. To create the page, start typing in the box below (see the ' +
671 '<a title="Help:Foobar" href="/wiki/Help:Foobar">foobar</a> for more info). If you are here by mistake, click your browser\'s back button.';
672
673 mw.messages.set( 'newarticletext', newarticletextSource );
674
675 assert.htmlEqual(
676 formatParse( 'newarticletext' ),
677 expectedNewarticletext,
678 'Link with nested message'
679 );
680
681 assert.equal(
682 formatParse( 'see-portal-url' ),
683 'Project:Community portal is an important community page.',
684 'Nested message'
685 );
686
687 mw.messages.set( 'newarticletext-lowercase',
688 newarticletextSource.replace( 'Int:Helppage', 'int:helppage' ) );
689
690 assert.htmlEqual(
691 formatParse( 'newarticletext-lowercase' ),
692 expectedNewarticletext,
693 'Link with nested message, lowercase include'
694 );
695
696 mw.messages.set( 'uses-missing-int', '{{int:doesnt-exist}}' );
697
698 assert.equal(
699 formatParse( 'uses-missing-int' ),
700 '[doesnt-exist]',
701 'int: where nested message does not exist'
702 );
703 } );
704
705 QUnit.test( 'Ns', 4, function ( assert ) {
706 mw.messages.set( 'ns-template-talk', '{{ns:Template talk}}' );
707 assert.equal(
708 formatParse( 'ns-template-talk' ),
709 'Dyskusja szablonu',
710 'ns: returns localised namespace when used with a canonical namespace name'
711 );
712
713 mw.messages.set( 'ns-10', '{{ns:10}}' );
714 assert.equal(
715 formatParse( 'ns-10' ),
716 'Szablon',
717 'ns: returns localised namespace when used with a namespace number'
718 );
719
720 mw.messages.set( 'ns-unknown', '{{ns:doesnt-exist}}' );
721 assert.equal(
722 formatParse( 'ns-unknown' ),
723 '',
724 'ns: returns empty string for unknown namespace name'
725 );
726
727 mw.messages.set( 'ns-in-a-link', '[[{{ns:template}}:Foo]]' );
728 assert.equal(
729 formatParse( 'ns-in-a-link' ),
730 '<a title="Szablon:Foo" href="/wiki/Szablon:Foo">Szablon:Foo</a>',
731 'ns: works when used inside a wikilink'
732 );
733 } );
734
735 // Tests that getMessageFunction is used for non-plain messages with curly braces or
736 // square brackets, but not otherwise.
737 QUnit.test( 'mw.Message.prototype.parser monkey-patch', 22, function ( assert ) {
738 var oldGMF, outerCalled, innerCalled;
739
740 mw.messages.set( {
741 'curly-brace': '{{int:message}}',
742 'single-square-bracket': '[https://www.mediawiki.org/ MediaWiki]',
743 'double-square-bracket': '[[Some page]]',
744 regular: 'Other message'
745 } );
746
747 oldGMF = mw.jqueryMsg.getMessageFunction;
748
749 mw.jqueryMsg.getMessageFunction = function () {
750 outerCalled = true;
751 return function () {
752 innerCalled = true;
753 };
754 };
755
756 function verifyGetMessageFunction( key, format, shouldCall ) {
757 var message;
758 outerCalled = false;
759 innerCalled = false;
760 message = mw.message( key );
761 message[ format ]();
762 assert.strictEqual( outerCalled, shouldCall, 'Outer function called for ' + key );
763 assert.strictEqual( innerCalled, shouldCall, 'Inner function called for ' + key );
764 delete mw.messages[ format ];
765 }
766
767 verifyGetMessageFunction( 'curly-brace', 'parse', true );
768 verifyGetMessageFunction( 'curly-brace', 'plain', false );
769
770 verifyGetMessageFunction( 'single-square-bracket', 'parse', true );
771 verifyGetMessageFunction( 'single-square-bracket', 'plain', false );
772
773 verifyGetMessageFunction( 'double-square-bracket', 'parse', true );
774 verifyGetMessageFunction( 'double-square-bracket', 'plain', false );
775
776 verifyGetMessageFunction( 'regular', 'parse', false );
777 verifyGetMessageFunction( 'regular', 'plain', false );
778
779 verifyGetMessageFunction( 'jquerymsg-test-pagetriage-del-talk-page-notify-summary', 'plain', false );
780 verifyGetMessageFunction( 'jquerymsg-test-categorytree-collapse-bullet', 'plain', false );
781 verifyGetMessageFunction( 'jquerymsg-test-wikieditor-toolbar-help-content-signature-result', 'plain', false );
782
783 mw.jqueryMsg.getMessageFunction = oldGMF;
784 } );
785
786 formatnumTests = [
787 {
788 lang: 'en',
789 number: 987654321.654321,
790 result: '987,654,321.654',
791 description: 'formatnum test for English, decimal separator'
792 },
793 {
794 lang: 'ar',
795 number: 987654321.654321,
796 result: '٩٨٧٬٦٥٤٬٣٢١٫٦٥٤',
797 description: 'formatnum test for Arabic, with decimal separator'
798 },
799 {
800 lang: 'ar',
801 number: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١',
802 result: 987654321,
803 integer: true,
804 description: 'formatnum test for Arabic, with decimal separator, reverse'
805 },
806 {
807 lang: 'ar',
808 number: -12.89,
809 result: '-١٢٫٨٩',
810 description: 'formatnum test for Arabic, negative number'
811 },
812 {
813 lang: 'ar',
814 number: '-١٢٫٨٩',
815 result: -12,
816 integer: true,
817 description: 'formatnum test for Arabic, negative number, reverse'
818 },
819 {
820 lang: 'nl',
821 number: 987654321.654321,
822 result: '987.654.321,654',
823 description: 'formatnum test for Nederlands, decimal separator'
824 },
825 {
826 lang: 'nl',
827 number: -12.89,
828 result: '-12,89',
829 description: 'formatnum test for Nederlands, negative number'
830 },
831 {
832 lang: 'nl',
833 number: '.89',
834 result: '0,89',
835 description: 'formatnum test for Nederlands'
836 },
837 {
838 lang: 'nl',
839 number: 'invalidnumber',
840 result: 'invalidnumber',
841 description: 'formatnum test for Nederlands, invalid number'
842 },
843 {
844 lang: 'ml',
845 number: '1000000000',
846 result: '1,00,00,00,000',
847 description: 'formatnum test for Malayalam'
848 },
849 {
850 lang: 'ml',
851 number: '-1000000000',
852 result: '-1,00,00,00,000',
853 description: 'formatnum test for Malayalam, negative number'
854 },
855 /*
856 * This will fail because of wrong pattern for ml in MW(different from CLDR)
857 {
858 lang: 'ml',
859 number: '1000000000.000',
860 result: '1,00,00,00,000.000',
861 description: 'formatnum test for Malayalam with decimal place'
862 },
863 */
864 {
865 lang: 'hi',
866 number: '123456789.123456789',
867 result: '१२,३४,५६,७८९',
868 description: 'formatnum test for Hindi'
869 },
870 {
871 lang: 'hi',
872 number: '१२,३४,५६,७८९',
873 result: '१२,३४,५६,७८९',
874 description: 'formatnum test for Hindi, Devanagari digits passed'
875 },
876 {
877 lang: 'hi',
878 number: '१२३४५६,७८९',
879 result: '123456',
880 integer: true,
881 description: 'formatnum test for Hindi, Devanagari digits passed to get integer value'
882 }
883 ];
884
885 QUnit.test( 'formatnum', formatnumTests.length, function ( assert ) {
886 mw.messages.set( 'formatnum-msg', '{{formatnum:$1}}' );
887 mw.messages.set( 'formatnum-msg-int', '{{formatnum:$1|R}}' );
888 var queue = $.map( formatnumTests, function ( test ) {
889 return function ( next, abort ) {
890 var done = assert.async();
891 getMwLanguage( test.lang )
892 .then( function ( langClass ) {
893 mw.config.set( 'wgUserLanguage', test.lang );
894 var parser = new mw.jqueryMsg.parser( { language: langClass } );
895 assert.equal(
896 parser.parse( test.integer ? 'formatnum-msg-int' : 'formatnum-msg',
897 [ test.number ] ).html(),
898 test.result,
899 test.description
900 );
901 }, function () {
902 assert.ok( false, 'Language "' + test.lang + '" failed to load' );
903 } )
904 .then( done, done )
905 .then( next, abort );
906 };
907 } );
908 process( queue );
909 } );
910
911 // HTML in wikitext
912 QUnit.test( 'HTML', 32, function ( assert ) {
913 mw.messages.set( 'jquerymsg-italics-msg', '<i>Very</i> important' );
914
915 assertBothModes( assert, [ 'jquerymsg-italics-msg' ], mw.messages.get( 'jquerymsg-italics-msg' ), 'Simple italics unchanged' );
916
917 mw.messages.set( 'jquerymsg-bold-msg', '<b>Strong</b> speaker' );
918 assertBothModes( assert, [ 'jquerymsg-bold-msg' ], mw.messages.get( 'jquerymsg-bold-msg' ), 'Simple bold unchanged' );
919
920 mw.messages.set( 'jquerymsg-bold-italics-msg', 'It is <b><i>key</i></b>' );
921 assertBothModes( assert, [ 'jquerymsg-bold-italics-msg' ], mw.messages.get( 'jquerymsg-bold-italics-msg' ), 'Bold and italics nesting order preserved' );
922
923 mw.messages.set( 'jquerymsg-italics-bold-msg', 'It is <i><b>vital</b></i>' );
924 assertBothModes( assert, [ 'jquerymsg-italics-bold-msg' ], mw.messages.get( 'jquerymsg-italics-bold-msg' ), 'Italics and bold nesting order preserved' );
925
926 mw.messages.set( 'jquerymsg-italics-with-link', 'An <i>italicized [[link|wiki-link]]</i>' );
927
928 assert.htmlEqual(
929 formatParse( 'jquerymsg-italics-with-link' ),
930 'An <i>italicized <a title="link" href="' + mw.html.escape( mw.util.getUrl( 'link' ) ) + '">wiki-link</i>',
931 'Italics with link inside in parse mode'
932 );
933
934 assert.equal(
935 formatText( 'jquerymsg-italics-with-link' ),
936 mw.messages.get( 'jquerymsg-italics-with-link' ),
937 'Italics with link unchanged in text mode'
938 );
939
940 mw.messages.set( 'jquerymsg-italics-id-class', '<i id="foo" class="bar">Foo</i>' );
941 assert.htmlEqual(
942 formatParse( 'jquerymsg-italics-id-class' ),
943 mw.messages.get( 'jquerymsg-italics-id-class' ),
944 'ID and class are allowed'
945 );
946
947 mw.messages.set( 'jquerymsg-italics-onclick', '<i onclick="alert(\'foo\')">Foo</i>' );
948 assert.htmlEqual(
949 formatParse( 'jquerymsg-italics-onclick' ),
950 '&lt;i onclick=&quot;alert(\'foo\')&quot;&gt;Foo&lt;/i&gt;',
951 'element with onclick is escaped because it is not allowed'
952 );
953
954 mw.messages.set( 'jquerymsg-script-msg', '<script >alert( "Who put this tag here?" );</script>' );
955 assert.htmlEqual(
956 formatParse( 'jquerymsg-script-msg' ),
957 '&lt;script &gt;alert( &quot;Who put this tag here?&quot; );&lt;/script&gt;',
958 'Tag outside whitelist escaped in parse mode'
959 );
960
961 assert.equal(
962 formatText( 'jquerymsg-script-msg' ),
963 mw.messages.get( 'jquerymsg-script-msg' ),
964 'Tag outside whitelist unchanged in text mode'
965 );
966
967 mw.messages.set( 'jquerymsg-script-link-msg', '<script>[[Foo|bar]]</script>' );
968 assert.htmlEqual(
969 formatParse( 'jquerymsg-script-link-msg' ),
970 '&lt;script&gt;<a title="Foo" href="' + mw.html.escape( mw.util.getUrl( 'Foo' ) ) + '">bar</a>&lt;/script&gt;',
971 'Script tag text is escaped because that element is not allowed, but link inside is still HTML'
972 );
973
974 mw.messages.set( 'jquerymsg-mismatched-html', '<i class="important">test</b>' );
975 assert.htmlEqual(
976 formatParse( 'jquerymsg-mismatched-html' ),
977 '&lt;i class=&quot;important&quot;&gt;test&lt;/b&gt;',
978 'Mismatched HTML start and end tag treated as text'
979 );
980
981 mw.messages.set( 'jquerymsg-script-and-external-link', '<script>alert( "jquerymsg-script-and-external-link test" );</script> [http://example.com <i>Foo</i> bar]' );
982 assert.htmlEqual(
983 formatParse( 'jquerymsg-script-and-external-link' ),
984 '&lt;script&gt;alert( "jquerymsg-script-and-external-link test" );&lt;/script&gt; <a href="http://example.com"><i>Foo</i> bar</a>',
985 'HTML tags in external links not interfering with escaping of other tags'
986 );
987
988 mw.messages.set( 'jquerymsg-link-script', '[http://example.com <script>alert( "jquerymsg-link-script test" );</script>]' );
989 assert.htmlEqual(
990 formatParse( 'jquerymsg-link-script' ),
991 '<a href="http://example.com">&lt;script&gt;alert( "jquerymsg-link-script test" );&lt;/script&gt;</a>',
992 'Non-whitelisted HTML tag in external link anchor treated as text'
993 );
994
995 // Intentionally not using htmlEqual for the quote tests
996 mw.messages.set( 'jquerymsg-double-quotes-preserved', '<i id="double">Double</i>' );
997 assert.equal(
998 formatParse( 'jquerymsg-double-quotes-preserved' ),
999 mw.messages.get( 'jquerymsg-double-quotes-preserved' ),
1000 'Attributes with double quotes are preserved as such'
1001 );
1002
1003 mw.messages.set( 'jquerymsg-single-quotes-normalized-to-double', '<i id=\'single\'>Single</i>' );
1004 assert.equal(
1005 formatParse( 'jquerymsg-single-quotes-normalized-to-double' ),
1006 '<i id="single">Single</i>',
1007 'Attributes with single quotes are normalized to double'
1008 );
1009
1010 mw.messages.set( 'jquerymsg-escaped-double-quotes-attribute', '<i style="font-family:&quot;Arial&quot;">Styled</i>' );
1011 assert.htmlEqual(
1012 formatParse( 'jquerymsg-escaped-double-quotes-attribute' ),
1013 mw.messages.get( 'jquerymsg-escaped-double-quotes-attribute' ),
1014 'Escaped attributes are parsed correctly'
1015 );
1016
1017 mw.messages.set( 'jquerymsg-escaped-single-quotes-attribute', '<i style=\'font-family:&#039;Arial&#039;\'>Styled</i>' );
1018 assert.htmlEqual(
1019 formatParse( 'jquerymsg-escaped-single-quotes-attribute' ),
1020 mw.messages.get( 'jquerymsg-escaped-single-quotes-attribute' ),
1021 'Escaped attributes are parsed correctly'
1022 );
1023
1024 mw.messages.set( 'jquerymsg-wikitext-contents-parsed', '<i>[http://example.com Example]</i>' );
1025 assert.htmlEqual(
1026 formatParse( 'jquerymsg-wikitext-contents-parsed' ),
1027 '<i><a href="http://example.com">Example</a></i>',
1028 'Contents of valid tag are treated as wikitext, so external link is parsed'
1029 );
1030
1031 mw.messages.set( 'jquerymsg-wikitext-contents-script', '<i><script>Script inside</script></i>' );
1032 assert.htmlEqual(
1033 formatParse( 'jquerymsg-wikitext-contents-script' ),
1034 '<i>&lt;script&gt;Script inside&lt;/script&gt;</i>',
1035 'Contents of valid tag are treated as wikitext, so invalid HTML element is treated as text'
1036 );
1037
1038 mw.messages.set( 'jquerymsg-unclosed-tag', 'Foo<tag>bar' );
1039 assert.htmlEqual(
1040 formatParse( 'jquerymsg-unclosed-tag' ),
1041 'Foo&lt;tag&gt;bar',
1042 'Nonsupported unclosed tags are escaped'
1043 );
1044
1045 mw.messages.set( 'jquerymsg-self-closing-tag', 'Foo<tag/>bar' );
1046 assert.htmlEqual(
1047 formatParse( 'jquerymsg-self-closing-tag' ),
1048 'Foo&lt;tag/&gt;bar',
1049 'Self-closing tags don\'t cause a parse error'
1050 );
1051
1052 mw.messages.set( 'jquerymsg-entities1', 'A&B' );
1053 mw.messages.set( 'jquerymsg-entities2', 'A&gt;B' );
1054 mw.messages.set( 'jquerymsg-entities3', 'A&rarr;B' );
1055 assert.htmlEqual(
1056 formatParse( 'jquerymsg-entities1' ),
1057 'A&amp;B',
1058 'Lone "&" is escaped in text'
1059 );
1060 assert.htmlEqual(
1061 formatParse( 'jquerymsg-entities2' ),
1062 'A&amp;gt;B',
1063 '"&gt;" entity is double-escaped in text' // (WHY?)
1064 );
1065 assert.htmlEqual(
1066 formatParse( 'jquerymsg-entities3' ),
1067 'A&amp;rarr;B',
1068 '"&rarr;" entity is double-escaped in text'
1069 );
1070
1071 mw.messages.set( 'jquerymsg-entities-attr1', '<i title="A&B"></i>' );
1072 mw.messages.set( 'jquerymsg-entities-attr2', '<i title="A&gt;B"></i>' );
1073 mw.messages.set( 'jquerymsg-entities-attr3', '<i title="A&rarr;B"></i>' );
1074 assert.htmlEqual(
1075 formatParse( 'jquerymsg-entities-attr1' ),
1076 '<i title="A&amp;B"></i>',
1077 'Lone "&" is escaped in attribute'
1078 );
1079 assert.htmlEqual(
1080 formatParse( 'jquerymsg-entities-attr2' ),
1081 '<i title="A&gt;B"></i>',
1082 '"&gt;" entity is not double-escaped in attribute' // (WHY?)
1083 );
1084 assert.htmlEqual(
1085 formatParse( 'jquerymsg-entities-attr3' ),
1086 '<i title="A&amp;rarr;B"></i>',
1087 '"&rarr;" entity is double-escaped in attribute'
1088 );
1089 } );
1090
1091 QUnit.test( 'Behavior in case of invalid wikitext', 3, function ( assert ) {
1092 mw.messages.set( 'invalid-wikitext', '<b>{{FAIL}}</b>' );
1093
1094 this.suppressWarnings();
1095 var logSpy = this.sandbox.spy( mw.log, 'warn' );
1096
1097 assert.equal(
1098 formatParse( 'invalid-wikitext' ),
1099 '&lt;b&gt;{{FAIL}}&lt;/b&gt;',
1100 'Invalid wikitext: \'parse\' format'
1101 );
1102
1103 assert.equal(
1104 formatText( 'invalid-wikitext' ),
1105 '<b>{{FAIL}}</b>',
1106 'Invalid wikitext: \'text\' format'
1107 );
1108
1109 assert.equal( logSpy.callCount, 2, 'mw.log.warn calls' );
1110 } );
1111
1112 QUnit.test( 'Integration', 5, function ( assert ) {
1113 var expected, logSpy, msg;
1114
1115 expected = '<b><a title="Bold" href="/wiki/Bold">Bold</a>!</b>';
1116 mw.messages.set( 'integration-test', '<b>[[Bold]]!</b>' );
1117
1118 this.suppressWarnings();
1119 logSpy = this.sandbox.spy( mw.log, 'warn' );
1120 assert.equal(
1121 window.gM( 'integration-test' ),
1122 expected,
1123 'Global function gM() works correctly'
1124 );
1125 assert.equal( logSpy.callCount, 1, 'mw.log.warn called' );
1126 this.restoreWarnings();
1127
1128 assert.equal(
1129 mw.message( 'integration-test' ).parse(),
1130 expected,
1131 'mw.message().parse() works correctly'
1132 );
1133
1134 assert.equal(
1135 $( '<span>' ).msg( 'integration-test' ).html(),
1136 expected,
1137 'jQuery plugin $.fn.msg() works correctly'
1138 );
1139
1140 mw.messages.set( 'integration-test-extlink', '[$1 Link]' );
1141 msg = mw.message(
1142 'integration-test-extlink',
1143 $( '<a>' ).attr( 'href', 'http://example.com/' )
1144 );
1145 msg.parse(); // Not a no-op
1146 assert.equal(
1147 msg.parse(),
1148 '<a href="http://example.com/">Link</a>',
1149 'Calling .parse() multiple times does not duplicate link contents'
1150 );
1151 } );
1152
1153 }( mediaWiki, jQuery ) );