2 var mwLanguageCache
= {}, formatText
, formatParse
, formatnumTests
, specialCharactersPageName
,
3 expectedListUsers
, expectedEntrypoints
;
5 // When the expected result is the same in both modes
6 function assertBothModes( assert
, parserArguments
, expectedResult
, assertMessage
) {
7 assert
.equal( formatText
.apply( null, parserArguments
), expectedResult
, assertMessage
+ ' when format is \'text\'' );
8 assert
.equal( formatParse
.apply( null, parserArguments
), expectedResult
, assertMessage
+ ' when format is \'parse\'' );
11 QUnit
.module( 'mediawiki.jqueryMsg', QUnit
.newMwEnvironment( {
13 this.originalMwLanguage
= mw
.language
;
15 // Messages that are reused in multiple tests
17 // The values for gender are not significant,
18 // what matters is which of the values is choosen by the parser
19 'gender-msg': '$1: {{GENDER:$2|blue|pink|green}}',
20 'gender-msg-currentuser': '{{GENDER:|blue|pink|green}}',
22 'plural-msg': 'Found $1 {{PLURAL:$1|item|items}}',
24 // Assume the grammar form grammar_case_foo is not valid in any language
25 'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
27 'formatnum-msg': '{{formatnum:$1}}',
29 'portal-url': 'Project:Community portal',
30 'see-portal-url': '{{Int:portal-url}} is an important community page.',
32 'jquerymsg-test-statistics-users': '注册[[Special:ListUsers|用户]]',
34 'jquerymsg-test-version-entrypoints-index-php': '[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
36 'external-link-replace': 'Foo [$1 bar]'
40 wgArticlePath
: '/wiki/$1'
43 specialCharactersPageName
= '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
45 expectedListUsers
= '注册<a title="Special:ListUsers" href="/wiki/Special:ListUsers">用户</a>';
47 expectedEntrypoints
= '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>';
49 formatText
= mw
.jqueryMsg
.getMessageFunction( {
53 formatParse
= mw
.jqueryMsg
.getMessageFunction( {
57 teardown: function () {
58 mw
.language
= this.originalMwLanguage
;
62 function getMwLanguage( langCode
, cb
) {
63 if ( mwLanguageCache
[langCode
] !== undefined ) {
64 mwLanguageCache
[langCode
].add( cb
);
67 mwLanguageCache
[langCode
] = $.Callbacks( 'once memory' );
68 mwLanguageCache
[langCode
].add( cb
);
70 url
: mw
.util
.wikiScript( 'load' ),
72 skin
: mw
.config
.get( 'skin' ),
74 debug
: mw
.config
.get( 'debug' ),
76 'mediawiki.language.data',
82 } ).done(function () {
83 mwLanguageCache
[langCode
].fire( mw
.language
);
84 } ).fail( function () {
85 mwLanguageCache
[langCode
].fire( false );
89 QUnit
.test( 'Replace', 9, function ( assert
) {
90 mw
.messages
.set( 'simple', 'Foo $1 baz $2' );
92 assert
.equal( formatParse( 'simple' ), 'Foo $1 baz $2', 'Replacements with no substitutes' );
93 assert
.equal( formatParse( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' );
94 assert
.equal( formatParse( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' );
96 mw
.messages
.set( 'plain-input', '<foo foo="foo">x$1y<</foo>z' );
99 formatParse( 'plain-input', 'bar' ),
100 '<foo foo="foo">xbary&lt;</foo>z',
101 'Input is not considered html'
104 mw
.messages
.set( 'plain-replace', 'Foo $1' );
107 formatParse( 'plain-replace', '<bar bar="bar">></bar>' ),
108 'Foo <bar bar="bar">&gt;</bar>',
109 'Replacement is not considered html'
112 mw
.messages
.set( 'object-replace', 'Foo $1' );
115 formatParse( 'object-replace', $( '<div class="bar">></div>' ) ),
116 'Foo <div class="bar">></div>',
117 'jQuery objects are preserved as raw html'
121 formatParse( 'object-replace', $( '<div class="bar">></div>' ).get( 0 ) ),
122 'Foo <div class="bar">></div>',
123 'HTMLElement objects are preserved as raw html'
127 formatParse( 'object-replace', $( '<div class="bar">></div>' ).toArray() ),
128 'Foo <div class="bar">></div>',
129 'HTMLElement[] arrays are preserved as raw html'
133 formatParse( 'external-link-replace', 'http://example.org/?x=y&z' ),
134 'Foo <a href="http://example.org/?x=y&z">bar</a>',
135 'Href is not double-escaped in wikilink function'
139 QUnit
.test( 'Plural', 3, function ( assert
) {
140 assert
.equal( formatParse( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' );
141 assert
.equal( formatParse( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' );
142 assert
.equal( formatParse( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' );
145 QUnit
.test( 'Gender', 15, function ( assert
) {
146 var originalGender
= mw
.user
.options
.get( 'gender' );
148 // TODO: These tests should be for mw.msg once mw.msg integrated with mw.jqueryMsg
149 // TODO: English may not be the best language for these tests. Use a language like Arabic or Russian
150 mw
.user
.options
.set( 'gender', 'male' );
152 formatParse( 'gender-msg', 'Bob', 'male' ),
154 'Masculine from string "male"'
157 formatParse( 'gender-msg', 'Bob', mw
.user
),
159 'Masculine from mw.user object'
162 formatParse( 'gender-msg-currentuser' ),
164 'Masculine for current user'
167 mw
.user
.options
.set( 'gender', 'female' );
169 formatParse( 'gender-msg', 'Alice', 'female' ),
171 'Feminine from string "female"' );
173 formatParse( 'gender-msg', 'Alice', mw
.user
),
175 'Feminine from mw.user object'
178 formatParse( 'gender-msg-currentuser' ),
180 'Feminine for current user'
183 mw
.user
.options
.set( 'gender', 'unknown' );
185 formatParse( 'gender-msg', 'Foo', mw
.user
),
187 'Neutral from mw.user object' );
189 formatParse( 'gender-msg', 'User' ),
191 'Neutral when no parameter given' );
193 formatParse( 'gender-msg', 'User', 'unknown' ),
195 'Neutral from string "unknown"'
198 formatParse( 'gender-msg-currentuser' ),
200 'Neutral for current user'
203 mw
.messages
.set( 'gender-msg-one-form', '{{GENDER:$1|User}}: $2 {{PLURAL:$2|edit|edits}}' );
206 formatParse( 'gender-msg-one-form', 'male', 10 ),
208 'Gender neutral and plural form'
211 formatParse( 'gender-msg-one-form', 'female', 1 ),
213 'Gender neutral and singular form'
216 mw
.messages
.set( 'gender-msg-lowercase', '{{gender:$1|he|she}} is awesome' );
218 formatParse( 'gender-msg-lowercase', 'male' ),
223 formatParse( 'gender-msg-lowercase', 'female' ),
228 mw
.messages
.set( 'gender-msg-wrong', '{{gender}} test' );
230 formatParse( 'gender-msg-wrong', 'female' ),
232 'Invalid syntax should result in {{gender}} simply being stripped away'
235 mw
.user
.options
.set( 'gender', originalGender
);
238 QUnit
.test( 'Grammar', 2, function ( assert
) {
239 assert
.equal( formatParse( 'grammar-msg' ), 'Przeszukaj ' + mw
.config
.get( 'wgSiteName' ), 'Grammar Test with sitename' );
241 mw
.messages
.set( 'grammar-msg-wrong-syntax', 'Przeszukaj {{GRAMMAR:grammar_case_xyz}}' );
242 assert
.equal( formatParse( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ', 'Grammar Test with wrong grammar template syntax' );
245 QUnit
.test( 'Match PHP parser', mw
.libs
.phpParserData
.tests
.length
, function ( assert
) {
246 mw
.messages
.set( mw
.libs
.phpParserData
.messages
);
247 $.each( mw
.libs
.phpParserData
.tests
, function ( i
, test
) {
249 getMwLanguage( test
.lang
, function ( langClass
) {
252 assert
.ok( false, 'Language "' + test
.lang
+ '" failed to load' );
255 mw
.config
.set( 'wgUserLanguage', test
.lang
);
256 var parser
= new mw
.jqueryMsg
.parser( { language
: langClass
} );
258 parser
.parse( test
.key
, test
.args
).html(),
266 QUnit
.test( 'Links', 6, function ( assert
) {
267 var expectedDisambiguationsText
,
268 expectedMultipleBars
,
269 expectedSpecialCharacters
;
272 The below three are all identical to or based on real messages. For disambiguations-text,
273 the bold was removed because it is not yet implemented.
277 formatParse( 'jquerymsg-test-statistics-users' ),
282 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 ' +
283 '<a title="MediaWiki:Disambiguationspage" href="/wiki/MediaWiki:Disambiguationspage">MediaWiki:Disambiguationspage</a>.';
285 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]].' );
287 formatParse( 'disambiguations-text' ),
288 expectedDisambiguationsText
,
289 'Wikilink without pipe'
293 formatParse( 'jquerymsg-test-version-entrypoints-index-php' ),
298 // Pipe trick is not supported currently, but should not parse as text either.
299 mw
.messages
.set( 'pipe-trick', '[[Tampa, Florida|]]' );
301 formatParse( 'pipe-trick' ),
302 'pipe-trick: Parse error at position 0 in input: [[Tampa, Florida|]]',
303 'Pipe trick should return error string.'
306 expectedMultipleBars
= '<a title="Main Page" href="/wiki/Main_Page">Main|Page</a>';
307 mw
.messages
.set( 'multiple-bars', '[[Main Page|Main|Page]]' );
309 formatParse( 'multiple-bars' ),
310 expectedMultipleBars
,
314 expectedSpecialCharacters
= '<a title=""Who" wants to be a millionaire & live on 'Exotic Island'?" href="/wiki/%22Who%22_wants_to_be_a_millionaire_%26_live_on_%27Exotic_Island%27%3F">"Who" wants to be a millionaire & live on 'Exotic Island'?</a>';
316 mw
.messages
.set( 'special-characters', '[[' + specialCharactersPageName
+ ']]' );
318 formatParse( 'special-characters' ),
319 expectedSpecialCharacters
,
324 // Tests that {{-transformation vs. general parsing are done as requested
325 QUnit
.test( 'Curly brace transformation', 14, function ( assert
) {
326 var oldUserLang
= mw
.config
.get( 'wgUserLanguage' );
328 assertBothModes( assert
, ['gender-msg', 'Bob', 'male'], 'Bob: blue', 'gender is resolved' );
330 assertBothModes( assert
, ['plural-msg', 5], 'Found 5 items', 'plural is resolved' );
332 assertBothModes( assert
, ['grammar-msg'], 'Przeszukaj ' + mw
.config
.get( 'wgSiteName' ), 'grammar is resolved' );
334 mw
.config
.set( 'wgUserLanguage', 'en' );
335 assertBothModes( assert
, ['formatnum-msg', '987654321.654321'], '987,654,321.654', 'formatnum is resolved' );
337 // Test non-{{ wikitext, where behavior differs
341 formatText( 'jquerymsg-test-statistics-users' ),
342 mw
.messages
.get( 'jquerymsg-test-statistics-users' ),
343 'Internal link message unchanged when format is \'text\''
346 formatParse( 'jquerymsg-test-statistics-users' ),
348 'Internal link message parsed when format is \'parse\''
353 formatText( 'jquerymsg-test-version-entrypoints-index-php' ),
354 mw
.messages
.get( 'jquerymsg-test-version-entrypoints-index-php' ),
355 'External link message unchanged when format is \'text\''
358 formatParse( 'jquerymsg-test-version-entrypoints-index-php' ),
360 'External link message processed when format is \'parse\''
363 // External link with parameter
365 formatText( 'external-link-replace', 'http://example.com' ),
366 'Foo [http://example.com bar]',
367 'External link message only substitutes parameter when format is \'text\''
370 formatParse( 'external-link-replace', 'http://example.com' ),
371 'Foo <a href="http://example.com">bar</a>',
372 'External link message processed when format is \'parse\''
375 mw
.config
.set( 'wgUserLanguage', oldUserLang
);
378 QUnit
.test( 'Int', 4, function ( assert
) {
379 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.',
380 expectedNewarticletext
,
381 helpPageTitle
= 'Help:Foobar';
383 mw
.messages
.set( 'foobar', helpPageTitle
);
385 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 ' +
386 '<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.';
388 mw
.messages
.set( 'newarticletext', newarticletextSource
);
391 formatParse( 'newarticletext' ),
392 expectedNewarticletext
,
393 'Link with nested message'
397 formatParse( 'see-portal-url' ),
398 'Project:Community portal is an important community page.',
402 mw
.messages
.set( 'newarticletext-lowercase',
403 newarticletextSource
.replace( 'Int:Helppage', 'int:helppage' ) );
406 formatParse( 'newarticletext-lowercase' ),
407 expectedNewarticletext
,
408 'Link with nested message, lowercase include'
411 mw
.messages
.set( 'uses-missing-int', '{{int:doesnt-exist}}' );
414 formatParse( 'uses-missing-int' ),
416 'int: where nested message does not exist'
420 // Tests that getMessageFunction is used for non-plain messages with curly braces or
421 // square brackets, but not otherwise.
422 QUnit
.test( 'mw.Message.prototype.parser monkey-patch', 22, function ( assert
) {
423 var oldGMF
, outerCalled
, innerCalled
;
426 'curly-brace': '{{int:message}}',
427 'single-square-bracket': '[https://www.mediawiki.org/ MediaWiki]',
428 'double-square-bracket': '[[Some page]]',
429 'regular': 'Other message'
432 oldGMF
= mw
.jqueryMsg
.getMessageFunction
;
434 mw
.jqueryMsg
.getMessageFunction = function () {
441 function verifyGetMessageFunction( key
, format
, shouldCall
) {
445 message
= mw
.message( key
);
447 assert
.strictEqual( outerCalled
, shouldCall
, 'Outer function called for ' + key
);
448 assert
.strictEqual( innerCalled
, shouldCall
, 'Inner function called for ' + key
);
451 verifyGetMessageFunction( 'curly-brace', 'parse', true );
452 verifyGetMessageFunction( 'curly-brace', 'plain', false );
454 verifyGetMessageFunction( 'single-square-bracket', 'parse', true );
455 verifyGetMessageFunction( 'single-square-bracket', 'plain', false );
457 verifyGetMessageFunction( 'double-square-bracket', 'parse', true );
458 verifyGetMessageFunction( 'double-square-bracket', 'plain', false );
460 verifyGetMessageFunction( 'regular', 'parse', false );
461 verifyGetMessageFunction( 'regular', 'plain', false );
463 verifyGetMessageFunction( 'jquerymsg-test-pagetriage-del-talk-page-notify-summary', 'plain', false );
464 verifyGetMessageFunction( 'jquerymsg-test-categorytree-collapse-bullet', 'plain', false );
465 verifyGetMessageFunction( 'jquerymsg-test-wikieditor-toolbar-help-content-signature-result', 'plain', false );
467 mw
.jqueryMsg
.getMessageFunction
= oldGMF
;
473 number
: 987654321.654321,
474 result
: '987,654,321.654',
475 description
: 'formatnum test for English, decimal seperator'
479 number
: 987654321.654321,
480 result
: '٩٨٧٬٦٥٤٬٣٢١٫٦٥٤',
481 description
: 'formatnum test for Arabic, with decimal seperator'
485 number
: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١',
488 description
: 'formatnum test for Arabic, with decimal seperator, reverse'
494 description
: 'formatnum test for Arabic, negative number'
501 description
: 'formatnum test for Arabic, negative number, reverse'
505 number
: 987654321.654321,
506 result
: '987.654.321,654',
507 description
: 'formatnum test for Nederlands, decimal seperator'
513 description
: 'formatnum test for Nederlands, negative number'
519 description
: 'formatnum test for Nederlands'
523 number
: 'invalidnumber',
524 result
: 'invalidnumber',
525 description
: 'formatnum test for Nederlands, invalid number'
529 number
: '1000000000',
530 result
: '1,00,00,00,000',
531 description
: 'formatnum test for Malayalam'
535 number
: '-1000000000',
536 result
: '-1,00,00,00,000',
537 description
: 'formatnum test for Malayalam, negative number'
540 * This will fail because of wrong pattern for ml in MW(different from CLDR)
543 number: '1000000000.000',
544 result: '1,00,00,00,000.000',
545 description: 'formatnum test for Malayalam with decimal place'
550 number
: '123456789.123456789',
551 result
: '१२,३४,५६,७८९',
552 description
: 'formatnum test for Hindi'
556 number
: '१२,३४,५६,७८९',
557 result
: '१२,३४,५६,७८९',
558 description
: 'formatnum test for Hindi, Devanagari digits passed'
562 number
: '१२३४५६,७८९',
565 description
: 'formatnum test for Hindi, Devanagari digits passed to get integer value'
569 QUnit
.test( 'formatnum', formatnumTests
.length
, function ( assert
) {
570 mw
.messages
.set( 'formatnum-msg', '{{formatnum:$1}}' );
571 mw
.messages
.set( 'formatnum-msg-int', '{{formatnum:$1|R}}' );
572 $.each( formatnumTests
, function ( i
, test
) {
574 getMwLanguage( test
.lang
, function ( langClass
) {
577 assert
.ok( false, 'Language "' + test
.lang
+ '" failed to load' );
580 mw
.messages
.set(test
.message
);
581 mw
.config
.set( 'wgUserLanguage', test
.lang
);
582 var parser
= new mw
.jqueryMsg
.parser( { language
: langClass
} );
584 parser
.parse( test
.integer
? 'formatnum-msg-int' : 'formatnum-msg',
585 [ test
.number
] ).html(),
594 QUnit
.test( 'HTML', 26, function ( assert
) {
595 mw
.messages
.set( 'jquerymsg-italics-msg', '<i>Very</i> important' );
597 assertBothModes( assert
, ['jquerymsg-italics-msg'], mw
.messages
.get( 'jquerymsg-italics-msg' ), 'Simple italics unchanged' );
599 mw
.messages
.set( 'jquerymsg-bold-msg', '<b>Strong</b> speaker' );
600 assertBothModes( assert
, ['jquerymsg-bold-msg'], mw
.messages
.get( 'jquerymsg-bold-msg' ), 'Simple bold unchanged' );
602 mw
.messages
.set( 'jquerymsg-bold-italics-msg', 'It is <b><i>key</i></b>' );
603 assertBothModes( assert
, ['jquerymsg-bold-italics-msg'], mw
.messages
.get( 'jquerymsg-bold-italics-msg' ), 'Bold and italics nesting order preserved' );
605 mw
.messages
.set( 'jquerymsg-italics-bold-msg', 'It is <i><b>vital</b></i>' );
606 assertBothModes( assert
, ['jquerymsg-italics-bold-msg'], mw
.messages
.get( 'jquerymsg-italics-bold-msg' ), 'Italics and bold nesting order preserved' );
608 mw
.messages
.set( 'jquerymsg-italics-with-link', 'An <i>italicized [[link|wiki-link]]</i>' );
611 formatParse( 'jquerymsg-italics-with-link' ),
612 'An <i>italicized <a title="link" href="' + mw
.html
.escape( mw
.util
.getUrl( 'link' ) ) + '">wiki-link</i>',
613 'Italics with link inside in parse mode'
617 formatText( 'jquerymsg-italics-with-link' ),
618 mw
.messages
.get( 'jquerymsg-italics-with-link' ),
619 'Italics with link unchanged in text mode'
622 mw
.messages
.set( 'jquerymsg-italics-id-class', '<i id="foo" class="bar">Foo</i>' );
624 formatParse( 'jquerymsg-italics-id-class' ),
625 mw
.messages
.get( 'jquerymsg-italics-id-class' ),
626 'ID and class are allowed'
629 mw
.messages
.set( 'jquerymsg-italics-onclick', '<i onclick="alert(\'foo\')">Foo</i>' );
631 formatParse( 'jquerymsg-italics-onclick' ),
632 '<i onclick="alert(\'foo\')">Foo</i>',
633 'element with onclick is escaped because it is not allowed'
636 mw
.messages
.set( 'jquerymsg-script-msg', '<script >alert( "Who put this tag here?" );</script>' );
638 formatParse( 'jquerymsg-script-msg' ),
639 '<script >alert( "Who put this tag here?" );</script>',
640 'Tag outside whitelist escaped in parse mode'
644 formatText( 'jquerymsg-script-msg' ),
645 mw
.messages
.get( 'jquerymsg-script-msg' ),
646 'Tag outside whitelist unchanged in text mode'
649 mw
.messages
.set( 'jquerymsg-script-link-msg', '<script>[[Foo|bar]]</script>' );
651 formatParse( 'jquerymsg-script-link-msg' ),
652 '<script><a title="Foo" href="' + mw
.html
.escape( mw
.util
.getUrl( 'Foo' ) ) + '">bar</a></script>',
653 'Script tag text is escaped because that element is not allowed, but link inside is still HTML'
656 mw
.messages
.set( 'jquerymsg-mismatched-html', '<i class="important">test</b>' );
658 formatParse( 'jquerymsg-mismatched-html' ),
659 '<i class="important">test</b>',
660 'Mismatched HTML start and end tag treated as text'
663 // TODO (mattflaschen, 2013-03-18): It's not a security issue, but there's no real
664 // reason the htmlEmitter span needs to be here. It's an artifact of how emitting works.
665 mw
.messages
.set( 'jquerymsg-script-and-external-link', '<script>alert( "jquerymsg-script-and-external-link test" );</script> [http://example.com <i>Foo</i> bar]' );
667 formatParse( 'jquerymsg-script-and-external-link' ),
668 '<script>alert( "jquerymsg-script-and-external-link test" );</script> <a href="http://example.com"><span class="mediaWiki_htmlEmitter"><i>Foo</i> bar</span></a>',
669 'HTML tags in external links not interfering with escaping of other tags'
672 mw
.messages
.set( 'jquerymsg-link-script', '[http://example.com <script>alert( "jquerymsg-link-script test" );</script>]' );
674 formatParse( 'jquerymsg-link-script' ),
675 '<a href="http://example.com"><span class="mediaWiki_htmlEmitter"><script>alert( "jquerymsg-link-script test" );</script></span></a>',
676 'Non-whitelisted HTML tag in external link anchor treated as text'
679 // Intentionally not using htmlEqual for the quote tests
680 mw
.messages
.set( 'jquerymsg-double-quotes-preserved', '<i id="double">Double</i>' );
682 formatParse( 'jquerymsg-double-quotes-preserved' ),
683 mw
.messages
.get( 'jquerymsg-double-quotes-preserved' ),
684 'Attributes with double quotes are preserved as such'
687 mw
.messages
.set( 'jquerymsg-single-quotes-normalized-to-double', '<i id=\'single\'>Single</i>' );
689 formatParse( 'jquerymsg-single-quotes-normalized-to-double' ),
690 '<i id="single">Single</i>',
691 'Attributes with single quotes are normalized to double'
694 mw
.messages
.set( 'jquerymsg-escaped-double-quotes-attribute', '<i style="font-family:"Arial"">Styled</i>' );
696 formatParse( 'jquerymsg-escaped-double-quotes-attribute' ),
697 mw
.messages
.get( 'jquerymsg-escaped-double-quotes-attribute' ),
698 'Escaped attributes are parsed correctly'
701 mw
.messages
.set( 'jquerymsg-escaped-single-quotes-attribute', '<i style=\'font-family:'Arial'\'>Styled</i>' );
703 formatParse( 'jquerymsg-escaped-single-quotes-attribute' ),
704 mw
.messages
.get( 'jquerymsg-escaped-single-quotes-attribute' ),
705 'Escaped attributes are parsed correctly'
709 mw
.messages
.set( 'jquerymsg-wikitext-contents-parsed', '<i>[http://example.com Example]</i>' );
711 formatParse( 'jquerymsg-wikitext-contents-parsed' ),
712 '<i><a href="http://example.com">Example</a></i>',
713 'Contents of valid tag are treated as wikitext, so external link is parsed'
716 mw
.messages
.set( 'jquerymsg-wikitext-contents-script', '<i><script>Script inside</script></i>' );
718 formatParse( 'jquerymsg-wikitext-contents-script' ),
719 '<i><span class="mediaWiki_htmlEmitter"><script>Script inside</script></span></i>',
720 'Contents of valid tag are treated as wikitext, so invalid HTML element is treated as text'
723 mw
.messages
.set( 'jquerymsg-unclosed-tag', 'Foo<tag>bar' );
725 formatParse( 'jquerymsg-unclosed-tag' ),
727 'Nonsupported unclosed tags are escaped'
730 mw
.messages
.set( 'jquerymsg-self-closing-tag', 'Foo<tag/>bar' );
732 formatParse( 'jquerymsg-self-closing-tag' ),
733 'Foo<tag/>bar',
734 'Self-closing tags don\'t cause a parse error'
738 }( mediaWiki
, jQuery
) );