2 * Some misc JavaScript compatibility tests,
3 * just to make sure the environments we run in are consistent.
6 QUnit
.module( 'mediawiki.jscompat', QUnit
.newMwEnvironment() );
8 QUnit
.test( 'Variable with Unicode letter in name', 3, function ( assert
) {
14 assert
.deepEqual( ŝablono
, orig
, 'ŝablono' );
15 assert
.deepEqual( \u015dablono, orig
, '\\u015dablono' );
16 assert
.deepEqual( \u015Dablono, orig
, '\\u015Dablono' );
20 // Not that we need this. ;)
21 // This fails on IE 6-8
22 // Works on IE 9, Firefox 6, Chrome 14
23 QUnit.test( 'Keyword workaround: "if" as variable name using Unicode escapes', function ( assert ) {
24 var orig = "another token";
26 assert.deepEqual( \u0069\u0066, orig, '\\u0069\\u0066' );
31 // Not that we need this. ;)
32 // This fails on IE 6-9
33 // Works on Firefox 6, Chrome 14
34 QUnit.test( 'Keyword workaround: "if" as member variable name using Unicode escapes', function ( assert ) {
35 var orig = "another token";
37 foo.\u0069\u0066 = orig;
38 assert.deepEqual( foo.\u0069\u0066, orig, 'foo.\\u0069\\u0066' );
42 QUnit
.test( 'Stripping of single initial newline from textarea\'s literal contents (bug 12130)', function ( assert
) {
47 QUnit
.expect( maxn
* 2 );
49 function repeat( str
, n
) {
56 return out
.join( str
);
60 for ( n
= 0; n
< maxn
; n
++ ) {
61 expected
= repeat( '\n', n
) + 'some text';
63 $textarea
= $( '<textarea>\n' + expected
+ '</textarea>' );
64 assert
.equal( $textarea
.val(), expected
, 'Expecting ' + n
+ ' newlines (HTML contained ' + ( n
+ 1 ) + ')' );
66 $textarea
= $( '<textarea>' ).val( expected
);
67 assert
.equal( $textarea
.val(), expected
, 'Expecting ' + n
+ ' newlines (from DOM set with ' + n
+ ')' );