1 /* Some misc JavaScript compatibility tests, just to make sure the environments we run in are consistent */
3 QUnit
.module( 'mediawiki.jscompat', QUnit
.newMwEnvironment() );
5 QUnit
.test( 'Variable with Unicode letter in name', 3, function ( assert
) {
6 var orig
= "some token";
9 assert
.deepEqual( ŝablono
, orig
, 'ŝablono' );
10 assert
.deepEqual( \u015dablono, orig
, '\\u015dablono' );
11 assert
.deepEqual( \u015Dablono, orig
, '\\u015Dablono' );
15 // Not that we need this. ;)
16 // This fails on IE 6-8
17 // Works on IE 9, Firefox 6, Chrome 14
18 QUnit.test( 'Keyword workaround: "if" as variable name using Unicode escapes', function ( assert ) {
19 var orig = "another token";
21 assert.deepEqual( \u0069\u0066, orig, '\\u0069\\u0066' );
26 // Not that we need this. ;)
27 // This fails on IE 6-9
28 // Works on Firefox 6, Chrome 14
29 QUnit.test( 'Keyword workaround: "if" as member variable name using Unicode escapes', function ( assert ) {
30 var orig = "another token";
32 foo.\u0069\u0066 = orig;
33 assert.deepEqual( foo.\u0069\u0066, orig, 'foo.\\u0069\\u0066' );
37 QUnit
.test( 'Stripping of single initial newline from textarea\'s literal contents (bug 12130)', function ( assert
) {
39 QUnit
.expect( maxn
* 2 );
41 function repeat( str
, n
) {
45 var out
= new Array(n
);
46 for ( var i
= 0; i
< n
; i
++ ) {
53 for ( var n
= 0; n
< maxn
; n
++ ) {
54 var expected
= repeat('\n', n
) + 'some text';
56 var $textarea
= $('<textarea>\n' + expected
+ '</textarea>');
57 assert
.equal( $textarea
.val(), expected
, 'Expecting ' + n
+ ' newlines (HTML contained ' + (n
+ 1) + ')' );
59 var $textarea2
= $('<textarea>').val(expected
);
60 assert
.equal( $textarea2
.val(), expected
, 'Expecting ' + n
+ ' newlines (from DOM set with ' + n
+ ')' );