~ubuntu-branches/ubuntu/trusty/mediawiki/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js

  • Committer: Package Import Robot
  • Author(s): Thorsten Glaser
  • Date: 2014-03-28 09:56:29 UTC
  • mfrom: (1.3.14)
  • Revision ID: package-import@ubuntu.com-20140328095629-1526y9tchdd507id
Tags: 1:1.19.14+dfsg-1
* New upstream security fix release (Closes: #742857):
  - (bug 62497) SECURITY: Add CSRF token on Special:ChangePassword
  - (bug 62467) Set a title for the context during import on the cli
* Use upstream-provided signing key bundle

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Some misc JavaScript compatibility tests, just to make sure the environments we run in are consistent */
 
2
 
 
3
module( 'mediawiki.jscompat', QUnit.newMwEnvironment() );
 
4
 
 
5
test( 'Variable with Unicode letter in name', function() {
 
6
        expect(3);
 
7
        var orig = "some token";
 
8
        var ŝablono = orig;
 
9
        deepEqual( ŝablono, orig, 'ŝablono' );
 
10
        deepEqual( \u015dablono, orig, '\\u015dablono' );
 
11
        deepEqual( \u015Dablono, orig, '\\u015Dablono' );
 
12
});
 
13
 
 
14
/*
 
15
// Not that we need this. ;)
 
16
// This fails on IE 6-8
 
17
// Works on IE 9, Firefox 6, Chrome 14
 
18
test( 'Keyword workaround: "if" as variable name using Unicode escapes', function() {
 
19
        var orig = "another token";
 
20
        \u0069\u0066 = orig;
 
21
        deepEqual( \u0069\u0066, orig, '\\u0069\\u0066' );
 
22
});
 
23
*/
 
24
 
 
25
/*
 
26
// Not that we need this. ;)
 
27
// This fails on IE 6-9
 
28
// Works on Firefox 6, Chrome 14
 
29
test( 'Keyword workaround: "if" as member variable name using Unicode escapes', function() {
 
30
        var orig = "another token";
 
31
        var foo = {};
 
32
        foo.\u0069\u0066 = orig;
 
33
        deepEqual( foo.\u0069\u0066, orig, 'foo.\\u0069\\u0066' );
 
34
});
 
35
*/
 
36
 
 
37
test( 'Stripping of single initial newline from textarea\'s literal contents (bug 12130)', function() {
 
38
        var maxn = 4;
 
39
        expect(maxn * 2);
 
40
 
 
41
        var repeat = function(str, n) {
 
42
                if (n <= 0) {
 
43
                        return '';
 
44
                } else {
 
45
                        var out = Array(n);
 
46
                        for (var i = 0; i < n; i++) {
 
47
                                out[i] = str;
 
48
                        }
 
49
                        return out.join('');
 
50
                }
 
51
        };
 
52
 
 
53
        for (var n = 0; n < maxn; n++) {
 
54
                var expected = repeat('\n', n) + 'some text';
 
55
 
 
56
                var $textarea = $('<textarea>\n' + expected + '</textarea>');
 
57
                equal($textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + (n + 1) + ')');
 
58
 
 
59
                var $textarea2 = $('<textarea>').val(expected);
 
60
                equal($textarea2.val(), expected, 'Expecting ' + n + ' newlines (from DOM set with ' + n + ')');
 
61
        }
 
62
});