mediawiki-extensions-Popups/tests/qunit/ext.popups.renderer.article.test.js
Prateek Saxena b24e39e9fc Run mw.html.escape on page extract and title
Add test for XSS attack

Bug: T69180
Change-Id: I213169bd9daed979e63f50cf3926f7196eb6181c
2014-12-01 11:23:14 -08:00

52 lines
1.1 KiB
JavaScript

( function ( $, mw ) {
QUnit.module( 'ext.popups' );
QUnit.test( 'render.article.getProcessedHtml', function ( assert ) {
QUnit.expect( 7 );
function test ( extract, title, expected ) {
assert.equal(
mw.popups.render.article.getProcessedHtml( extract, title ),
expected
);
}
test(
'Isaac Newton was born in', 'Isaac Newton',
'<b>Isaac Newton</b> was born in'
);
test(
'The C* language not to be confused with C# or C', 'C*',
'The <b>C*</b> language not to be confused with C# or C'
);
test(
'Person (was born in Location) is good', 'Person',
'<b>Person</b> is good'
);
test(
'Person (was born in Location (at Time)) is good', 'Person',
'<b>Person</b> is good'
);
test(
'Person (was born in Location (at Time) ) is good', 'Person',
'<b>Person</b> is good'
);
test(
'Brackets ) are funny ( when not used properly', 'Brackets',
'<b>Brackets</b> ) are funny ( when not used properly'
);
test(
'Epic XSS <script>alert("XSS")</script> is epic', 'Epic XSS',
'<b>Epic XSS</b> &lt;script&gt;alert&lt;/script&gt; is epic'
);
} );
} ) ( jQuery, mediaWiki );