Update formatting
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Fri, 15 Feb 2013 11:10:19 +0000 (12:10 +0100)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 15 Feb 2013 13:19:38 +0000 (13:19 +0000)
9 of n.

Change-Id: Ide20743a2e84ff68549286120e6cff9d9f396f54

16 files changed:
tests/qunit/data/testrunner.js
tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js
tests/qunit/suites/resources/jquery/jquery.client.test.js
tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js
tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js
tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
tests/qunit/suites/resources/jquery/jquery.textSelection.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index b751ca9..c89656d 100644 (file)
@@ -52,7 +52,7 @@
        /**
         * CompletenessTest
         */
-       // Adds toggle checkbox to header
+        // Adds toggle checkbox to header
        QUnit.config.urlConfig.push( {
                id: 'completenesstest',
                label: 'Run CompletenessTest',
@@ -92,7 +92,7 @@
        /**
         * Test environment recommended for all QUnit test modules
         */
-       // Whether to log environment changes to the console
+        // Whether to log environment changes to the console
        QUnit.config.urlConfig.push( 'mwlogenv' );
 
        /**
                }
 
                function freshMessagesCopy( custom ) {
-                       return $.extend(  /*deep=*/true, {}, liveMessages, custom );
+                       return $.extend( /*deep=*/true, {}, liveMessages, custom );
                }
 
                log = QUnit.urlParams.mwlogenv ? mw.log : function () {};
                        // Whether this one fails or not, forwards it to
                        // the 'done' (resolve) callback of the alternative promise.
                        arg.always( alt.resolve );
-               });
+               } );
 
                return $.when.apply( $, altPromises );
        };
         * initializations defined above in this file.
         */
        envExecCount = 0;
-       QUnit.module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment({
+       QUnit.module( 'mediawiki.tests.qunit.testrunner', QUnit.newMwEnvironment( {
                setup: function () {
                        envExecCount += 1;
                        this.mwHtmlLive = mw.html;
                messages: {
                        testMsg: 'Foo.'
                }
-       }) );
+       } ) );
 
        QUnit.test( 'Setup', 3, function ( assert ) {
                assert.equal( mw.html.escape( 'foo' ), 'mocked-1', 'extra setup() callback was ran.' );
 
                mw.config.set( 'testVar', 'bar' );
                mw.messages.set( 'testMsg', 'Bar.' );
-       });
+       } );
 
        QUnit.test( 'Teardown', 3, function ( assert ) {
                assert.equal( mw.html.escape( 'foo' ), 'mocked-2', 'extra setup() callback was re-ran.' );
                assert.equal( mw.config.get( 'testVar' ), 'foo', 'config object restored and re-applied after test()' );
                assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object restored and re-applied after test()' );
-       });
+       } );
 
        QUnit.module( 'mediawiki.tests.qunit.testrunner-after', QUnit.newMwEnvironment() );
 
                assert.equal( mw.html.escape( '<' ), '&lt;', 'extra teardown() callback was ran.' );
                assert.equal( mw.config.get( 'testVar' ), null, 'config object restored to live in next module()' );
                assert.equal( mw.messages.get( 'testMsg' ), null, 'messages object restored to live in next module()' );
-       });
+       } );
 
 }( jQuery, mediaWiki, QUnit ) );
index 2990de2..c21844e 100644 (file)
        // Basic sendkey-implementation
        function addChars( $input, charstr ) {
                var c, len;
+
                function x( $input, i ) {
                        // Add character to the value
                        return $input.val() + charstr.charAt( i );
                }
+
                for ( c = 0, len = charstr.length; c < len; c += 1 ) {
                        $input
                                .val( x( $input, c ) )
         * The limit should be less than 20 (the sample data's length)
         */
        function byteLimitTest( options ) {
-               var opt = $.extend({
+               var opt = $.extend( {
                        description: '',
                        $input: null,
                        sample: '',
                        hasLimit: false,
                        expected: '',
                        limit: null
-               }, options);
+               }, options );
 
                QUnit.asyncTest( opt.description, opt.hasLimit ? 3 : 2, function ( assert ) {
-               setTimeout( function () {
-                       var rawVal, fn, effectiveVal;
-
-                       opt.$input.appendTo( '#qunit-fixture' );
-
-                       // Simulate pressing keys for each of the sample characters
-                       addChars( opt.$input, opt.sample );
-
-                       rawVal = opt.$input.val();
-                       fn = opt.$input.data( 'byteLimit.callback' );
-                       effectiveVal = fn ? fn( rawVal ) : rawVal;
-
-                       if ( opt.hasLimit ) {
-                               assert.ltOrEq(
-                                       $.byteLength( effectiveVal ),
-                                       opt.limit,
-                                       'Prevent keypresses after byteLimit was reached, length never exceeded the limit'
-                               );
-                               assert.equal(
-                                       $.byteLength( rawVal ),
-                                       $.byteLength( opt.expected ),
-                                       'Not preventing keypresses too early, length has reached the expected length'
-                               );
-                               assert.equal( rawVal, opt.expected, 'New value matches the expected string' );
-
-                       } else {
-                               assert.equal(
-                                       $.byteLength( effectiveVal ),
-                                       $.byteLength( opt.expected ),
-                                       'Unlimited scenarios are not affected, expected length reached'
-                               );
-                               assert.equal( rawVal, opt.expected, 'New value matches the expected string' );
-                       }
-                       QUnit.start();
-               }, 10 );
+                       setTimeout( function () {
+                               var rawVal, fn, effectiveVal;
+
+                               opt.$input.appendTo( '#qunit-fixture' );
+
+                               // Simulate pressing keys for each of the sample characters
+                               addChars( opt.$input, opt.sample );
+
+                               rawVal = opt.$input.val();
+                               fn = opt.$input.data( 'byteLimit.callback' );
+                               effectiveVal = fn ? fn( rawVal ) : rawVal;
+
+                               if ( opt.hasLimit ) {
+                                       assert.ltOrEq(
+                                               $.byteLength( effectiveVal ),
+                                               opt.limit,
+                                               'Prevent keypresses after byteLimit was reached, length never exceeded the limit'
+                                       );
+                                       assert.equal(
+                                               $.byteLength( rawVal ),
+                                               $.byteLength( opt.expected ),
+                                               'Not preventing keypresses too early, length has reached the expected length'
+                                       );
+                                       assert.equal( rawVal, opt.expected, 'New value matches the expected string' );
+
+                               } else {
+                                       assert.equal(
+                                               $.byteLength( effectiveVal ),
+                                               $.byteLength( opt.expected ),
+                                               'Unlimited scenarios are not affected, expected length reached'
+                                       );
+                                       assert.equal( rawVal, opt.expected, 'New value matches the expected string' );
+                               }
+                               QUnit.start();
+                       }, 10 );
                } );
        }
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Plain text input',
                $input: $( '<input type="text"/>' ),
                sample: simpleSample,
                hasLimit: false,
                expected: simpleSample
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Plain text input. Calling byteLimit with no parameters and no maxlength attribute (bug 36310)',
                $input: $( '<input type="text"/>' )
                        .byteLimit(),
                sample: simpleSample,
                hasLimit: false,
                expected: simpleSample
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Limit using the maxlength attribute',
                $input: $( '<input type="text"/>' )
                        .attr( 'maxlength', '10' )
                hasLimit: true,
                limit: 10,
                expected: '1234567890'
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Limit using a custom value',
                $input: $( '<input type="text"/>' )
                        .byteLimit( 10 ),
                hasLimit: true,
                limit: 10,
                expected: '1234567890'
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Limit using a custom value, overriding maxlength attribute',
                $input: $( '<input type="text"/>' )
                        .attr( 'maxlength', '10' )
                hasLimit: true,
                limit: 15,
                expected: '123456789012345'
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Limit using a custom value (multibyte)',
                $input: $( '<input type="text"/>' )
                        .byteLimit( 14 ),
                hasLimit: true,
                limit: 14,
                expected: '1234567890' + U_20AC + '1'
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Limit using a custom value (multibyte) overlapping a byte',
                $input: $( '<input type="text"/>' )
                        .byteLimit( 12 ),
                hasLimit: true,
                limit: 12,
                expected: '1234567890' + '12'
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Pass the limit and a callback as input filter',
                $input: $( '<input type="text"/>' )
                        .byteLimit( 6, function ( val ) {
                hasLimit: true,
                limit: 6, // 'Sample' length
                expected: 'User:Sample'
-       });
+       } );
 
-       byteLimitTest({
+       byteLimitTest( {
                description: 'Limit using the maxlength attribute and pass a callback as input filter',
                $input: $( '<input type="text"/>' )
                        .attr( 'maxlength', '6' )
                hasLimit: true,
                limit: 6, // 'Sample' length
                expected: 'User:Sample'
-       });
+       } );
 
        QUnit.test( 'Confirm properties and attributes set', 4, function ( assert ) {
                var $el, $elA, $elB;
                assert.strictEqual( $el.length, 2, 'Verify that there are no other elements clashing with this test suite' );
 
                $el.byteLimit();
-       });
+       } );
 
        QUnit.test( 'Trim from insertion when limit exceeded', 2, function ( assert ) {
                var $el;
                        .val( 'azbc' ).trigger( 'change' );
 
                assert.strictEqual( $el.val(), 'abc', 'Trim from the insertion point (at 1), not the end' );
-       });
-
+       } );
 }( jQuery, mediaWiki ) );
index 44aaefd..88bbf5c 100644 (file)
                };
                $.each( uas, function () {
                        uacount++;
-               });
+               } );
                return uas;
        }() );
 
        QUnit.test( 'profile userAgent support', uacount, function ( assert ) {
                // Generate a client profile object and compare recursively
-               var uaTest = function( rawUserAgent, data ) {
+               var uaTest = function ( rawUserAgent, data ) {
                        var ret = $.client.profile( {
                                userAgent: rawUserAgent,
                                platform: data.platform
 
        QUnit.test( 'profile return validation for current user agent', 7, function ( assert ) {
                var p = $.client.profile();
+
                function unknownOrType( val, type, summary ) {
                        assert.ok( typeof val === type || val === 'unknown', summary );
                }
                unknownOrType( p.version, 'string', 'p.version is a string (or "unknown")' );
                unknownOrType( p.versionBase, 'string', 'p.versionBase is a string (or "unknown")' );
                assert.equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' );
-       });
+       } );
 
        // Example from WikiEditor
        // Make sure to use raw numbers, a string like "7.0" would fail on a
 
                assert.equal( typeof testMatch, 'boolean', 'test returns a boolean value' );
 
-       });
+       } );
 
        QUnit.test( 'User-agent matches against WikiEditor\'s compatibility map', uacount * 2, function ( assert ) {
-               var     $body = $( 'body' ),
+               var $body = $( 'body' ),
                        bodyClasses = $body.attr( 'class' );
 
                // Loop through and run tests
                                $body.removeClass( dir );
 
                                assert.equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent );
-                       });
-               });
+                       } );
+               } );
 
                // Restore body classes
                $body.attr( 'class', bodyClasses );
-       });
+       } );
 }( jQuery ) );
index 3ffcbf5..2765498 100644 (file)
@@ -2,38 +2,36 @@
        QUnit.module( 'jquery.mwExtension', QUnit.newMwEnvironment() );
 
        QUnit.test( 'String functions', function ( assert ) {
-
                assert.equal( $.trimLeft( '  foo bar  ' ), 'foo bar  ', 'trimLeft' );
                assert.equal( $.trimRight( '  foo bar  ' ), '  foo bar', 'trimRight' );
                assert.equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' );
 
                assert.equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
-                '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
+                       '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
                assert.equal( $.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ),
-                'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' );
+                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' );
                assert.equal( $.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ),
-                'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' );
+                       'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' );
                assert.equal( $.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' );
-       });
+       } );
 
        QUnit.test( 'Is functions', function ( assert ) {
-
                assert.strictEqual( $.isDomElement( document.getElementById( 'qunit-header' ) ), true,
-                'isDomElement: #qunit-header Node' );
+                       'isDomElement: #qunit-header Node' );
                assert.strictEqual( $.isDomElement( document.getElementById( 'random-name' ) ), false,
-                'isDomElement: #random-name (null)' );
+                       'isDomElement: #random-name (null)' );
                assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' ) ), false,
-                'isDomElement: getElementsByTagName Array' );
+                       'isDomElement: getElementsByTagName Array' );
                assert.strictEqual( $.isDomElement( document.getElementsByTagName( 'div' )[0] ), true,
-                'isDomElement: getElementsByTagName(..)[0] Node' );
+                       'isDomElement: getElementsByTagName(..)[0] Node' );
                assert.strictEqual( $.isDomElement( $( 'div' ) ), false,
-                'isDomElement: jQuery object' );
-               assert.strictEqual( $.isDomElement( $( 'div' ).get(0) ), true,
-                'isDomElement: jQuery object > Get node' );
+                       'isDomElement: jQuery object' );
+               assert.strictEqual( $.isDomElement( $( 'div' ).get( 0 ) ), true,
+                       'isDomElement: jQuery object > Get node' );
                assert.strictEqual( $.isDomElement( document.createElement( 'div' ) ), true,
-                'isDomElement: createElement' );
+                       'isDomElement: createElement' );
                assert.strictEqual( $.isDomElement( { foo: 1 } ), false,
-                'isDomElement: Object' );
+                       'isDomElement: Object' );
 
                assert.strictEqual( $.isEmpty( 'string' ), false, 'isEmptry: "string"' );
                assert.strictEqual( $.isEmpty( '0' ), true, 'isEmptry: "0"' );
 
                // Documented behaviour
                assert.strictEqual( $.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' );
-       });
+       } );
 
        QUnit.test( 'Comparison functions', function ( assert ) {
-
                assert.ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, 'a', [], [2, 'b'] ] ),
-                'compareArray: Two deep arrays that are excactly the same' );
+                       'compareArray: Two deep arrays that are excactly the same' );
                assert.ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' );
 
                assert.ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' );
                assert.ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' );
                assert.ok( !$.compareObject( { bar: true }, { baz: false } ),
-                'compareObject: Two different objects (false)' );
-       });
+                       'compareObject: Two different objects (false)' );
+       } );
 }( jQuery ) );
index e31fc63..1213793 100644 (file)
@@ -3,35 +3,33 @@
 
        QUnit.test( 'firstTabIndex', 2, function ( assert ) {
                var html, $testA, $testB;
-               html =
-       '<form>' +
-               '<input tabindex="7" />' +
-               '<input tabindex="9" />' +
-               '<textarea tabindex="2">Foobar</textarea>' +
-               '<textarea tabindex="5">Foobar</textarea>' +
-       '</form>';
+               html = '<form>' +
+                       '<input tabindex="7" />' +
+                       '<input tabindex="9" />' +
+                       '<textarea tabindex="2">Foobar</textarea>' +
+                       '<textarea tabindex="5">Foobar</textarea>' +
+                       '</form>';
 
                $testA = $( '<div>' ).html( html ).appendTo( '#qunit-fixture' );
                assert.strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
 
                $testB = $( '<div>' );
                assert.strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
-       });
+       } );
 
        QUnit.test( 'lastTabIndex', 2, function ( assert ) {
                var html, $testA, $testB;
-               html =
-       '<form>' +
-               '<input tabindex="7" />' +
-               '<input tabindex="9" />' +
-               '<textarea tabindex="2">Foobar</textarea>' +
-               '<textarea tabindex="5">Foobar</textarea>' +
-       '</form>';
+               html = '<form>' +
+                       '<input tabindex="7" />' +
+                       '<input tabindex="9" />' +
+                       '<textarea tabindex="2">Foobar</textarea>' +
+                       '<textarea tabindex="5">Foobar</textarea>' +
+                       '</form>';
 
                $testA = $( '<div>' ).html( html ).appendTo( '#qunit-fixture' );
                assert.strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
 
                $testB = $( '<div>' );
                assert.strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
-       });
+       } );
 }( jQuery ) );
index b8d816e..deff5b0 100644 (file)
@@ -8,7 +8,7 @@
                wgContentLanguage: 'en'
        };
 
-       QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment({ config: config }) );
+       QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( { config: config } ) );
 
        /**
         * Create an HTML table from an array of row arrays containing text strings.
@@ -18,7 +18,7 @@
         * @param {String[][]} data
         * @return jQuery
         */
-       function tableCreate(  header, data ) {
+       function tableCreate( header, data ) {
                var i,
                        $table = $( '<table class="sortable"><thead></thead><tbody></tbody></table>' ),
                        $thead = $table.find( 'thead' ),
@@ -28,7 +28,7 @@
                $.each( header, function ( i, str ) {
                        var $th = $( '<th>' );
                        $th.text( str ).appendTo( $tr );
-               });
+               } );
                $tr.appendTo( $thead );
 
                for ( i = 0; i < data.length; i++ ) {
@@ -37,7 +37,7 @@
                        $.each( data[i], function ( j, str ) {
                                var $td = $( '<td>' );
                                $td.text( str ).appendTo( $tr );
-                       });
+                       } );
                        $tr.appendTo( $tbody );
                }
                return $table;
        function tableExtract( $table ) {
                var data = [];
 
-               $table.find( 'tbody' ).find( 'tr' ).each( function( i, tr ) {
+               $table.find( 'tbody' ).find( 'tr' ).each( function ( i, tr ) {
                        var row = [];
-                       $( tr ).find( 'td,th' ).each( function( i, td ) {
+                       $( tr ).find( 'td,th' ).each( function ( i, td ) {
                                row.push( $( td ).text() );
-                       });
+                       } );
                        data.push( row );
-               });
+               } );
                return data;
        }
 
                        // to asynchronous, we'll need a timeout or a callback here.
                        var extracted = tableExtract( $table );
                        assert.deepEqual( extracted, expected, msg );
-               });
+               } );
        }
 
-       function reversed(arr) {
+       function reversed( arr ) {
                // Clone array
-               var arr2 = arr.slice(0);
+               var arr2 = arr.slice( 0 );
 
                arr2.reverse();
 
        }
 
        // Sample data set using planets named and their radius
-       var header  = [ 'Planet' , 'Radius (km)'],
+       var header = [ 'Planet' , 'Radius (km)'],
                mercury = [ 'Mercury', '2439.7' ],
-               venus   = [ 'Venus'  , '6051.8' ],
-               earth   = [ 'Earth'  , '6371.0' ],
-               mars    = [ 'Mars'   , '3390.0' ],
-               jupiter = [ 'Jupiter',  '69911' ],
-               saturn  = [ 'Saturn' ,  '58232' ];
+               venus = [ 'Venus'  , '6051.8' ],
+               earth = [ 'Earth'  , '6371.0' ],
+               mars = [ 'Mars'   , '3390.0' ],
+               jupiter = [ 'Jupiter', '69911' ],
+               saturn = [ 'Saturn' , '58232' ];
 
        // Initial data set
-       var planets         = [mercury, venus, earth, mars, jupiter, saturn];
-       var ascendingName   = [earth, jupiter, mars, mercury, saturn, venus];
+       var planets = [mercury, venus, earth, mars, jupiter, saturn];
+       var ascendingName = [earth, jupiter, mars, mercury, saturn, venus];
        var ascendingRadius = [mercury, mars, venus, earth, saturn, jupiter];
 
        tableTest(
                planets,
                ascendingName,
                function ( $table ) {
-                       $table.tablesorter( { sortList: [ { 0: 'asc' } ] } );
+                       $table.tablesorter( { sortList: [
+                               { 0: 'asc' }
+                       ] } );
                }
        );
        tableTest(
                'Basic planet table: sorting initially - descending by radius',
                header,
                planets,
-               reversed(ascendingRadius),
+               reversed( ascendingRadius ),
                function ( $table ) {
-                       $table.tablesorter( { sortList: [ { 1: 'desc' } ] } );
+                       $table.tablesorter( { sortList: [
+                               { 1: 'desc' }
+                       ] } );
                }
        );
        tableTest(
                'Basic planet table: descending by name',
                header,
                planets,
-               reversed(ascendingName),
+               reversed( ascendingName ),
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click().click();
                'Basic planet table: descending radius',
                header,
                planets,
-               reversed(ascendingRadius),
+               reversed( ascendingRadius ),
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(1)' ).click().click();
                asc,
                function ( $table ) {
                        $table.tablesorter(
-                               { sortList: [ { 0: 'asc' }, { 1: 'asc' } ] }
+                               { sortList: [
+                                       { 0: 'asc' },
+                                       { 1: 'asc' }
+                               ] }
                        );
                }
        );
                function ( $table ) {
                        $table.tablesorter();
                        $table.data( 'tablesorter' ).sort(
-                               [ { 0: 'desc' }, { 1: 'asc' } ]
+                               [
+                                       { 0: 'desc' },
+                                       { 1: 'asc' }
+                               ]
                        );
                }
        );
                asc,
                function ( $table ) {
                        $table.tablesorter(
-                               { sortList: [ { 0: 'asc' }, { 1: 'asc' } ] }
+                               { sortList: [
+                                       { 0: 'asc' },
+                                       { 1: 'asc' }
+                               ] }
                        );
                        $table.data( 'tablesorter' ).sort(
-                               [ { 0: 'desc' }, { 1: 'asc' } ]
+                               [
+                                       { 0: 'desc' },
+                                       { 1: 'asc' }
+                               ]
                        );
                        $table.data( 'tablesorter' ).sort();
                }
        QUnit.test( 'Reset sorting making table appear unsorted', 3, function ( assert ) {
                var $table = tableCreate( header, initial );
                $table.tablesorter(
-                       { sortList: [ { 0: 'desc' }, { 1: 'asc' } ] }
+                       { sortList: [
+                               { 0: 'desc' },
+                               { 1: 'asc' }
+                       ] }
                );
                $table.data( 'tablesorter' ).sort( [] );
 
        tableTest(
                'Bug 28775: German-style (dmy) short numeric dates',
                ['Date'],
-               [ // German-style dates are day-month-year
+               [
+                       // German-style dates are day-month-year
                        ['11.11.2011'],
                        ['01.11.2011'],
                        ['02.10.2011'],
                        ['03.08.2011'],
                        ['09.11.2011']
                ],
-               [ // Sorted by ascending date
+               [
+                       // Sorted by ascending date
                        ['03.08.2011'],
                        ['02.10.2011'],
                        ['01.11.2011'],
        tableTest(
                'Bug 28775: American-style (mdy) short numeric dates',
                ['Date'],
-               [ // American-style dates are month-day-year
+               [
+                       // American-style dates are month-day-year
                        ['11.11.2011'],
                        ['01.11.2011'],
                        ['02.10.2011'],
                        ['03.08.2011'],
                        ['09.11.2011']
                ],
-               [ // Sorted by ascending date
+               [
+                       // Sorted by ascending date
                        ['01.11.2011'],
                        ['02.10.2011'],
                        ['03.08.2011'],
                'Bug 17141: IPv4 address sorting (reverse)',
                ['IP'],
                ipv4,
-               reversed(ipv4Sorted),
+               reversed( ipv4Sorted ),
                function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click().click();
                                'ä': 'ae',
                                'ö': 'oe',
                                'ß': 'ss',
-                               'ü':'ue'
+                               'ü': 'ue'
                        } );
 
                        $table.tablesorter();
                        3,
                        'Rowspan not exploded'
                );
-       });
+       } );
 
-       var planetsRowspan = [ [ 'Earth', '6051.8' ], jupiter, [ 'Mars', '6051.8' ], mercury, saturn, venus ];
+       var planetsRowspan = [
+               [ 'Earth', '6051.8' ],
+               jupiter,
+               [ 'Mars', '6051.8' ],
+               mercury,
+               saturn,
+               venus
+       ];
        var planetsRowspanII = [ jupiter, mercury, saturn, venus, [ 'Venus', '6371.0' ], [ 'Venus', '3390.0' ] ];
 
        tableTest(
                        //   This covers the removed cell in the 4th and 5th row.
                        $table.find( 'tr:eq(2) td:eq(1)' ).prop( 'rowspan', '3' );
 
-                       $table.tablesorter( { sortList: [ { 0: 'asc' } ] } );
+                       $table.tablesorter( { sortList: [
+                               { 0: 'asc' }
+                       ] } );
                }
        );
        tableTest(
                }
        );
 
-       var ascendingNameLegacy = ascendingName.slice(0);
+       var ascendingNameLegacy = ascendingName.slice( 0 );
        ascendingNameLegacy[4] = ascendingNameLegacy[5];
        ascendingNameLegacy.pop();
 
                header,
                planets,
                ascendingNameLegacy,
-               function( $table ) {
+               function ( $table ) {
                        $table.find( 'tr:last' ).addClass( 'sortbottom' );
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click();
                var $table;
                $table = $(
                        '<table class="sortable">' +
-                       '<caption>CAPTION</caption>' +
-                       '<tr><th>THEAD</th></tr>' +
-                       '<tr><td>1</td></tr>' +
-                       '<tr class="sortbottom"><td>text</td></tr>' +
-                       '</table>'
+                               '<caption>CAPTION</caption>' +
+                               '<tr><th>THEAD</th></tr>' +
+                               '<tr><td>1</td></tr>' +
+                               '<tr class="sortbottom"><td>text</td></tr>' +
+                               '</table>'
                );
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
                var $table;
                $table = $(
                        '<table class="sortable">' +
-                       '<caption>CAPTION</caption>' +
-                       '<tr><th>THEAD</th></tr>' +
-                       '<tr><td>A</td></tr>' +
-                       '<tr><td>B</td></tr>' +
-                       '<tr class="sortbottom"><td>TFOOT</td></tr>' +
-                       '</table>'
-                       );
+                               '<caption>CAPTION</caption>' +
+                               '<tr><th>THEAD</th></tr>' +
+                               '<tr><td>A</td></tr>' +
+                               '<tr><td>B</td></tr>' +
+                               '<tr class="sortbottom"><td>TFOOT</td></tr>' +
+                               '</table>'
+               );
                $table.tablesorter();
 
                assert.equal(
-                       $table.children( ).get( 0 ).nodeName,
+                       $table.children().get( 0 ).nodeName,
                        'CAPTION',
                        'First element after <thead> must be <caption> (bug 32047)'
                );
-       });
+       } );
 
        QUnit.test( 'data-sort-value attribute, when available, should override sorting position', function ( assert ) {
                var $table, data;
                                '<tr><td data-sort-value="Bananna">Ferret</td></tr>' +
                                '<tr><td data-sort-value="Drupe">Elephant</td></tr>' +
                                '<tr><td data-sort-value="Cherry">Dolphin</td></tr>' +
-                       '</tbody></table>'
+                               '</tbody></table>'
                );
                $table.tablesorter().find( '.headerSort:eq(0)' ).click();
 
                data = [];
-               $table.find( 'tbody > tr' ).each( function( i, tr ) {
-                       $( tr ).find( 'td' ).each( function( i, td ) {
+               $table.find( 'tbody > tr' ).each( function ( i, tr ) {
+                       $( tr ).find( 'td' ).each( function ( i, td ) {
                                data.push( {
                                        data: $( td ).data( 'sortValue' ),
                                        text: $( td ).text()
                                } );
-                       });
-               });
+                       } );
+               } );
 
                assert.deepEqual( data, [
                        {
                                data: 'Apple',
                                text: 'Bird'
-                       }, {
+                       },
+                       {
                                data: 'Bananna',
                                text: 'Ferret'
-                       }, {
+                       },
+                       {
                                data: undefined,
                                text: 'Cheetah'
-                       }, {
+                       },
+                       {
                                data: 'Cherry',
                                text: 'Dolphin'
-                       }, {
+                       },
+                       {
                                data: 'Drupe',
                                text: 'Elephant'
                        }
                                '<tr><td>B</td></tr>' +
                                '<tr><td>G</td></tr>' +
                                '<tr><td data-sort-value="F">C</td></tr>' +
-                       '</tbody></table>'
+                               '</tbody></table>'
                );
                $table.tablesorter().find( '.headerSort:eq(0)' ).click();
 
                                        data: $( td ).data( 'sortValue' ),
                                        text: $( td ).text()
                                } );
-                       });
-               });
+                       } );
+               } );
 
                assert.deepEqual( data, [
                        {
                                data: undefined,
                                text: 'B'
-                       }, {
+                       },
+                       {
                                data: undefined,
                                text: 'D'
-                       }, {
+                       },
+                       {
                                data: 'E',
                                text: 'A'
-                       }, {
+                       },
+                       {
                                data: 'F',
                                text: 'C'
-                       }, {
+                       },
+                       {
                                data: undefined,
                                text: 'G'
                        }
                                '<tr><td>B</td></tr>' +
                                '<tr><td data-sort-value="2">G</td></tr>' +
                                '<tr><td>C</td></tr>' +
-                       '</tbody></table>'
+                               '</tbody></table>'
                );
                // initialize table sorter and sort once
                $table
                $table.find( '.headerSort:eq(0)' ).click();
 
                data = [];
-               $table.find( 'tbody > tr' ).each( function( i, tr ) {
-                       $( tr ).find( 'td' ).each( function( i, td ) {
+               $table.find( 'tbody > tr' ).each( function ( i, tr ) {
+                       $( tr ).find( 'td' ).each( function ( i, td ) {
                                data.push( {
                                        data: $( td ).data( 'sortValue' ),
                                        text: $( td ).text()
                                } );
-                       });
-               });
+                       } );
+               } );
 
                assert.deepEqual( data, [
                        {
                                data: 1,
                                text: 'B'
-                       }, {
+                       },
+                       {
                                data: 2,
                                text: 'G'
-                       }, {
+                       },
+                       {
                                data: 3,
                                text: 'A'
-                       }, {
+                       },
+                       {
                                data: undefined,
                                text: 'C'
-                       }, {
+                       },
+                       {
                                data: undefined,
                                text: 'D'
                        }
                ], 'Order matches expected order, using the current sortValue in $.data()' );
 
-       });
+       } );
 
        var numbers = [
                [ '12'    ],
 
        tableTest( 'bug 8115: sort numbers with commas (ascending)',
                ['Numbers'], numbers, numbersAsc,
-               function( $table ) {
+               function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click();
                }
        );
 
        tableTest( 'bug 8115: sort numbers with commas (descending)',
-               ['Numbers'], numbers, reversed(numbersAsc),
-               function( $table ) {
+               ['Numbers'], numbers, reversed( numbersAsc ),
+               function ( $table ) {
                        $table.tablesorter();
                        $table.find( '.headerSort:eq(0)' ).click().click();
                }
                var $table;
                $table = $(
                        '<table class="sortable" id="mw-bug-32888">' +
-                       '<tr><th>header<table id="mw-bug-32888-2">'+
+                               '<tr><th>header<table id="mw-bug-32888-2">' +
                                '<tr><th>1</th><th>2</th></tr>' +
-                       '</table></th></tr>' +
-                       '<tr><td>A</td></tr>' +
-                       '<tr><td>B</td></tr>' +
-                       '</table>'
-                       );
+                               '</table></th></tr>' +
+                               '<tr><td>A</td></tr>' +
+                               '<tr><td>B</td></tr>' +
+                               '</table>'
+               );
                $table.tablesorter();
 
                assert.equal(
-                       $table.find('> thead:eq(0) > tr > th.headerSort').length,
+                       $table.find( '> thead:eq(0) > tr > th.headerSort' ).length,
                        1,
                        'Child tables inside a headercell should not interfere with sortable headers (bug 32888)'
                );
                assert.equal(
-                       $( '#mw-bug-32888-2' ).find('th.headerSort').length,
+                       $( '#mw-bug-32888-2' ).find( 'th.headerSort' ).length,
                        0,
                        'The headers of child tables inside a headercell should not be sortable themselves (bug 32888)'
                );
-       });
+       } );
 
 
        var correctDateSorting1 = [
                }
        );
 
-QUnit.test( 'Sorting images using alt text', function ( assert ) {
-       var $table = $(
-               '<table class="sortable">' +
-               '<tr><th>THEAD</th></tr>' +
-               '<tr><td><img alt="2"/></td></tr>' +
-               '<tr><td>1</td></tr>' +
-               '</table>'
-       );
-       $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+       QUnit.test( 'Sorting images using alt text', function ( assert ) {
+               var $table = $(
+                       '<table class="sortable">' +
+                               '<tr><th>THEAD</th></tr>' +
+                               '<tr><td><img alt="2"/></td></tr>' +
+                               '<tr><td>1</td></tr>' +
+                               '</table>'
+               );
+               $table.tablesorter().find( '.headerSort:eq(0)' ).click();
 
-       assert.equal(
-               $table.find( 'td' ).first().text(),
-               '1',
-               'Applied correct sorting order'
-       );
-} );
-
-QUnit.test( 'Sorting images using alt text (complex)', function ( assert ) {
-       var $table = $(
-               '<table class="sortable">' +
-               '<tr><th>THEAD</th></tr>' +
-               '<tr><td><img alt="D" />A</td></tr>' +
-               '<tr><td>CC</td></tr>' +
-               '<tr><td><a><img alt="A" /></a>F</tr>' +
-               '<tr><td><img alt="A" /><strong>E</strong></tr>' +
-               '<tr><td><strong><img alt="A" />D</strong></tr>' +
-               '<tr><td><img alt="A" />C</tr>' +
-               '</table>'
-       );
-       $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+               assert.equal(
+                       $table.find( 'td' ).first().text(),
+                       '1',
+                       'Applied correct sorting order'
+               );
+       } );
 
-       assert.equal(
-               $table.find( 'td' ).text(),
-               'CDEFCCA',
-               'Applied correct sorting order'
-       );
-} );
-
-QUnit.test( 'Sorting images using alt text (with format autodetection)', function ( assert ) {
-       var $table = $(
-               '<table class="sortable">' +
-               '<tr><th>THEAD</th></tr>' +
-               '<tr><td><img alt="1" />7</td></tr>' +
-               '<tr><td>1<img alt="6" /></td></tr>' +
-               '<tr><td>5</td></tr>' +
-               '<tr><td>4</td></tr>' +
-               '</table>'
-       );
-       $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+       QUnit.test( 'Sorting images using alt text (complex)', function ( assert ) {
+               var $table = $(
+                       '<table class="sortable">' +
+                               '<tr><th>THEAD</th></tr>' +
+                               '<tr><td><img alt="D" />A</td></tr>' +
+                               '<tr><td>CC</td></tr>' +
+                               '<tr><td><a><img alt="A" /></a>F</tr>' +
+                               '<tr><td><img alt="A" /><strong>E</strong></tr>' +
+                               '<tr><td><strong><img alt="A" />D</strong></tr>' +
+                               '<tr><td><img alt="A" />C</tr>' +
+                               '</table>'
+               );
+               $table.tablesorter().find( '.headerSort:eq(0)' ).click();
 
-       assert.equal(
-               $table.find( 'td' ).text(),
-               '4517',
-               'Applied correct sorting order'
-       );
-} );
+               assert.equal(
+                       $table.find( 'td' ).text(),
+                       'CDEFCCA',
+                       'Applied correct sorting order'
+               );
+       } );
 
+       QUnit.test( 'Sorting images using alt text (with format autodetection)', function ( assert ) {
+               var $table = $(
+                       '<table class="sortable">' +
+                               '<tr><th>THEAD</th></tr>' +
+                               '<tr><td><img alt="1" />7</td></tr>' +
+                               '<tr><td>1<img alt="6" /></td></tr>' +
+                               '<tr><td>5</td></tr>' +
+                               '<tr><td>4</td></tr>' +
+                               '</table>'
+               );
+               $table.tablesorter().find( '.headerSort:eq(0)' ).click();
+
+               assert.equal(
+                       $table.find( 'td' ).text(),
+                       '4517',
+                       'Applied correct sorting order'
+               );
+       } );
 }( jQuery, mediaWiki ) );
index 1795b95..ce03b69 100644 (file)
         *   params {object} add'l parameters for $().textSelection( 'encapsulateText' )
         */
        function encapsulateTest( options ) {
-               var opt = $.extend({
+               var opt = $.extend( {
                        description: '',
                        before: {},
                        after: {},
                        replace: {}
-               }, options);
+               }, options );
 
-               opt.before = $.extend({
+               opt.before = $.extend( {
                        text: '',
                        start: 0,
                        end: 0
-               }, opt.before);
-               opt.after = $.extend({
+               }, opt.before );
+               opt.after = $.extend( {
                        text: '',
                        selected: null
-               }, opt.after);
+               }, opt.after );
 
                QUnit.test( opt.description, function ( assert ) {
                        /*jshint onevar: false */
                        //$textarea.textSelection( 'setContents', opt.before.text); // this method is actually missing atm...
                        $textarea.val( opt.before.text ); // won't work with the WikiEditor iframe?
 
-                       var     start = opt.before.start,
+                       var start = opt.before.start,
                                end = opt.before.end;
                        if ( window.opera ) {
                                // Compensate for Opera's craziness converting \n to \r\n and counting that as two chars
-                               var     newLinesBefore = opt.before.text.substring( 0, start ).split( '\n' ).length - 1,
+                               var newLinesBefore = opt.before.text.substring( 0, start ).split( '\n' ).length - 1,
                                        newLinesInside = opt.before.text.substring( start, end ).split( '\n' ).length - 1;
                                start += newLinesBefore;
                                end += newLinesBefore + newLinesInside;
@@ -98,7 +98,7 @@
                        splitlines: true
                };
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'Adding sig to end of text',
                before: {
                        text: 'Wikilove dude! ',
                        selected: ''
                },
                replace: sig
-       });
+       } );
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'Adding bold to empty',
                before: {
                        text: '',
                        selected: 'Bold text' // selected because it's the default
                },
                replace: bold
-       });
+       } );
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'Adding bold to existing text',
                before: {
                        text: 'Now is the time for all good men to come to the aid of their country',
                        selected: '' // empty because it's not the default'
                },
                replace: bold
-       });
+       } );
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'ownline option: adding new h2',
                before: {
-                       text:'Before\nAfter',
+                       text: 'Before\nAfter',
                        start: 7,
                        end: 7
                },
                        selected: 'Heading 2'
                },
                replace: h2
-       });
+       } );
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'ownline option: turn a whole line into new h2',
                before: {
-                       text:'Before\nMy heading\nAfter',
+                       text: 'Before\nMy heading\nAfter',
                        start: 7,
                        end: 17
                },
                        selected: ''
                },
                replace: h2
-       });
+       } );
 
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'ownline option: turn a partial line into new h2',
                before: {
-                       text:'BeforeMy headingAfter',
+                       text: 'BeforeMy headingAfter',
                        start: 6,
                        end: 16
                },
                        selected: ''
                },
                replace: h2
-       });
+       } );
 
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'splitlines option: no selection, insert new list item',
                before: {
                        text: 'Before\nAfter',
                        text: 'Before\n* Bulleted list item\nAfter'
                },
                replace: ulist
-       });
+       } );
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'splitlines option: single partial line selection, insert new list item',
                before: {
                        text: 'BeforeMy List ItemAfter',
                        text: 'Before\n* My List Item\nAfter'
                },
                replace: ulist
-       });
+       } );
 
-       encapsulateTest({
+       encapsulateTest( {
                description: 'splitlines option: multiple lines',
                before: {
                        text: 'Before\nFirst\nSecond\nThird\nAfter',
                        text: 'Before\n* First\n* Second\n* Third\nAfter'
                },
                replace: ulist
-       });
+       } );
 
 
        function caretTest( options ) {
                        $( '#qunit-fixture' ).append( $textarea );
 
                        if ( options.mode === 'set' ) {
-                               $textarea.textSelection('setSelection', {
+                               $textarea.textSelection( 'setSelection', {
                                        start: options.start,
                                        end: options.end
-                               });
+                               } );
                        }
 
                        function among( actual, expected, message ) {
                                if ( $.isArray( expected ) ) {
-                                       assert.ok( $.inArray( actual, expected ) !== -1 , message + ' (got ' + actual + '; expected one of ' + expected.join(', ') + ')' );
+                                       assert.ok( $.inArray( actual, expected ) !== -1, message + ' (got ' + actual + '; expected one of ' + expected.join( ', ' ) + ')' );
                                } else {
                                        assert.equal( actual, expected, message );
                                }
                        }
 
-                       pos = $textarea.textSelection( 'getCaretPosition', { startAndEnd: true });
-                       among(pos[0], options.start, 'Caret start should be where we set it.');
-                       among(pos[1], options.end, 'Caret end should be where we set it.');
-               });
+                       pos = $textarea.textSelection( 'getCaretPosition', { startAndEnd: true } );
+                       among( pos[0], options.start, 'Caret start should be where we set it.' );
+                       among( pos[1], options.end, 'Caret end should be where we set it.' );
+               } );
        }
 
        caretSample = 'Some big text that we like to work with. Nothing fancy... you know what I mean?';
 
        /*
-       // @broken: Disabled per bug 34820
-       caretTest({
-               description: 'getCaretPosition with original/empty selection - bug 31847 with IE 6/7/8',
-               text: caretSample,
-               start: [0, caretSample.length], // Opera and Firefox (prior to FF 6.0) default caret to the end of the box (caretSample.length)
-               end: [0, caretSample.length], // Other browsers default it to the beginning (0), so check both.
-               mode: 'get'
-       });
-       */
+        // @broken: Disabled per bug 34820
+        caretTest({
+        description: 'getCaretPosition with original/empty selection - bug 31847 with IE 6/7/8',
+        text: caretSample,
+        start: [0, caretSample.length], // Opera and Firefox (prior to FF 6.0) default caret to the end of the box (caretSample.length)
+        end: [0, caretSample.length], // Other browsers default it to the beginning (0), so check both.
+        mode: 'get'
+        });
+        */
 
-       caretTest({
+       caretTest( {
                description: 'set/getCaretPosition with forced empty selection',
                text: caretSample,
                start: 7,
                end: 7,
                mode: 'set'
-       });
+       } );
 
-       caretTest({
+       caretTest( {
                description: 'set/getCaretPosition with small selection',
                text: caretSample,
                start: 6,
                end: 11,
                mode: 'set'
-       });
+       } );
 }( jQuery ) );
index 50bbfd7..9eda75c 100644 (file)
                d1 = api.get( {} )
                        .done( function ( data ) {
                                assert.deepEqual( data, [], 'If request succeeds without errors, resolve deferred' );
-                       });
+                       } );
 
-               d2 = api.get({
-                               action: 'doesntexist'
-                       })
+               d2 = api.get( {
+                       action: 'doesntexist'
+               )
                        .fail( function ( errorCode ) {
                                assert.equal( errorCode, 'unknown_action', 'API error (e.g. "unknown_action") should reject the deferred' );
-                       });
+                       } );
 
                d3 = api.post( {} )
                        .done( function ( data ) {
                                assert.deepEqual( data, [], 'Simple POST request' );
-                       });
+                       } );
 
                // After all are completed, continue the test suite.
                QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
                        QUnit.start();
-               });
-       });
+               } );
+       } );
 
        QUnit.asyncTest( 'Deprecated callback methods', function ( assert ) {
                var api, d1, d2, d3;
 
                d1 = api.get( {}, function () {
                        assert.ok( true, 'Function argument treated as success callback.' );
-               });
+               } );
 
                d2 = api.get( {}, {
                        ok: function () {
                                assert.ok( true, '"ok" property treated as success callback.' );
                        }
-               });
+               } );
 
-               d3 = api.get({
-                               action: 'doesntexist'
-                       }, {
+               d3 = api.get( {
+                       action: 'doesntexist'
+               }, {
                        err: function () {
                                assert.ok( true, '"err" property treated as error callback.' );
                        }
-               });
+               } );
 
                QUnit.whenPromisesComplete( d1, d2, d3 ).always( function () {
                        QUnit.start();
-               });
-       });
+               } );
+       } );
 }( mediaWiki ) );
index d7b0cb7..9389651 100644 (file)
@@ -7,23 +7,21 @@
                var selectHtml, $env, $options;
 
                // from Special:Recentchanges
-               selectHtml =
-               '<select id="namespace" name="namespace" class="namespaceselector">'
-               + '<option value="" selected="selected">all</option>'
-               + '<option value="0">(Main)</option>'
-               + '<option value="1">Talk</option>'
-               + '<option value="2">User</option>'
-               + '<option value="3">User talk</option>'
-               + '<option value="4">ProjectName</option>'
-               + '<option value="5">ProjectName talk</option>'
-               + '</select>'
-               + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
-               + '<label for="nsinvert" title="no title">Invert selection</label>'
-               + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
-               + '<label for="nsassociated" title="no title">Associated namespace</label>'
-               + '<input type="submit" value="Go" />'
-               + '<input type="hidden" value="Special:RecentChanges" name="title" />'
-               ;
+               selectHtml = '<select id="namespace" name="namespace" class="namespaceselector">'
+                       + '<option value="" selected="selected">all</option>'
+                       + '<option value="0">(Main)</option>'
+                       + '<option value="1">Talk</option>'
+                       + '<option value="2">User</option>'
+                       + '<option value="3">User talk</option>'
+                       + '<option value="4">ProjectName</option>'
+                       + '<option value="5">ProjectName talk</option>'
+                       + '</select>'
+                       + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
+                       + '<label for="nsinvert" title="no title">Invert selection</label>'
+                       + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
+                       + '<label for="nsassociated" title="no title">Associated namespace</label>'
+                       + '<input type="submit" value="Go" />'
+                       + '<input type="hidden" value="Special:RecentChanges" name="title" />';
 
                $env = $( '<div>' ).html( selectHtml ).appendTo( 'body' );
 
@@ -42,8 +40,8 @@
 
                // select second option...
                $options = $( '#namespace' ).find( 'option' );
-               $options.eq(0).removeProp( 'selected' );
-               $options.eq(1).prop( 'selected', true );
+               $options.eq( 0 ).removeProp( 'selected' );
+               $options.eq( 1 ).prop( 'selected', true );
                $( '#namespace' ).change();
 
                // ... and checkboxes should be enabled again
@@ -51,8 +49,8 @@
                assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
 
                // select first option ( 'all' namespace)...
-               $options.eq(1).removeProp( 'selected' );
-               $options.eq(0).prop( 'selected', true );
+               $options.eq( 1 ).removeProp( 'selected' );
+               $options.eq( 0 ).prop( 'selected', true );
                $( '#namespace' ).change();
 
                // ... and checkboxes should now be disabled
@@ -61,5 +59,5 @@
 
                // DOM cleanup
                $env.remove();
-       });
+       } );
 }( mediaWiki, jQuery ) );
index 52f0538..30a31ef 100644 (file)
 ( function ( mw ) {
+       // mw.Title relies on these three config vars
+       // Restore them after each test run
+       var config = {
+               wgFormattedNamespaces: {
+                       '-2': 'Media',
+                       '-1': 'Special',
+                       0: '',
+                       1: 'Talk',
+                       2: 'User',
+                       3: 'User talk',
+                       4: 'Wikipedia',
+                       5: 'Wikipedia talk',
+                       6: 'File',
+                       7: 'File talk',
+                       8: 'MediaWiki',
+                       9: 'MediaWiki talk',
+                       10: 'Template',
+                       11: 'Template talk',
+                       12: 'Help',
+                       13: 'Help talk',
+                       14: 'Category',
+                       15: 'Category talk',
+                       // testing custom / localized namespace
+                       100: 'Penguins'
+               },
+               wgNamespaceIds: {
+                       /*jshint camelcase: false */
+                       media: -2,
+                       special: -1,
+                       '': 0,
+                       talk: 1,
+                       user: 2,
+                       user_talk: 3,
+                       wikipedia: 4,
+                       wikipedia_talk: 5,
+                       file: 6,
+                       file_talk: 7,
+                       mediawiki: 8,
+                       mediawiki_talk: 9,
+                       template: 10,
+                       template_talk: 11,
+                       help: 12,
+                       help_talk: 13,
+                       category: 14,
+                       category_talk: 15,
+                       image: 6,
+                       image_talk: 7,
+                       project: 4,
+                       project_talk: 5,
+                       /* testing custom / alias */
+                       penguins: 100,
+                       antarctic_waterfowl: 100
+               },
+               wgCaseSensitiveNamespaces: []
+       };
+
+       QUnit.module( 'mediawiki.Title', QUnit.newMwEnvironment( { config: config } ) );
+
+       QUnit.test( 'Transformation', 8, function ( assert ) {
+               var title;
+
+               title = new mw.Title( 'File:quux pif.jpg' );
+               assert.equal( title.getName(), 'Quux_pif' );
+
+               title = new mw.Title( 'File:Glarg_foo_glang.jpg' );
+               assert.equal( title.getNameText(), 'Glarg foo glang' );
+
+               title = new mw.Title( 'User:ABC.DEF' );
+               assert.equal( title.toText(), 'User:ABC.DEF' );
+               assert.equal( title.getNamespaceId(), 2 );
+               assert.equal( title.getNamespacePrefix(), 'User:' );
+
+               title = new mw.Title( 'uSEr:hAshAr' );
+               assert.equal( title.toText(), 'User:HAshAr' );
+               assert.equal( title.getNamespaceId(), 2 );
+
+               title = new mw.Title( '   MediaWiki:  Foo   bar   .js   ' );
+               // Don't ask why, it's the way the backend works. One space is kept of each set
+               assert.equal( title.getName(), 'Foo_bar_.js', 'Merge multiple spaces to a single space.' );
+       } );
+
+       QUnit.test( 'Main text for filename', 8, function ( assert ) {
+               var title = new mw.Title( 'File:foo_bar.JPG' );
+
+               assert.equal( title.getNamespaceId(), 6 );
+               assert.equal( title.getNamespacePrefix(), 'File:' );
+               assert.equal( title.getName(), 'Foo_bar' );
+               assert.equal( title.getNameText(), 'Foo bar' );
+               assert.equal( title.getMain(), 'Foo_bar.JPG' );
+               assert.equal( title.getMainText(), 'Foo bar.JPG' );
+               assert.equal( title.getExtension(), 'JPG' );
+               assert.equal( title.getDotExtension(), '.JPG' );
+       } );
+
+       QUnit.test( 'Namespace detection and conversion', 6, function ( assert ) {
+               var title;
+
+               title = new mw.Title( 'something.PDF', 6 );
+               assert.equal( title.toString(), 'File:Something.PDF' );
+
+               title = new mw.Title( 'NeilK', 3 );
+               assert.equal( title.toString(), 'User_talk:NeilK' );
+               assert.equal( title.toText(), 'User talk:NeilK' );
+
+               title = new mw.Title( 'Frobisher', 100 );
+               assert.equal( title.toString(), 'Penguins:Frobisher' );
+
+               title = new mw.Title( 'antarctic_waterfowl:flightless_yet_cute.jpg' );
+               assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
+
+               title = new mw.Title( 'Penguins:flightless_yet_cute.jpg' );
+               assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
+       } );
+
+       QUnit.test( 'Throw error on invalid title', 1, function ( assert ) {
+               assert.throws( function () {
+                       return new mw.Title( '' );
+               }, 'Throw error on empty string' );
+       } );
+
+       QUnit.test( 'Case-sensivity', 3, function ( assert ) {
+               var title;
+
+               // Default config
+               mw.config.set( 'wgCaseSensitiveNamespaces', [] );
+
+               title = new mw.Title( 'article' );
+               assert.equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
+
+               // $wgCapitalLinks = false;
+               mw.config.set( 'wgCaseSensitiveNamespaces', [0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15] );
+
+               title = new mw.Title( 'article' );
+               assert.equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
+
+               title = new mw.Title( 'john', 2 );
+               assert.equal( title.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
+       } );
+
+       QUnit.test( 'toString / toText', 2, function ( assert ) {
+               var title = new mw.Title( 'Some random page' );
+
+               assert.equal( title.toString(), title.getPrefixedDb() );
+               assert.equal( title.toText(), title.getPrefixedText() );
+       } );
 
-// mw.Title relies on these three config vars
-// Restore them after each test run
-var config = {
-       wgFormattedNamespaces: {
-               '-2': 'Media',
-               '-1': 'Special',
-               0: '',
-               1: 'Talk',
-               2: 'User',
-               3: 'User talk',
-               4: 'Wikipedia',
-               5: 'Wikipedia talk',
-               6: 'File',
-               7: 'File talk',
-               8: 'MediaWiki',
-               9: 'MediaWiki talk',
-               10: 'Template',
-               11: 'Template talk',
-               12: 'Help',
-               13: 'Help talk',
-               14: 'Category',
-               15: 'Category talk',
-               // testing custom / localized namespace
-               100: 'Penguins'
-       },
-       wgNamespaceIds: {
-               /*jshint camelcase: false */
-               media: -2,
-               special: -1,
-               '': 0,
-               talk: 1,
-               user: 2,
-               user_talk: 3,
-               wikipedia: 4,
-               wikipedia_talk: 5,
-               file: 6,
-               file_talk: 7,
-               mediawiki: 8,
-               mediawiki_talk: 9,
-               template: 10,
-               template_talk: 11,
-               help: 12,
-               help_talk: 13,
-               category: 14,
-               category_talk: 15,
-               image: 6,
-               image_talk: 7,
-               project: 4,
-               project_talk: 5,
-               /* testing custom / alias */
-               penguins: 100,
-               antarctic_waterfowl: 100
-       },
-       wgCaseSensitiveNamespaces: []
-};
-
-QUnit.module( 'mediawiki.Title', QUnit.newMwEnvironment({ config: config }) );
-
-
-QUnit.test( 'Transformation', 8, function ( assert ) {
-       var title;
-
-       title = new mw.Title( 'File:quux pif.jpg' );
-       assert.equal( title.getName(), 'Quux_pif' );
-
-       title = new mw.Title( 'File:Glarg_foo_glang.jpg' );
-       assert.equal( title.getNameText(), 'Glarg foo glang' );
-
-       title = new mw.Title( 'User:ABC.DEF' );
-       assert.equal( title.toText(), 'User:ABC.DEF' );
-       assert.equal( title.getNamespaceId(), 2 );
-       assert.equal( title.getNamespacePrefix(), 'User:' );
-
-       title = new mw.Title( 'uSEr:hAshAr' );
-       assert.equal( title.toText(), 'User:HAshAr' );
-       assert.equal( title.getNamespaceId(), 2 );
-
-       title = new mw.Title( '   MediaWiki:  Foo   bar   .js   ' );
-       // Don't ask why, it's the way the backend works. One space is kept of each set
-       assert.equal( title.getName(), 'Foo_bar_.js', 'Merge multiple spaces to a single space.' );
-});
-
-QUnit.test( 'Main text for filename', 8, function ( assert ) {
-       var title = new mw.Title( 'File:foo_bar.JPG' );
-
-       assert.equal( title.getNamespaceId(), 6 );
-       assert.equal( title.getNamespacePrefix(), 'File:' );
-       assert.equal( title.getName(), 'Foo_bar' );
-       assert.equal( title.getNameText(), 'Foo bar' );
-       assert.equal( title.getMain(), 'Foo_bar.JPG' );
-       assert.equal( title.getMainText(), 'Foo bar.JPG' );
-       assert.equal( title.getExtension(), 'JPG' );
-       assert.equal( title.getDotExtension(), '.JPG' );
-});
-
-QUnit.test( 'Namespace detection and conversion', 6, function ( assert ) {
-       var title;
-
-       title = new mw.Title( 'something.PDF', 6 );
-       assert.equal( title.toString(), 'File:Something.PDF' );
-
-       title = new mw.Title( 'NeilK', 3 );
-       assert.equal( title.toString(), 'User_talk:NeilK' );
-       assert.equal( title.toText(), 'User talk:NeilK' );
-
-       title = new mw.Title( 'Frobisher', 100 );
-       assert.equal( title.toString(), 'Penguins:Frobisher' );
-
-       title = new mw.Title( 'antarctic_waterfowl:flightless_yet_cute.jpg' );
-       assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
-
-       title = new mw.Title( 'Penguins:flightless_yet_cute.jpg' );
-       assert.equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
-});
-
-QUnit.test( 'Throw error on invalid title', 1, function ( assert ) {
-       assert.throws(function () {
-               return new mw.Title( '' );
-       }, 'Throw error on empty string' );
-});
-
-QUnit.test( 'Case-sensivity', 3, function ( assert ) {
-       var title;
-
-       // Default config
-       mw.config.set( 'wgCaseSensitiveNamespaces', [] );
-
-       title = new mw.Title( 'article' );
-       assert.equal( title.toString(), 'Article', 'Default config: No sensitive namespaces by default. First-letter becomes uppercase' );
-
-       // $wgCapitalLinks = false;
-       mw.config.set( 'wgCaseSensitiveNamespaces', [0, -2, 1, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15] );
-
-       title = new mw.Title( 'article' );
-       assert.equal( title.toString(), 'article', '$wgCapitalLinks=false: Article namespace is sensitive, first-letter case stays lowercase' );
-
-       title = new mw.Title( 'john', 2 );
-       assert.equal( title.toString(), 'User:John', '$wgCapitalLinks=false: User namespace is insensitive, first-letter becomes uppercase' );
-});
+       QUnit.test( 'getExtension', 7, function ( assert ) {
+               function extTest( pagename, ext, description ) {
+                       var title = new mw.Title( pagename );
+                       assert.equal( title.getExtension(), ext, description || pagename );
+               }
 
-QUnit.test( 'toString / toText', 2, function ( assert ) {
-       var title = new mw.Title( 'Some random page' );
+               extTest( 'MediaWiki:Vector.js', 'js' );
+               extTest( 'User:Example/common.css', 'css' );
+               extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (bug 36151)' );
+               extTest( 'Example/information.json', 'json', 'Extension parsing not restricted from any namespace' );
+               extTest( 'Foo.', null, 'Trailing dot is not an extension' );
+               extTest( 'Foo..', null, 'Trailing dots are not an extension' );
+               extTest( 'Foo.a.', null, 'Page name with dots and ending in a dot does not have an extension' );
 
-       assert.equal( title.toString(), title.getPrefixedDb() );
-       assert.equal( title.toText(), title.getPrefixedText() );
-});
+               // @broken: Throws an exception
+               // extTest( '.NET', null, 'Leading dot is (or is not?) an extension' );
+       } );
 
-QUnit.test( 'getExtension', 7, function ( assert ) {
+       QUnit.test( 'exists', 3, function ( assert ) {
+               var title;
 
-       function extTest( pagename, ext, description ) {
-               var title = new mw.Title( pagename );
-               assert.equal( title.getExtension(), ext, description || pagename );
-       }
+               // Empty registry, checks default to null
 
-       extTest( 'MediaWiki:Vector.js', 'js' );
-       extTest( 'User:Example/common.css', 'css' );
-       extTest( 'File:Example.longextension', 'longextension', 'Extension parsing not limited (bug 36151)' );
-       extTest( 'Example/information.json', 'json', 'Extension parsing not restricted from any namespace' );
-       extTest( 'Foo.', null, 'Trailing dot is not an extension' );
-       extTest( 'Foo..', null, 'Trailing dots are not an extension' );
-       extTest( 'Foo.a.', null, 'Page name with dots and ending in a dot does not have an extension' );
+               title = new mw.Title( 'Some random page', 4 );
+               assert.strictEqual( title.exists(), null, 'Return null with empty existance registry' );
 
-       // @broken: Throws an exception
-       // extTest( '.NET', null, 'Leading dot is (or is not?) an extension' );
-});
+               // Basic registry, checks default to boolean
+               mw.Title.exist.set( ['Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules'], true );
+               mw.Title.exist.set( ['Does_not_exist', 'User:John', 'Foobar'], false );
 
-QUnit.test( 'exists', 3, function ( assert ) {
-       var title;
+               title = new mw.Title( 'Project:Sandbox rules' );
+               assert.assertTrue( title.exists(), 'Return true for page titles marked as existing' );
+               title = new mw.Title( 'Foobar' );
+               assert.assertFalse( title.exists(), 'Return false for page titles marked as nonexistent' );
 
-       // Empty registry, checks default to null
+       } );
 
-       title = new mw.Title( 'Some random page', 4 );
-       assert.strictEqual( title.exists(), null, 'Return null with empty existance registry' );
+       QUnit.test( 'getUrl', 2, function ( assert ) {
+               var title;
 
-       // Basic registry, checks default to boolean
-       mw.Title.exist.set( ['Does_exist', 'User_talk:NeilK', 'Wikipedia:Sandbox_rules'], true );
-       mw.Title.exist.set( ['Does_not_exist', 'User:John', 'Foobar'], false );
+               // Config
+               mw.config.set( 'wgArticlePath', '/wiki/$1' );
 
-       title = new mw.Title( 'Project:Sandbox rules' );
-       assert.assertTrue( title.exists(), 'Return true for page titles marked as existing' );
-       title = new mw.Title( 'Foobar' );
-       assert.assertFalse( title.exists(), 'Return false for page titles marked as nonexistent' );
+               title = new mw.Title( 'Foobar' );
+               assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, toString passing to wikiGetlink' );
 
-});
+               title = new mw.Title( 'John Doe', 3 );
+               assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
+       } );
 
-QUnit.test( 'getUrl', 2, function ( assert ) {
-       var title;
-
-       // Config
-       mw.config.set( 'wgArticlePath', '/wiki/$1' );
-
-       title = new mw.Title( 'Foobar' );
-       assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, toString passing to wikiGetlink' );
-
-       title = new mw.Title( 'John Doe', 3 );
-       assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
-});
-
-}( mediaWiki ) );
\ No newline at end of file
+}( mediaWiki ) );
index 9eb2efc..9913f5e 100644 (file)
@@ -1,5 +1,5 @@
 ( function ( mw, $ ) {
-       QUnit.module( 'mediawiki.Uri', QUnit.newMwEnvironment({
+       QUnit.module( 'mediawiki.Uri', QUnit.newMwEnvironment( {
                setup: function () {
                        this.mwUriOrg = mw.Uri;
                        mw.Uri = mw.UriRelative( 'http://example.org/w/index.php' );
@@ -8,7 +8,7 @@
                        mw.Uri = this.mwUriOrg;
                        delete this.mwUriOrg;
                }
-       }) );
+       } ) );
 
        $.each( [true, false], function ( i, strictMode ) {
                QUnit.test( 'Basic construction and properties (' + ( strictMode ? '' : 'non-' ) + 'strict mode)', 2, function ( assert ) {
@@ -16,7 +16,7 @@
                        uriString = 'http://www.ietf.org/rfc/rfc2396.txt';
                        uri = new mw.Uri( uriString, {
                                strictMode: strictMode
-                       });
+                       } );
 
                        assert.deepEqual(
                                {
                                },
                                'construct composite components of URI on request'
                        );
-
-               });
-       });
+               } );
+       } );
 
        QUnit.test( 'Constructor( String[, Object ] )', 10, function ( assert ) {
                var uri;
 
                uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
                        overrideKeys: true
-               });
+               } );
 
                // Strict comparison to assert that numerical values stay strings
                assert.strictEqual( uri.query.n, '1', 'Simple parameter with overrideKeys:true' );
@@ -73,7 +72,7 @@
 
                uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
                        overrideKeys: false
-               });
+               } );
 
                assert.strictEqual( uri.query.n, '1', 'Simple parameter with overrideKeys:false' );
                assert.strictEqual( uri.query.m[0], 'foo', 'Order of multi-value parameters with overrideKeys:true' );
                        function () {
                                return new mw.Uri( 'foo.com/bar/baz', {
                                        strictMode: true
-                               });
+                               } );
                        },
                        function ( e ) {
                                return e.message === 'Bad constructor arguments';
 
                uri = new mw.Uri( 'foo.com/bar/baz', {
                        strictMode: false
-               });
+               } );
                assert.equal( uri.toString(), 'http://foo.com/bar/baz', 'normalize URI without protocol or // in loose mode' );
-       });
+       } );
 
        QUnit.test( 'Constructor( Object )', 3, function ( assert ) {
-               var uri = new mw.Uri({
+               var uri = new mw.Uri( {
                        protocol: 'http',
                        host: 'www.foo.local',
                        path: '/this'
-               });
+               } );
                assert.equal( uri.toString(), 'http://www.foo.local/this', 'Basic properties' );
 
-               uri = new mw.Uri({
+               uri = new mw.Uri( {
                        protocol: 'http',
                        host: 'www.foo.local',
                        path: '/this',
                        query: { hi: 'there' },
                        fragment: 'blah'
-               });
+               } );
                assert.equal( uri.toString(), 'http://www.foo.local/this?hi=there#blah', 'More complex properties' );
 
                assert.throws(
                        function () {
-                               return new mw.Uri({
+                               return new mw.Uri( {
                                        protocol: 'http',
                                        host: 'www.foo.local'
-                               });
+                               } );
                        },
                        function ( e ) {
                                return e.message === 'Bad constructor arguments';
                uri = uriBase.clone();
                uri.query.foo = 'bar';
                assert.equal( uri.toString(), 'http://en.wiki.local/w/api.php?foo=bar', 'extend query arguments' );
-               uri.extend({
+               uri.extend( {
                        foo: 'quux',
                        pif: 'paf'
-               });
+               } );
                assert.ok( uri.toString().indexOf( 'foo=quux' ) >= 0, 'extend query arguments' );
                assert.ok( uri.toString().indexOf( 'foo=bar' ) === -1, 'extend query arguments' );
-               assert.ok( uri.toString().indexOf( 'pif=paf' ) >= 0 , 'extend query arguments' );
+               assert.ok( uri.toString().indexOf( 'pif=paf' ) >= 0, 'extend query arguments' );
        } );
 
        QUnit.test( '.getQueryString()', 2, function ( assert ) {
 
                uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
                        overrideKeys: true
-               });
+               } );
 
                uri.query.n = [ 'x', 'y', 'z' ];
 
 
                uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', {
                        overrideKeys: false
-               });
+               } );
 
                // Change query values
                uri.query.n = [ 'x', 'y', 'z' ];
index 6c2a2d4..388f399 100644 (file)
 ( function ( mw, $ ) {
+       var mwLanguageCache = {}, oldGetOuterHtml, formatnumTests, specialCharactersPageName,
+               expectedListUsers, expectedEntrypoints;
 
-var mwLanguageCache = {}, oldGetOuterHtml, formatnumTests, specialCharactersPageName,
-       expectedListUsers, expectedEntrypoints;
-
-QUnit.module( 'mediawiki.jqueryMsg', QUnit.newMwEnvironment( {
-       setup: function () {
-               this.orgMwLangauge = mw.language;
-               mw.language = $.extend( true, {}, this.orgMwLangauge );
-               oldGetOuterHtml = $.fn.getOuterHtml;
-               $.fn.getOuterHtml = function () {
-                       var $div = $( '<div>' ), html;
-                       $div.append( $( this ).eq( 0 ).clone() );
-                       html = $div.html();
-                       $div.empty();
-                       $div = undefined;
-                       return html;
-               };
-
-               // Messages that are reused in multiple tests
-               mw.messages.set( {
-                       // The values for gender are not significant,
-                       // what matters is which of the values is choosen by the parser
-                       'gender-msg': '$1: {{GENDER:$2|blue|pink|green}}',
+       QUnit.module( 'mediawiki.jqueryMsg', QUnit.newMwEnvironment( {
+               setup: function () {
+                       this.orgMwLangauge = mw.language;
+                       mw.language = $.extend( true, {}, this.orgMwLangauge );
+                       oldGetOuterHtml = $.fn.getOuterHtml;
+                       $.fn.getOuterHtml = function () {
+                               var $div = $( '<div>' ), html;
+                               $div.append( $( this ).eq( 0 ).clone() );
+                               html = $div.html();
+                               $div.empty();
+                               $div = undefined;
+                               return html;
+                       };
 
-                       'plural-msg': 'Found $1 {{PLURAL:$1|item|items}}',
+                       // Messages that are reused in multiple tests
+                       mw.messages.set( {
+                               // The values for gender are not significant,
+                               // what matters is which of the values is choosen by the parser
+                               'gender-msg': '$1: {{GENDER:$2|blue|pink|green}}',
 
-                       // Assume the grammar form grammar_case_foo is not valid in any language
-                       'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
+                               'plural-msg': 'Found $1 {{PLURAL:$1|item|items}}',
 
-                       'formatnum-msg': '{{formatnum:$1}}',
+                               // Assume the grammar form grammar_case_foo is not valid in any language
+                               'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
 
-                       'portal-url': 'Project:Community portal',
-                       'see-portal-url': '{{Int:portal-url}} is an important community page.',
+                               'formatnum-msg': '{{formatnum:$1}}',
 
-                       'jquerymsg-test-statistics-users': '注册[[Special:ListUsers|用户]]',
+                               'portal-url': 'Project:Community portal',
+                               'see-portal-url': '{{Int:portal-url}} is an important community page.',
 
-                       'jquerymsg-test-version-entrypoints-index-php': '[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
+                               'jquerymsg-test-statistics-users': '注册[[Special:ListUsers|用户]]',
 
-                       'external-link-replace': 'Foo [$1 bar]'
-               } );
+                               'jquerymsg-test-version-entrypoints-index-php': '[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
 
-               specialCharactersPageName = '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
+                               'external-link-replace': 'Foo [$1 bar]'
+                       } );
 
-               expectedListUsers = '注册' + $( '<a>' ).attr( {
-                       title: 'Special:ListUsers',
-                       href: mw.util.wikiGetlink( 'Special:ListUsers' )
-               } ).text( '用户' ).getOuterHtml();
+                       specialCharactersPageName = '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
 
-               expectedEntrypoints = '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>';
-       },
-       teardown: function () {
-               mw.language = this.orgMwLangauge;
-               $.fn.getOuterHtml = oldGetOuterHtml;
-       }
-}) );
+                       expectedListUsers = '注册' + $( '<a>' ).attr( {
+                               title: 'Special:ListUsers',
+                               href: mw.util.wikiGetlink( 'Special:ListUsers' )
+                       } ).text( '用户' ).getOuterHtml();
 
-function getMwLanguage( langCode, cb ) {
-       if ( mwLanguageCache[langCode] !== undefined ) {
+                       expectedEntrypoints = '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>';
+               },
+               teardown: function () {
+                       mw.language = this.orgMwLangauge;
+                       $.fn.getOuterHtml = oldGetOuterHtml;
+               }
+       } ) );
+
+       function getMwLanguage( langCode, cb ) {
+               if ( mwLanguageCache[langCode] !== undefined ) {
+                       mwLanguageCache[langCode].add( cb );
+                       return;
+               }
+               mwLanguageCache[langCode] = $.Callbacks( 'once memory' );
                mwLanguageCache[langCode].add( cb );
-               return;
+               $.ajax( {
+                       url: mw.util.wikiScript( 'load' ),
+                       data: {
+                               skin: mw.config.get( 'skin' ),
+                               lang: langCode,
+                               debug: mw.config.get( 'debug' ),
+                               modules: [
+                                       'mediawiki.language.data',
+                                       'mediawiki.language'
+                               ].join( '|' ),
+                               only: 'scripts'
+                       },
+                       dataType: 'script'
+               } ).done(function () {
+                               mwLanguageCache[langCode].fire( mw.language );
+                       } ).fail( function () {
+                               mwLanguageCache[langCode].fire( false );
+                       } );
        }
-       mwLanguageCache[langCode] = $.Callbacks( 'once memory' );
-       mwLanguageCache[langCode].add( cb );
-       $.ajax({
-               url: mw.util.wikiScript( 'load' ),
-               data: {
-                       skin: mw.config.get( 'skin' ),
-                       lang: langCode,
-                       debug: mw.config.get( 'debug' ),
-                       modules: [
-                               'mediawiki.language.data',
-                               'mediawiki.language'
-                       ].join( '|' ),
-                       only: 'scripts'
-               },
-               dataType: 'script'
-       }).done( function () {
-               mwLanguageCache[langCode].fire( mw.language );
-       }).fail( function () {
-               mwLanguageCache[langCode].fire( false );
-       });
-}
-
-QUnit.test( 'Replace', 9, function ( assert ) {
-       var parser = mw.jqueryMsg.getMessageFunction();
-
-       mw.messages.set( 'simple', 'Foo $1 baz $2' );
-
-       assert.equal( parser( 'simple' ), 'Foo $1 baz $2', 'Replacements with no substitutes' );
-       assert.equal( parser( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' );
-       assert.equal( parser( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' );
-
-       mw.messages.set( 'plain-input', '<foo foo="foo">x$1y&lt;</foo>z' );
-
-       assert.equal(
-               parser( 'plain-input', 'bar' ),
-               '&lt;foo foo="foo"&gt;xbary&amp;lt;&lt;/foo&gt;z',
-               'Input is not considered html'
-       );
-
-       mw.messages.set( 'plain-replace', 'Foo $1' );
-
-       assert.equal(
-               parser( 'plain-replace', '<bar bar="bar">&gt;</bar>' ),
-               'Foo &lt;bar bar="bar"&gt;&amp;gt;&lt;/bar&gt;',
-               'Replacement is not considered html'
-       );
-
-       mw.messages.set( 'object-replace', 'Foo $1' );
-
-       assert.equal(
-               parser( 'object-replace', $( '<div class="bar">&gt;</div>' ) ),
-               'Foo <div class="bar">&gt;</div>',
-               'jQuery objects are preserved as raw html'
-       );
-
-       assert.equal(
-               parser( 'object-replace', $( '<div class="bar">&gt;</div>' ).get( 0 ) ),
-               'Foo <div class="bar">&gt;</div>',
-               'HTMLElement objects are preserved as raw html'
-       );
-
-       assert.equal(
-               parser( 'object-replace', $( '<div class="bar">&gt;</div>' ).toArray() ),
-               'Foo <div class="bar">&gt;</div>',
-               'HTMLElement[] arrays are preserved as raw html'
-       );
-
-       assert.equal(
-               parser( 'external-link-replace', 'http://example.org/?x=y&z' ),
-               'Foo <a href="http://example.org/?x=y&amp;z">bar</a>',
-               'Href is not double-escaped in wikilink function'
-       );
-} );
-
-QUnit.test( 'Plural', 3, function ( assert ) {
-       var parser = mw.jqueryMsg.getMessageFunction();
-
-       assert.equal( parser( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' );
-       assert.equal( parser( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' );
-       assert.equal( parser( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' );
-} );
-
-QUnit.test( 'Gender', 11, function ( assert ) {
-       // TODO: These tests should be for mw.msg once mw.msg integrated with mw.jqueryMsg
-       // TODO: English may not be the best language for these tests. Use a language like Arabic or Russian
-       var user = mw.user,
-               parser = mw.jqueryMsg.getMessageFunction();
-
-       user.options.set( 'gender', 'male' );
-       assert.equal(
-               parser( 'gender-msg', 'Bob', 'male' ),
-               'Bob: blue',
-               'Masculine from string "male"'
-       );
-       assert.equal(
-               parser( 'gender-msg', 'Bob', user ),
-               'Bob: blue',
-               'Masculine from mw.user object'
-       );
-
-       user.options.set( 'gender', 'unknown' );
-       assert.equal(
-               parser( 'gender-msg', 'Foo', user ),
-               'Foo: green',
-               'Neutral from mw.user object' );
-       assert.equal(
-               parser( 'gender-msg', 'Alice', 'female' ),
-               'Alice: pink',
-               'Feminine from string "female"' );
-       assert.equal(
-               parser( 'gender-msg', 'User' ),
-               'User: green',
-               'Neutral when no parameter given' );
-       assert.equal(
-               parser( 'gender-msg', 'User', 'unknown' ),
-               'User: green',
-               'Neutral from string "unknown"'
-       );
-
-       mw.messages.set( 'gender-msg-one-form', '{{GENDER:$1|User}}: $2 {{PLURAL:$2|edit|edits}}' );
-
-       assert.equal(
-               parser( 'gender-msg-one-form', 'male', 10 ),
-               'User: 10 edits',
-               'Gender neutral and plural form'
-       );
-       assert.equal(
-               parser( 'gender-msg-one-form', 'female', 1 ),
-               'User: 1 edit',
-               'Gender neutral and singular form'
-       );
-
-       mw.messages.set( 'gender-msg-lowercase', '{{gender:$1|he|she}} is awesome' );
-       assert.equal(
-               parser( 'gender-msg-lowercase', 'male' ),
-               'he is awesome',
-               'Gender masculine'
-       );
-       assert.equal(
-               parser( 'gender-msg-lowercase', 'female' ),
-               'she is awesome',
-               'Gender feminine'
-       );
-
-       mw.messages.set( 'gender-msg-wrong', '{{gender}} test' );
-       assert.equal(
-               parser( 'gender-msg-wrong', 'female' ),
-               ' test',
-               'Invalid syntax should result in {{gender}} simply being stripped away'
-       );
-} );
-
-QUnit.test( 'Grammar', 2, function ( assert ) {
-       var parser = mw.jqueryMsg.getMessageFunction();
-
-       assert.equal( parser( 'grammar-msg' ), 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar Test with sitename' );
-
-       mw.messages.set( 'grammar-msg-wrong-syntax', 'Przeszukaj {{GRAMMAR:grammar_case_xyz}}' );
-       assert.equal( parser( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ' , 'Grammar Test with wrong grammar template syntax' );
-} );
-
-QUnit.test( 'Match PHP parser', mw.libs.phpParserData.tests.length, function ( assert ) {
-       mw.messages.set( mw.libs.phpParserData.messages );
-       $.each( mw.libs.phpParserData.tests, function ( i, test ) {
-               QUnit.stop();
-               getMwLanguage( test.lang, function ( langClass ) {
-                       QUnit.start();
-                       if ( !langClass ) {
-                               assert.ok( false, 'Language "' + test.lang + '" failed to load' );
-                               return;
-                       }
-                       mw.config.set( 'wgUserLanguage', test.lang ) ;
-                       var parser = new mw.jqueryMsg.parser( { language: langClass } );
-                       assert.equal(
-                               parser.parse( test.key, test.args ).html(),
-                               test.result,
-                               test.name
-                       );
-               } );
+
+       QUnit.test( 'Replace', 9, function ( assert ) {
+               var parser = mw.jqueryMsg.getMessageFunction();
+
+               mw.messages.set( 'simple', 'Foo $1 baz $2' );
+
+               assert.equal( parser( 'simple' ), 'Foo $1 baz $2', 'Replacements with no substitutes' );
+               assert.equal( parser( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' );
+               assert.equal( parser( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' );
+
+               mw.messages.set( 'plain-input', '<foo foo="foo">x$1y&lt;</foo>z' );
+
+               assert.equal(
+                       parser( 'plain-input', 'bar' ),
+                       '&lt;foo foo="foo"&gt;xbary&amp;lt;&lt;/foo&gt;z',
+                       'Input is not considered html'
+               );
+
+               mw.messages.set( 'plain-replace', 'Foo $1' );
+
+               assert.equal(
+                       parser( 'plain-replace', '<bar bar="bar">&gt;</bar>' ),
+                       'Foo &lt;bar bar="bar"&gt;&amp;gt;&lt;/bar&gt;',
+                       'Replacement is not considered html'
+               );
+
+               mw.messages.set( 'object-replace', 'Foo $1' );
+
+               assert.equal(
+                       parser( 'object-replace', $( '<div class="bar">&gt;</div>' ) ),
+                       'Foo <div class="bar">&gt;</div>',
+                       'jQuery objects are preserved as raw html'
+               );
+
+               assert.equal(
+                       parser( 'object-replace', $( '<div class="bar">&gt;</div>' ).get( 0 ) ),
+                       'Foo <div class="bar">&gt;</div>',
+                       'HTMLElement objects are preserved as raw html'
+               );
+
+               assert.equal(
+                       parser( 'object-replace', $( '<div class="bar">&gt;</div>' ).toArray() ),
+                       'Foo <div class="bar">&gt;</div>',
+                       'HTMLElement[] arrays are preserved as raw html'
+               );
+
+               assert.equal(
+                       parser( 'external-link-replace', 'http://example.org/?x=y&z' ),
+                       'Foo <a href="http://example.org/?x=y&amp;z">bar</a>',
+                       'Href is not double-escaped in wikilink function'
+               );
        } );
-});
-
-QUnit.test( 'Links', 6, function ( assert ) {
-       var parser = mw.jqueryMsg.getMessageFunction(),
-               expectedDisambiguationsText,
-               expectedMultipleBars,
-               expectedSpecialCharacters;
-
-       /*
-        The below three are all identical to or based on real messages.  For disambiguations-text,
-        the bold was removed because it is not yet implemented.
-       */
-
-       assert.equal(
-               parser( 'jquerymsg-test-statistics-users' ),
-               expectedListUsers,
-               'Piped wikilink'
-       );
-
-       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 ' +
-               $( '<a>' ).attr( {
-                       title: 'MediaWiki:Disambiguationspage',
-                       href: mw.util.wikiGetlink( 'MediaWiki:Disambiguationspage' )
-               } ).text( 'MediaWiki:Disambiguationspage' ).getOuterHtml() + '.';
-       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]].' );
-       assert.equal(
-               parser( 'disambiguations-text' ),
-               expectedDisambiguationsText,
-               'Wikilink without pipe'
-       );
-
-       assert.equal(
-               parser( 'jquerymsg-test-version-entrypoints-index-php' ),
-               expectedEntrypoints,
-               'External link'
-       );
-
-       // Pipe trick is not supported currently, but should not parse as text either.
-       mw.messages.set( 'pipe-trick', '[[Tampa, Florida|]]' );
-       assert.equal(
-               parser( 'pipe-trick' ),
-               'pipe-trick: Parse error at position 0 in input: [[Tampa, Florida|]]',
-               'Pipe trick should return error string.'
-       );
-
-       expectedMultipleBars = $( '<a>' ).attr( {
-               title: 'Main Page',
-               href: mw.util.wikiGetlink( 'Main Page' )
-       } ).text( 'Main|Page' ).getOuterHtml();
-       mw.messages.set( 'multiple-bars', '[[Main Page|Main|Page]]' );
-       assert.equal(
-               parser( 'multiple-bars' ),
-               expectedMultipleBars,
-               'Bar in anchor'
-       );
-
-       expectedSpecialCharacters = $( '<a>' ).attr( {
-               title: specialCharactersPageName,
-               href: mw.util.wikiGetlink( specialCharactersPageName )
-       } ).text( specialCharactersPageName ).getOuterHtml();
-
-       mw.messages.set( 'special-characters', '[[' + specialCharactersPageName + ']]' );
-       assert.equal(
-               parser( 'special-characters' ),
-               expectedSpecialCharacters,
-               'Special characters'
-       );
-});
 
-// Tests that {{-transformation vs. general parsing are done as requested
-QUnit.test( 'Curly brace transformation', 14, function ( assert ) {
-       var formatText, formatParse, oldUserLang;
+       QUnit.test( 'Plural', 3, function ( assert ) {
+               var parser = mw.jqueryMsg.getMessageFunction();
 
-       oldUserLang = mw.config.get( 'wgUserLanguage' ) ;
+               assert.equal( parser( 'plural-msg', 0 ), 'Found 0 items', 'Plural test for english with zero as count' );
+               assert.equal( parser( 'plural-msg', 1 ), 'Found 1 item', 'Singular test for english' );
+               assert.equal( parser( 'plural-msg', 2 ), 'Found 2 items', 'Plural test for english' );
+       } );
 
-       formatText= mw.jqueryMsg.getMessageFunction( {
-               format: 'text'
+       QUnit.test( 'Gender', 11, function ( assert ) {
+               // TODO: These tests should be for mw.msg once mw.msg integrated with mw.jqueryMsg
+               // TODO: English may not be the best language for these tests. Use a language like Arabic or Russian
+               var user = mw.user,
+                       parser = mw.jqueryMsg.getMessageFunction();
+
+               user.options.set( 'gender', 'male' );
+               assert.equal(
+                       parser( 'gender-msg', 'Bob', 'male' ),
+                       'Bob: blue',
+                       'Masculine from string "male"'
+               );
+               assert.equal(
+                       parser( 'gender-msg', 'Bob', user ),
+                       'Bob: blue',
+                       'Masculine from mw.user object'
+               );
+
+               user.options.set( 'gender', 'unknown' );
+               assert.equal(
+                       parser( 'gender-msg', 'Foo', user ),
+                       'Foo: green',
+                       'Neutral from mw.user object' );
+               assert.equal(
+                       parser( 'gender-msg', 'Alice', 'female' ),
+                       'Alice: pink',
+                       'Feminine from string "female"' );
+               assert.equal(
+                       parser( 'gender-msg', 'User' ),
+                       'User: green',
+                       'Neutral when no parameter given' );
+               assert.equal(
+                       parser( 'gender-msg', 'User', 'unknown' ),
+                       'User: green',
+                       'Neutral from string "unknown"'
+               );
+
+               mw.messages.set( 'gender-msg-one-form', '{{GENDER:$1|User}}: $2 {{PLURAL:$2|edit|edits}}' );
+
+               assert.equal(
+                       parser( 'gender-msg-one-form', 'male', 10 ),
+                       'User: 10 edits',
+                       'Gender neutral and plural form'
+               );
+               assert.equal(
+                       parser( 'gender-msg-one-form', 'female', 1 ),
+                       'User: 1 edit',
+                       'Gender neutral and singular form'
+               );
+
+               mw.messages.set( 'gender-msg-lowercase', '{{gender:$1|he|she}} is awesome' );
+               assert.equal(
+                       parser( 'gender-msg-lowercase', 'male' ),
+                       'he is awesome',
+                       'Gender masculine'
+               );
+               assert.equal(
+                       parser( 'gender-msg-lowercase', 'female' ),
+                       'she is awesome',
+                       'Gender feminine'
+               );
+
+               mw.messages.set( 'gender-msg-wrong', '{{gender}} test' );
+               assert.equal(
+                       parser( 'gender-msg-wrong', 'female' ),
+                       ' test',
+                       'Invalid syntax should result in {{gender}} simply being stripped away'
+               );
        } );
 
-       formatParse = mw.jqueryMsg.getMessageFunction( {
-               format: 'parse'
+       QUnit.test( 'Grammar', 2, function ( assert ) {
+               var parser = mw.jqueryMsg.getMessageFunction();
+
+               assert.equal( parser( 'grammar-msg' ), 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar Test with sitename' );
+
+               mw.messages.set( 'grammar-msg-wrong-syntax', 'Przeszukaj {{GRAMMAR:grammar_case_xyz}}' );
+               assert.equal( parser( 'grammar-msg-wrong-syntax' ), 'Przeszukaj ', 'Grammar Test with wrong grammar template syntax' );
        } );
 
-       // When the expected result is the same in both modes
-       function assertBothModes( parserArguments, expectedResult, assertMessage) {
-               assert.equal( formatText.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'text\'' );
-               assert.equal( formatParse.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'parse\'' );
-       }
+       QUnit.test( 'Match PHP parser', mw.libs.phpParserData.tests.length, function ( assert ) {
+               mw.messages.set( mw.libs.phpParserData.messages );
+               $.each( mw.libs.phpParserData.tests, function ( i, test ) {
+                       QUnit.stop();
+                       getMwLanguage( test.lang, function ( langClass ) {
+                               QUnit.start();
+                               if ( !langClass ) {
+                                       assert.ok( false, 'Language "' + test.lang + '" failed to load' );
+                                       return;
+                               }
+                               mw.config.set( 'wgUserLanguage', test.lang );
+                               var parser = new mw.jqueryMsg.parser( { language: langClass } );
+                               assert.equal(
+                                       parser.parse( test.key, test.args ).html(),
+                                       test.result,
+                                       test.name
+                               );
+                       } );
+               } );
+       } );
+
+       QUnit.test( 'Links', 6, function ( assert ) {
+               var parser = mw.jqueryMsg.getMessageFunction(),
+                       expectedDisambiguationsText,
+                       expectedMultipleBars,
+                       expectedSpecialCharacters;
+
+               /*
+                The below three are all identical to or based on real messages.  For disambiguations-text,
+                the bold was removed because it is not yet implemented.
+                */
+
+               assert.equal(
+                       parser( 'jquerymsg-test-statistics-users' ),
+                       expectedListUsers,
+                       'Piped wikilink'
+               );
+
+               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 ' +
+                       $( '<a>' ).attr( {
+                               title: 'MediaWiki:Disambiguationspage',
+                               href: mw.util.wikiGetlink( 'MediaWiki:Disambiguationspage' )
+                       } ).text( 'MediaWiki:Disambiguationspage' ).getOuterHtml() + '.';
+               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]].' );
+               assert.equal(
+                       parser( 'disambiguations-text' ),
+                       expectedDisambiguationsText,
+                       'Wikilink without pipe'
+               );
+
+               assert.equal(
+                       parser( 'jquerymsg-test-version-entrypoints-index-php' ),
+                       expectedEntrypoints,
+                       'External link'
+               );
+
+               // Pipe trick is not supported currently, but should not parse as text either.
+               mw.messages.set( 'pipe-trick', '[[Tampa, Florida|]]' );
+               assert.equal(
+                       parser( 'pipe-trick' ),
+                       'pipe-trick: Parse error at position 0 in input: [[Tampa, Florida|]]',
+                       'Pipe trick should return error string.'
+               );
+
+               expectedMultipleBars = $( '<a>' ).attr( {
+                       title: 'Main Page',
+                       href: mw.util.wikiGetlink( 'Main Page' )
+               } ).text( 'Main|Page' ).getOuterHtml();
+               mw.messages.set( 'multiple-bars', '[[Main Page|Main|Page]]' );
+               assert.equal(
+                       parser( 'multiple-bars' ),
+                       expectedMultipleBars,
+                       'Bar in anchor'
+               );
+
+               expectedSpecialCharacters = $( '<a>' ).attr( {
+                       title: specialCharactersPageName,
+                       href: mw.util.wikiGetlink( specialCharactersPageName )
+               } ).text( specialCharactersPageName ).getOuterHtml();
+
+               mw.messages.set( 'special-characters', '[[' + specialCharactersPageName + ']]' );
+               assert.equal(
+                       parser( 'special-characters' ),
+                       expectedSpecialCharacters,
+                       'Special characters'
+               );
+       } );
+
+// Tests that {{-transformation vs. general parsing are done as requested
+       QUnit.test( 'Curly brace transformation', 14, function ( assert ) {
+               var formatText, formatParse, oldUserLang;
+
+               oldUserLang = mw.config.get( 'wgUserLanguage' );
+
+               formatText = mw.jqueryMsg.getMessageFunction( {
+                       format: 'text'
+               } );
 
-       assertBothModes( ['gender-msg', 'Bob', 'male'], 'Bob: blue', 'gender is resolved' );
-
-       assertBothModes( ['plural-msg', 5], 'Found 5 items', 'plural is resolved' );
-
-       assertBothModes( ['grammar-msg'], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'grammar is resolved' );
-
-       mw.config.set( 'wgUserLanguage', 'en' ) ;
-       assertBothModes( ['formatnum-msg', '987654321.654321'], '987654321.654321', 'formatnum is resolved' );
-
-       // Test non-{{ wikitext, where behavior differs
-
-       // Wikilink
-       assert.equal(
-               formatText( 'jquerymsg-test-statistics-users' ),
-               mw.messages.get( 'jquerymsg-test-statistics-users' ),
-               'Internal link message unchanged when format is \'text\''
-       );
-       assert.equal(
-               formatParse( 'jquerymsg-test-statistics-users' ),
-               expectedListUsers,
-               'Internal link message parsed when format is \'parse\''
-       );
-
-       // External link
-       assert.equal(
-               formatText( 'jquerymsg-test-version-entrypoints-index-php' ),
-               mw.messages.get( 'jquerymsg-test-version-entrypoints-index-php' ),
-               'External link message unchanged when format is \'text\''
-       );
-       assert.equal(
-               formatParse( 'jquerymsg-test-version-entrypoints-index-php' ),
-               expectedEntrypoints,
-               'External link message processed when format is \'parse\''
-       );
-
-       // External link with parameter
-       assert.equal(
-               formatText( 'external-link-replace', 'http://example.com' ),
-               'Foo [http://example.com bar]',
-               'External link message only substitutes parameter when format is \'text\''
-       );
-       assert.equal(
-               formatParse( 'external-link-replace', 'http://example.com' ),
-               'Foo <a href="http://example.com">bar</a>',
-               'External link message processed when format is \'parse\''
-       );
-
-       mw.config.set( 'wgUserLanguage', oldUserLang );
-} );
-
-QUnit.test( 'Int', 4, function ( assert ) {
-       var parser = mw.jqueryMsg.getMessageFunction(),
-           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:Helppage}}|help page]] for more info). If you are here by mistake, click your browser\'s back button.',
-               expectedNewarticletext;
-
-       mw.messages.set( 'helppage', 'Help:Contents' );
-
-       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 ' +
-               $( '<a>' ).attr( {
-                       title: mw.msg( 'helppage' ),
-                       href: mw.util.wikiGetlink( mw.msg( 'helppage' ) )
-               } ).text( 'help page' ).getOuterHtml() + ' for more info). If you are here by mistake, click your browser\'s back button.';
-
-       mw.messages.set( 'newarticletext', newarticletextSource );
-
-       assert.equal(
-               parser( 'newarticletext' ),
-               expectedNewarticletext,
-               'Link with nested message'
-       );
-
-       assert.equal(
-               parser( 'see-portal-url' ),
-               'Project:Community portal is an important community page.',
-               'Nested message'
-       );
-
-       mw.messages.set( 'newarticletext-lowercase',
-               newarticletextSource.replace( 'Int:Helppage', 'int:helppage' ) );
-
-       assert.equal(
-               parser( 'newarticletext-lowercase' ),
-               expectedNewarticletext,
-               'Link with nested message, lowercase include'
-       );
-
-       mw.messages.set( 'uses-missing-int', '{{int:doesnt-exist}}' );
-
-       assert.equal(
-               parser( 'uses-missing-int' ),
-               '[doesnt-exist]',
-               'int: where nested message does not exist'
-       );
-});
+               formatParse = mw.jqueryMsg.getMessageFunction( {
+                       format: 'parse'
+               } );
+
+               // When the expected result is the same in both modes
+               function assertBothModes( parserArguments, expectedResult, assertMessage ) {
+                       assert.equal( formatText.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'text\'' );
+                       assert.equal( formatParse.apply( null, parserArguments ), expectedResult, assertMessage + ' when format is \'parse\'' );
+               }
+
+               assertBothModes( ['gender-msg', 'Bob', 'male'], 'Bob: blue', 'gender is resolved' );
+
+               assertBothModes( ['plural-msg', 5], 'Found 5 items', 'plural is resolved' );
+
+               assertBothModes( ['grammar-msg'], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'grammar is resolved' );
+
+               mw.config.set( 'wgUserLanguage', 'en' );
+               assertBothModes( ['formatnum-msg', '987654321.654321'], '987654321.654321', 'formatnum is resolved' );
+
+               // Test non-{{ wikitext, where behavior differs
+
+               // Wikilink
+               assert.equal(
+                       formatText( 'jquerymsg-test-statistics-users' ),
+                       mw.messages.get( 'jquerymsg-test-statistics-users' ),
+                       'Internal link message unchanged when format is \'text\''
+               );
+               assert.equal(
+                       formatParse( 'jquerymsg-test-statistics-users' ),
+                       expectedListUsers,
+                       'Internal link message parsed when format is \'parse\''
+               );
+
+               // External link
+               assert.equal(
+                       formatText( 'jquerymsg-test-version-entrypoints-index-php' ),
+                       mw.messages.get( 'jquerymsg-test-version-entrypoints-index-php' ),
+                       'External link message unchanged when format is \'text\''
+               );
+               assert.equal(
+                       formatParse( 'jquerymsg-test-version-entrypoints-index-php' ),
+                       expectedEntrypoints,
+                       'External link message processed when format is \'parse\''
+               );
+
+               // External link with parameter
+               assert.equal(
+                       formatText( 'external-link-replace', 'http://example.com' ),
+                       'Foo [http://example.com bar]',
+                       'External link message only substitutes parameter when format is \'text\''
+               );
+               assert.equal(
+                       formatParse( 'external-link-replace', 'http://example.com' ),
+                       'Foo <a href="http://example.com">bar</a>',
+                       'External link message processed when format is \'parse\''
+               );
+
+               mw.config.set( 'wgUserLanguage', oldUserLang );
+       } );
+
+       QUnit.test( 'Int', 4, function ( assert ) {
+               var parser = mw.jqueryMsg.getMessageFunction(),
+                       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:Helppage}}|help page]] for more info). If you are here by mistake, click your browser\'s back button.',
+                       expectedNewarticletext;
+
+               mw.messages.set( 'helppage', 'Help:Contents' );
+
+               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 ' +
+                       $( '<a>' ).attr( {
+                               title: mw.msg( 'helppage' ),
+                               href: mw.util.wikiGetlink( mw.msg( 'helppage' ) )
+                       } ).text( 'help page' ).getOuterHtml() + ' for more info). If you are here by mistake, click your browser\'s back button.';
+
+               mw.messages.set( 'newarticletext', newarticletextSource );
+
+               assert.equal(
+                       parser( 'newarticletext' ),
+                       expectedNewarticletext,
+                       'Link with nested message'
+               );
+
+               assert.equal(
+                       parser( 'see-portal-url' ),
+                       'Project:Community portal is an important community page.',
+                       'Nested message'
+               );
+
+               mw.messages.set( 'newarticletext-lowercase',
+                       newarticletextSource.replace( 'Int:Helppage', 'int:helppage' ) );
+
+               assert.equal(
+                       parser( 'newarticletext-lowercase' ),
+                       expectedNewarticletext,
+                       'Link with nested message, lowercase include'
+               );
+
+               mw.messages.set( 'uses-missing-int', '{{int:doesnt-exist}}' );
+
+               assert.equal(
+                       parser( 'uses-missing-int' ),
+                       '[doesnt-exist]',
+                       'int: where nested message does not exist'
+               );
+       } );
 
 // Tests that getMessageFunction is used for non-plain messages with curly braces or
 // square brackets, but not otherwise.
-QUnit.test( 'mw.Message.prototype.parser monkey-patch', 22, function ( assert ) {
-       var oldGMF, outerCalled, innerCalled;
-
-       mw.messages.set( {
-               'curly-brace': '{{int:message}}',
-               'single-square-bracket': '[https://www.mediawiki.org/ MediaWiki]',
-               'double-square-bracket': '[[Some page]]',
-               'regular': 'Other message'
-       } );
+       QUnit.test( 'mw.Message.prototype.parser monkey-patch', 22, function ( assert ) {
+               var oldGMF, outerCalled, innerCalled;
 
-       oldGMF = mw.jqueryMsg.getMessageFunction;
+               mw.messages.set( {
+                       'curly-brace': '{{int:message}}',
+                       'single-square-bracket': '[https://www.mediawiki.org/ MediaWiki]',
+                       'double-square-bracket': '[[Some page]]',
+                       'regular': 'Other message'
+               } );
 
-       mw.jqueryMsg.getMessageFunction = function() {
-               outerCalled = true;
-               return function() {
-                       innerCalled = true;
+               oldGMF = mw.jqueryMsg.getMessageFunction;
+
+               mw.jqueryMsg.getMessageFunction = function () {
+                       outerCalled = true;
+                       return function () {
+                               innerCalled = true;
+                       };
                };
-       };
-
-       function verifyGetMessageFunction( key, format, shouldCall ) {
-               var message;
-               outerCalled = false;
-               innerCalled = false;
-               message = mw.message( key );
-               message[format]();
-               assert.strictEqual( outerCalled, shouldCall, 'Outer function called for ' + key );
-               assert.strictEqual( innerCalled, shouldCall, 'Inner function called for ' + key );
-       }
 
-       verifyGetMessageFunction( 'curly-brace', 'parse', true );
-       verifyGetMessageFunction( 'curly-brace', 'plain', false );
-
-       verifyGetMessageFunction( 'single-square-bracket', 'parse', true );
-       verifyGetMessageFunction( 'single-square-bracket', 'plain', false );
-
-       verifyGetMessageFunction( 'double-square-bracket', 'parse', true );
-       verifyGetMessageFunction( 'double-square-bracket', 'plain', false );
-
-       verifyGetMessageFunction( 'regular', 'parse', false );
-       verifyGetMessageFunction( 'regular', 'plain', false );
-
-       verifyGetMessageFunction( 'jquerymsg-test-pagetriage-del-talk-page-notify-summary', 'plain', false );
-       verifyGetMessageFunction( 'jquerymsg-test-categorytree-collapse-bullet', 'plain', false );
-       verifyGetMessageFunction( 'jquerymsg-test-wikieditor-toolbar-help-content-signature-result', 'plain', false );
-
-       mw.jqueryMsg.getMessageFunction = oldGMF;
-} );
-
-formatnumTests = [
-       {
-               lang: 'en',
-               number: 987654321.654321,
-               result: '987654321.654321',
-               description: 'formatnum test for English, decimal seperator'
-       },
-       {
-               lang: 'ar',
-               number: 987654321.654321,
-               result: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١',
-               description: 'formatnum test for Arabic, with decimal seperator'
-       },
-       {
-               lang: 'ar',
-               number: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١',
-               result: 987654321,
-               integer: true,
-               description: 'formatnum test for Arabic, with decimal seperator, reverse'
-       },
-       {
-               lang: 'ar',
-               number: -12.89,
-               result: '-١٢٫٨٩',
-               description: 'formatnum test for Arabic, negative number'
-       },
-       {
-               lang: 'ar',
-               number: '-١٢٫٨٩',
-               result: -12,
-               integer: true,
-               description: 'formatnum test for Arabic, negative number, reverse'
-       },
-       {
-               lang: 'nl',
-               number: 987654321.654321,
-               result: '987654321,654321',
-               description: 'formatnum test for Nederlands, decimal seperator'
-       },
-       {
-               lang: 'nl',
-               number: -12.89,
-               result: '-12,89',
-               description: 'formatnum test for Nederlands, negative number'
-       },
-       {
-               lang: 'nl',
-               number: 'invalidnumber',
-               result: 'invalidnumber',
-               description: 'formatnum test for Nederlands, invalid number'
-       }
-];
-
-QUnit.test( 'formatnum', formatnumTests.length, function ( assert ) {
-       mw.messages.set( 'formatnum-msg-int', '{{formatnum:$1|R}}' );
-       $.each( formatnumTests, function ( i, test ) {
-               QUnit.stop();
-               getMwLanguage( test.lang, function ( langClass ) {
-                       QUnit.start();
-                       if ( !langClass ) {
-                               assert.ok( false, 'Language "' + test.lang + '" failed to load' );
-                               return;
-                       }
-                       mw.messages.set(test.message );
-                       mw.config.set( 'wgUserLanguage', test.lang ) ;
-                       var parser = new mw.jqueryMsg.parser( { language: langClass } );
-                       assert.equal(
-                               parser.parse( test.integer ? 'formatnum-msg-int' : 'formatnum-msg',
-                                       [ test.number ] ).html(),
-                               test.result,
-                               test.description
-                       );
+               function verifyGetMessageFunction( key, format, shouldCall ) {
+                       var message;
+                       outerCalled = false;
+                       innerCalled = false;
+                       message = mw.message( key );
+                       message[format]();
+                       assert.strictEqual( outerCalled, shouldCall, 'Outer function called for ' + key );
+                       assert.strictEqual( innerCalled, shouldCall, 'Inner function called for ' + key );
+               }
+
+               verifyGetMessageFunction( 'curly-brace', 'parse', true );
+               verifyGetMessageFunction( 'curly-brace', 'plain', false );
+
+               verifyGetMessageFunction( 'single-square-bracket', 'parse', true );
+               verifyGetMessageFunction( 'single-square-bracket', 'plain', false );
+
+               verifyGetMessageFunction( 'double-square-bracket', 'parse', true );
+               verifyGetMessageFunction( 'double-square-bracket', 'plain', false );
+
+               verifyGetMessageFunction( 'regular', 'parse', false );
+               verifyGetMessageFunction( 'regular', 'plain', false );
+
+               verifyGetMessageFunction( 'jquerymsg-test-pagetriage-del-talk-page-notify-summary', 'plain', false );
+               verifyGetMessageFunction( 'jquerymsg-test-categorytree-collapse-bullet', 'plain', false );
+               verifyGetMessageFunction( 'jquerymsg-test-wikieditor-toolbar-help-content-signature-result', 'plain', false );
+
+               mw.jqueryMsg.getMessageFunction = oldGMF;
+       } );
+
+       formatnumTests = [
+               {
+                       lang: 'en',
+                       number: 987654321.654321,
+                       result: '987654321.654321',
+                       description: 'formatnum test for English, decimal seperator'
+               },
+               {
+                       lang: 'ar',
+                       number: 987654321.654321,
+                       result: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١',
+                       description: 'formatnum test for Arabic, with decimal seperator'
+               },
+               {
+                       lang: 'ar',
+                       number: '٩٨٧٦٥٤٣٢١٫٦٥٤٣٢١',
+                       result: 987654321,
+                       integer: true,
+                       description: 'formatnum test for Arabic, with decimal seperator, reverse'
+               },
+               {
+                       lang: 'ar',
+                       number: -12.89,
+                       result: '-١٢٫٨٩',
+                       description: 'formatnum test for Arabic, negative number'
+               },
+               {
+                       lang: 'ar',
+                       number: '-١٢٫٨٩',
+                       result: -12,
+                       integer: true,
+                       description: 'formatnum test for Arabic, negative number, reverse'
+               },
+               {
+                       lang: 'nl',
+                       number: 987654321.654321,
+                       result: '987654321,654321',
+                       description: 'formatnum test for Nederlands, decimal seperator'
+               },
+               {
+                       lang: 'nl',
+                       number: -12.89,
+                       result: '-12,89',
+                       description: 'formatnum test for Nederlands, negative number'
+               },
+               {
+                       lang: 'nl',
+                       number: 'invalidnumber',
+                       result: 'invalidnumber',
+                       description: 'formatnum test for Nederlands, invalid number'
+               }
+       ];
+
+       QUnit.test( 'formatnum', formatnumTests.length, function ( assert ) {
+               mw.messages.set( 'formatnum-msg-int', '{{formatnum:$1|R}}' );
+               $.each( formatnumTests, function ( i, test ) {
+                       QUnit.stop();
+                       getMwLanguage( test.lang, function ( langClass ) {
+                               QUnit.start();
+                               if ( !langClass ) {
+                                       assert.ok( false, 'Language "' + test.lang + '" failed to load' );
+                                       return;
+                               }
+                               mw.messages.set( test.message );
+                               mw.config.set( 'wgUserLanguage', test.lang );
+                               var parser = new mw.jqueryMsg.parser( { language: langClass } );
+                               assert.equal(
+                                       parser.parse( test.integer ? 'formatnum-msg-int' : 'formatnum-msg',
+                                               [ test.number ] ).html(),
+                                       test.result,
+                                       test.description
+                               );
+                       } );
                } );
        } );
-});
 
 }( mediaWiki, jQuery ) );
index bc6fafe..3328ce3 100644 (file)
@@ -14,7 +14,7 @@
                assert.deepEqual( ŝablono, orig, 'ŝablono' );
                assert.deepEqual( \u015dablono, orig, '\\u015dablono' );
                assert.deepEqual( \u015Dablono, orig, '\\u015Dablono' );
-       });
+       } );
 
        /*
        // Not that we need this. ;)
                }
 
                for ( n = 0; n < maxn; n++ ) {
-                       expected = repeat('\n', n) + 'some text';
+                       expected = repeat( '\n', n ) + 'some text';
 
-                       $textarea = $('<textarea>\n' + expected + '</textarea>');
+                       $textarea = $( '<textarea>\n' + expected + '</textarea>' );
                        assert.equal( $textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + (n + 1) + ')' );
 
-                       $textarea = $('<textarea>').val( expected );
+                       $textarea = $( '<textarea>' ).val( expected );
                        assert.equal( $textarea.val(), expected, 'Expecting ' + n + ' newlines (from DOM set with ' + n + ')' );
                }
-       });
+       } );
 }( jQuery ) );
index ec061a6..9b540a8 100644 (file)
 ( function ( mw, $ ) {
+       var specialCharactersPageName;
+
+       // Since QUnitTestResources.php loads both mediawiki and mediawiki.jqueryMsg as
+       // dependencies, this only tests the monkey-patched behavior with the two of them combined.
+
+       // See mediawiki.jqueryMsg.test.js for unit tests for jqueryMsg-specific functionality.
+
+       QUnit.module( 'mediawiki', QUnit.newMwEnvironment( {
+               setup: function () {
+                       // Messages used in multiple tests
+                       mw.messages.set( {
+                               'other-message': 'Other Message',
+                               'mediawiki-test-pagetriage-del-talk-page-notify-summary': 'Notifying author of deletion nomination for [[$1]]',
+                               'gender-plural-msg': '{{GENDER:$1|he|she|they}} {{PLURAL:$2|is|are}} awesome',
+                               'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
+                               'formatnum-msg': '{{formatnum:$1}}',
+                               'int-msg': 'Some {{int:other-message}}'
+                       } );
 
-var specialCharactersPageName;
+                       // For formatnum tests
+                       mw.config.set( 'wgUserLanguage', 'en' );
 
+                       specialCharactersPageName = '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
+               }
+       } ) );
+
+       QUnit.test( 'Initial check', 8, function ( assert ) {
+               assert.ok( window.jQuery, 'jQuery defined' );
+               assert.ok( window.$, '$j defined' );
+               assert.ok( window.$j, '$j defined' );
+               assert.strictEqual( window.$, window.jQuery, '$ alias to jQuery' );
+               assert.strictEqual( window.$j, window.jQuery, '$j alias to jQuery' );
+
+               assert.ok( window.mediaWiki, 'mediaWiki defined' );
+               assert.ok( window.mw, 'mw defined' );
+               assert.strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
+       } );
+
+       QUnit.test( 'mw.Map', 17, function ( assert ) {
+               var arry, conf, funky, globalConf, nummy, someValues;
+
+               assert.ok( mw.Map, 'mw.Map defined' );
+
+               conf = new mw.Map();
+               // Dummy variables
+               funky = function () {};
+               arry = [];
+               nummy = 7;
+
+               // Tests for input validation
+               assert.strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' );
+               assert.strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' );
+               assert.strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' );
+               assert.strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' );
+               assert.strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' );
+               assert.equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' );
+               assert.strictEqual( conf.get( nummy ), null, 'Map.get ruturns null if selection was invalid (Number)' );
+               assert.strictEqual( conf.get( funky ), null, 'Map.get ruturns null if selection was invalid (Function)' );
+
+               // Multiple values at once
+               someValues = {
+                       'foo': 'bar',
+                       'lorem': 'ipsum',
+                       'MediaWiki': true
+               };
+               assert.strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' );
+               assert.deepEqual( conf.get( ['foo', 'lorem'] ), {
+                       'foo': 'bar',
+                       'lorem': 'ipsum'
+               }, 'Map.get returns multiple values correctly as an object' );
+
+               assert.deepEqual( conf.get( ['foo', 'notExist'] ), {
+                       'foo': 'bar',
+                       'notExist': null
+               }, 'Map.get return includes keys that were not found as null values' );
+
+               assert.strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' );
+               assert.strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' );
+
+               // Interacting with globals and accessing the values object
+               assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
+
+               conf.set( 'globalMapChecker', 'Hi' );
+
+               assert.ok( false === 'globalMapChecker' in window, 'new mw.Map did not store its values in the global window object by default' );
+
+               globalConf = new mw.Map( true );
+               globalConf.set( 'anotherGlobalMapChecker', 'Hello' );
+
+               assert.ok( 'anotherGlobalMapChecker' in window, 'new mw.Map( true ) did store its values in the global window object' );
+
+               // Whitelist this global variable for QUnit's 'noglobal' mode
+               if ( QUnit.config.noglobals ) {
+                       QUnit.config.pollution.push( 'anotherGlobalMapChecker' );
+               }
+       } );
 
-// Since QUnitTestResources.php loads both mediawiki and mediawiki.jqueryMsg as
-// dependencies, this only tests the monkey-patched behavior with the two of them combined.
+       QUnit.test( 'mw.config', 1, function ( assert ) {
+               assert.ok( mw.config instanceof mw.Map, 'mw.config instance of mw.Map' );
+       } );
 
-// See mediawiki.jqueryMsg.test.js for unit tests for jqueryMsg-specific functionality.
+       QUnit.test( 'mw.message & mw.messages', 54, function ( assert ) {
+               var goodbye, hello;
 
-QUnit.module( 'mediawiki', QUnit.newMwEnvironment( {
-       setup: function () {
-               // Messages used in multiple tests
-               mw.messages.set( {
-                       'other-message': 'Other Message',
-                       'mediawiki-test-pagetriage-del-talk-page-notify-summary': 'Notifying author of deletion nomination for [[$1]]',
-                       'gender-plural-msg': '{{GENDER:$1|he|she|they}} {{PLURAL:$2|is|are}} awesome',
-                       'grammar-msg': 'Przeszukaj {{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
-                       'formatnum-msg': '{{formatnum:$1}}',
-                       'int-msg': 'Some {{int:other-message}}'
-               } );
+               // Convenience method for asserting the same result for multiple formats
+               function assertMultipleFormats( messageArguments, formats, expectedResult, assertMessage ) {
+                       var len = formats.length, format, i;
+                       for ( i = 0; i < len; i++ ) {
+                               format = formats[i];
+                               assert.equal( mw.message.apply( null, messageArguments )[format](), expectedResult, assertMessage + ' when format is ' + format );
+                       }
+               }
 
-               // For formatnum tests
-               mw.config.set( 'wgUserLanguage', 'en' );
+               assert.ok( mw.messages, 'messages defined' );
+               assert.ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' );
+               assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
 
-               specialCharactersPageName = '"Who" wants to be a millionaire & live on \'Exotic Island\'?';
-       }
-} ) );
-
-QUnit.test( 'Initial check', 8, function ( assert ) {
-       assert.ok( window.jQuery, 'jQuery defined' );
-       assert.ok( window.$, '$j defined' );
-       assert.ok( window.$j, '$j defined' );
-       assert.strictEqual( window.$, window.jQuery, '$ alias to jQuery' );
-       assert.strictEqual( window.$j, window.jQuery, '$j alias to jQuery' );
-
-       assert.ok( window.mediaWiki, 'mediaWiki defined' );
-       assert.ok( window.mw, 'mw defined' );
-       assert.strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
-});
-
-QUnit.test( 'mw.Map', 17, function ( assert ) {
-       var arry, conf, funky, globalConf, nummy, someValues;
-
-       assert.ok( mw.Map, 'mw.Map defined' );
-
-       conf = new mw.Map();
-       // Dummy variables
-       funky = function () {};
-       arry = [];
-       nummy = 7;
-
-       // Tests for input validation
-       assert.strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' );
-       assert.strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' );
-       assert.strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' );
-       assert.strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' );
-       assert.strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' );
-       assert.equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' );
-       assert.strictEqual( conf.get( nummy ), null, 'Map.get ruturns null if selection was invalid (Number)' );
-       assert.strictEqual( conf.get( funky ), null, 'Map.get ruturns null if selection was invalid (Function)' );
-
-       // Multiple values at once
-       someValues = {
-               'foo': 'bar',
-               'lorem': 'ipsum',
-               'MediaWiki': true
-       };
-       assert.strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' );
-       assert.deepEqual( conf.get( ['foo', 'lorem'] ), {
-               'foo': 'bar',
-               'lorem': 'ipsum'
-       }, 'Map.get returns multiple values correctly as an object' );
-
-       assert.deepEqual( conf.get( ['foo', 'notExist'] ), {
-               'foo': 'bar',
-               'notExist': null
-       }, 'Map.get return includes keys that were not found as null values' );
-
-       assert.strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' );
-       assert.strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' );
-
-       // Interacting with globals and accessing the values object
-       assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
-
-       conf.set( 'globalMapChecker', 'Hi' );
-
-       assert.ok( false === 'globalMapChecker' in window, 'new mw.Map did not store its values in the global window object by default' );
-
-       globalConf = new mw.Map( true );
-       globalConf.set( 'anotherGlobalMapChecker', 'Hello' );
-
-       assert.ok( 'anotherGlobalMapChecker' in window, 'new mw.Map( true ) did store its values in the global window object' );
-
-       // Whitelist this global variable for QUnit's 'noglobal' mode
-       if ( QUnit.config.noglobals ) {
-               QUnit.config.pollution.push( 'anotherGlobalMapChecker' );
-       }
-});
+               hello = mw.message( 'hello' );
 
-QUnit.test( 'mw.config', 1, function ( assert ) {
-       assert.ok( mw.config instanceof mw.Map, 'mw.config instance of mw.Map' );
-});
+               // https://bugzilla.wikimedia.org/show_bug.cgi?id=44459
+               assert.equal( hello.format, 'text', 'Message property "format" defaults to "text"' );
 
-QUnit.test( 'mw.message & mw.messages', 54, function ( assert ) {
-       var goodbye, hello;
+               assert.strictEqual( hello.map, mw.messages, 'Message property "map" defaults to the global instance in mw.messages' );
+               assert.equal( hello.key, 'hello', 'Message property "key" (currect key)' );
+               assert.deepEqual( hello.parameters, [], 'Message property "parameters" defaults to an empty array' );
 
-       // Convenience method for asserting the same result for multiple formats
-       function assertMultipleFormats( messageArguments, formats, expectedResult, assertMessage) {
-               var len = formats.length, format, i;
-               for ( i = 0; i < len; i++ ) {
-                       format = formats[i];
-                       assert.equal( mw.message.apply( null, messageArguments )[format](), expectedResult, assertMessage + ' when format is ' + format);
-               }
-       }
+               // Todo
+               assert.ok( hello.params, 'Message prototype "params"' );
 
-       assert.ok( mw.messages, 'messages defined' );
-       assert.ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' );
-       assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
+               hello.format = 'plain';
+               assert.equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString returns the message as a string with the current "format"' );
 
-       hello = mw.message( 'hello' );
+               assert.equal( hello.escaped(), 'Hello &lt;b&gt;awesome&lt;/b&gt; world', 'Message.escaped returns the escaped message' );
+               assert.equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' );
 
-       // https://bugzilla.wikimedia.org/show_bug.cgi?id=44459
-       assert.equal( hello.format, 'text', 'Message property "format" defaults to "text"' );
+               assert.ok( mw.messages.set( 'escaped-with-curly-brace', '"{{SITENAME}}" is the home of {{int:other-message}}' ) );
+               assert.equal( mw.message( 'escaped-with-curly-brace' ).escaped(), mw.html.escape( '"' + mw.config.get( 'wgSiteName' ) + '" is the home of Other Message' ), 'Escaped format works correctly for curly brace message' );
 
-       assert.strictEqual( hello.map, mw.messages, 'Message property "map" defaults to the global instance in mw.messages' );
-       assert.equal( hello.key, 'hello', 'Message property "key" (currect key)' );
-       assert.deepEqual( hello.parameters, [], 'Message property "parameters" defaults to an empty array' );
+               assert.ok( mw.messages.set( 'escaped-with-square-brackets', 'Visit the [[Project:Community portal|community portal]] & [[Project:Help desk|help desk]]' ) );
+               assert.equal( mw.message( 'escaped-with-square-brackets' ).escaped(), 'Visit the [[Project:Community portal|community portal]] &amp; [[Project:Help desk|help desk]]', 'Escaped format works correctly for square bracket message' );
 
-       // Todo
-       assert.ok( hello.params, 'Message prototype "params"' );
+               hello.parse();
+               assert.equal( hello.format, 'parse', 'Message.parse correctly updated the "format" property' );
 
-       hello.format = 'plain';
-       assert.equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString returns the message as a string with the current "format"' );
+               hello.plain();
+               assert.equal( hello.format, 'plain', 'Message.plain correctly updated the "format" property' );
 
-       assert.equal( hello.escaped(), 'Hello &lt;b&gt;awesome&lt;/b&gt; world', 'Message.escaped returns the escaped message' );
-       assert.equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' );
+               hello.text();
+               assert.equal( hello.format, 'text', 'Message.text correctly updated the "format" property' );
 
-       assert.ok( mw.messages.set( 'escaped-with-curly-brace', '"{{SITENAME}}" is the home of {{int:other-message}}' ) );
-       assert.equal( mw.message( 'escaped-with-curly-brace' ).escaped(), mw.html.escape( '"' + mw.config.get( 'wgSiteName') + '" is the home of Other Message' ), 'Escaped format works correctly for curly brace message' );
+               assert.strictEqual( hello.exists(), true, 'Message.exists returns true for existing messages' );
 
-       assert.ok( mw.messages.set( 'escaped-with-square-brackets', 'Visit the [[Project:Community portal|community portal]] & [[Project:Help desk|help desk]]' ) );
-       assert.equal( mw.message( 'escaped-with-square-brackets' ).escaped(), 'Visit the [[Project:Community portal|community portal]] &amp; [[Project:Help desk|help desk]]', 'Escaped format works correctly for square bracket message' );
+               goodbye = mw.message( 'goodbye' );
+               assert.strictEqual( goodbye.exists(), false, 'Message.exists returns false for nonexistent messages' );
 
-       hello.parse();
-       assert.equal( hello.format, 'parse', 'Message.parse correctly updated the "format" property' );
+               assertMultipleFormats( ['goodbye'], ['plain', 'text'], '<goodbye>', 'Message.toString returns <key> if key does not exist' );
+               // bug 30684
+               assertMultipleFormats( ['goodbye'], ['parse', 'escaped'], '&lt;goodbye&gt;', 'Message.toString returns properly escaped &lt;key&gt; if key does not exist' );
 
-       hello.plain();
-       assert.equal( hello.format, 'plain', 'Message.plain correctly updated the "format" property' );
+               assert.ok( mw.messages.set( 'plural-test-msg', 'There {{PLURAL:$1|is|are}} $1 {{PLURAL:$1|result|results}}' ), 'mw.messages.set: Register' );
+               assertMultipleFormats( ['plural-test-msg', 6], ['text', 'parse', 'escaped'], 'There are 6 results', 'plural get resolved' );
+               assert.equal( mw.message( 'plural-test-msg', 6 ).plain(), 'There {{PLURAL:6|is|are}} 6 {{PLURAL:6|result|results}}', 'Parameter is substituted but plural is not resolved in plain' );
 
-       hello.text();
-       assert.equal( hello.format, 'text', 'Message.text correctly updated the "format" property' );
+               assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary'], ['plain', 'text'], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' );
 
-       assert.strictEqual( hello.exists(), true, 'Message.exists returns true for existing messages' );
+               assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName], ['plain', 'text'], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' );
 
-       goodbye = mw.message( 'goodbye' );
-       assert.strictEqual( goodbye.exists(), false, 'Message.exists returns false for nonexistent messages' );
+               assert.equal( mw.message( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ).escaped(), 'Notifying author of deletion nomination for [[' + mw.html.escape( specialCharactersPageName ) + ']]', 'Double square brackets with one parameter, when escaped' );
 
-       assertMultipleFormats( ['goodbye'], ['plain', 'text'], '<goodbye>', 'Message.toString returns <key> if key does not exist' );
-       // bug 30684
-       assertMultipleFormats( ['goodbye'], ['parse', 'escaped'], '&lt;goodbye&gt;', 'Message.toString returns properly escaped &lt;key&gt; if key does not exist' );
 
-       assert.ok( mw.messages.set( 'plural-test-msg', 'There {{PLURAL:$1|is|are}} $1 {{PLURAL:$1|result|results}}' ), 'mw.messages.set: Register' );
-       assertMultipleFormats( ['plural-test-msg', 6], ['text', 'parse', 'escaped'], 'There are 6 results', 'plural get resolved' );
-       assert.equal( mw.message( 'plural-test-msg', 6 ).plain(), 'There {{PLURAL:6|is|are}} 6 {{PLURAL:6|result|results}}', 'Parameter is substituted but plural is not resolved in plain' );
+               assert.ok( mw.messages.set( 'mediawiki-test-categorytree-collapse-bullet', '[<b>−</b>]' ), 'mw.messages.set: Register' );
+               assert.equal( mw.message( 'mediawiki-test-categorytree-collapse-bullet' ).plain(), mw.messages.get( 'mediawiki-test-categorytree-collapse-bullet' ), 'Single square brackets unchanged in plain mode' );
 
-       assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary'], ['plain', 'text'], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' );
+               assert.ok( mw.messages.set( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result', '<a href=\'#\' title=\'{{#special:mypage}}\'>Username</a> (<a href=\'#\' title=\'{{#special:mytalk}}\'>talk</a>)' ) );
+               assert.equal( mw.message( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ).plain(), mw.messages.get( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ), 'HTML message with curly braces is not changed in plain mode' );
 
-       assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName], ['plain', 'text'], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' );
+               assertMultipleFormats( ['gender-plural-msg', 'male', 1], ['text', 'parse', 'escaped'], 'he is awesome', 'Gender and plural are resolved' );
+               assert.equal( mw.message( 'gender-plural-msg', 'male', 1 ).plain(), '{{GENDER:male|he|she|they}} {{PLURAL:1|is|are}} awesome', 'Parameters are substituted, but gender and plural are not resolved in plain mode' );
 
-       assert.equal( mw.message( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ).escaped(), 'Notifying author of deletion nomination for [[' + mw.html.escape( specialCharactersPageName ) + ']]', 'Double square brackets with one parameter, when escaped' );
+               assert.equal( mw.message( 'grammar-msg' ).plain(), mw.messages.get( 'grammar-msg' ), 'Grammar is not resolved in plain mode' );
+               assertMultipleFormats( ['grammar-msg'], ['text', 'parse'], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar is resolved' );
+               assert.equal( mw.message( 'grammar-msg' ).escaped(), 'Przeszukaj ' + mw.html.escape( mw.config.get( 'wgSiteName' ) ), 'Grammar is resolved in escaped mode' );
 
+               assertMultipleFormats( ['formatnum-msg', '987654321.654321'], ['text', 'parse', 'escaped'], '987654321.654321', 'formatnum is resolved' );
+               assert.equal( mw.message( 'formatnum-msg' ).plain(), mw.messages.get( 'formatnum-msg' ), 'formatnum is not resolved in plain mode' );
 
-       assert.ok( mw.messages.set( 'mediawiki-test-categorytree-collapse-bullet', '[<b>−</b>]' ), 'mw.messages.set: Register' );
-       assert.equal( mw.message( 'mediawiki-test-categorytree-collapse-bullet' ).plain(), mw.messages.get( 'mediawiki-test-categorytree-collapse-bullet' ), 'Single square brackets unchanged in plain mode' );
+               assertMultipleFormats( ['int-msg'], ['text', 'parse', 'escaped'], 'Some Other Message', 'int is resolved' );
+               assert.equal( mw.message( 'int-msg' ).plain(), mw.messages.get( 'int-msg' ), 'int is not resolved in plain mode' );
+       } );
 
-       assert.ok( mw.messages.set( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result', '<a href=\'#\' title=\'{{#special:mypage}}\'>Username</a> (<a href=\'#\' title=\'{{#special:mytalk}}\'>talk</a>)' ) );
-       assert.equal( mw.message( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ).plain(), mw.messages.get( 'mediawiki-test-wikieditor-toolbar-help-content-signature-result' ), 'HTML message with curly braces is not changed in plain mode' );
+       QUnit.test( 'mw.msg', 14, function ( assert ) {
+               assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
+               assert.equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' );
+               assert.equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (nonexistent message)' );
 
-       assertMultipleFormats( ['gender-plural-msg', 'male', 1], ['text', 'parse', 'escaped'], 'he is awesome', 'Gender and plural are resolved' );
-       assert.equal( mw.message( 'gender-plural-msg', 'male', 1 ).plain(), '{{GENDER:male|he|she|they}} {{PLURAL:1|is|are}} awesome', 'Parameters are substituted, but gender and plural are not resolved in plain mode' );
+               assert.ok( mw.messages.set( 'plural-item', 'Found $1 {{PLURAL:$1|item|items}}' ) );
+               assert.equal( mw.msg( 'plural-item', 5 ), 'Found 5 items', 'Apply plural for count 5' );
+               assert.equal( mw.msg( 'plural-item', 0 ), 'Found 0 items', 'Apply plural for count 0' );
+               assert.equal( mw.msg( 'plural-item', 1 ), 'Found 1 item', 'Apply plural for count 1' );
 
-       assert.equal( mw.message( 'grammar-msg' ).plain(), mw.messages.get( 'grammar-msg' ), 'Grammar is not resolved in plain mode' );
-       assertMultipleFormats( ['grammar-msg'], ['text', 'parse'], 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar is resolved' );
-       assert.equal( mw.message( 'grammar-msg' ).escaped(), 'Przeszukaj ' + mw.html.escape( mw.config.get( 'wgSiteName' ) ), 'Grammar is resolved in escaped mode' );
+               assert.equal( mw.msg( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ), 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets in mw.msg one parameter' );
 
-       assertMultipleFormats( ['formatnum-msg', '987654321.654321'], ['text', 'parse', 'escaped'], '987654321.654321', 'formatnum is resolved' );
-       assert.equal( mw.message( 'formatnum-msg' ).plain(), mw.messages.get( 'formatnum-msg' ), 'formatnum is not resolved in plain mode' );
+               assert.equal( mw.msg( 'gender-plural-msg', 'male', 1 ), 'he is awesome', 'Gender test for male, plural count 1' );
+               assert.equal( mw.msg( 'gender-plural-msg', 'female', '1' ), 'she is awesome', 'Gender test for female, plural count 1' );
+               assert.equal( mw.msg( 'gender-plural-msg', 'unknown', 10 ), 'they are awesome', 'Gender test for neutral, plural count 10' );
 
-       assertMultipleFormats( ['int-msg'], ['text', 'parse', 'escaped'], 'Some Other Message', 'int is resolved' );
-       assert.equal( mw.message( 'int-msg' ).plain(), mw.messages.get( 'int-msg' ), 'int is not resolved in plain mode' );
-});
+               assert.equal( mw.msg( 'grammar-msg' ), 'Przeszukaj ' + mw.config.get( 'wgSiteName' ), 'Grammar is resolved' );
 
-QUnit.test( 'mw.msg', 14, function ( assert ) {
-       assert.ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
-       assert.equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' );
-       assert.equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (nonexistent message)' );
+               assert.equal( mw.msg( 'formatnum-msg', '987654321.654321' ), '987654321.654321', 'formatnum is resolved' );
 
-       assert.ok( mw.messages.set( 'plural-item' , 'Found $1 {{PLURAL:$1|item|items}}' ) );
-       assert.equal( mw.msg( 'plural-item', 5 ), 'Found 5 items', 'Apply plural for count 5' );
-       assert.equal( mw.msg( 'plural-item', 0 ), 'Found 0 items', 'Apply plural for count 0' );
-       assert.equal( mw.msg( 'plural-item', 1 ), 'Found 1 item', 'Apply plural for count 1' );
+               assert.equal( mw.msg( 'int-msg' ), 'Some Other Message', 'int is resolved' );
+       } );
 
-       assert.equal( mw.msg( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ), 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets in mw.msg one parameter' );
+       /**
+        * The sync style load test (for @import). This is, in a way, also an open bug for
+        * ResourceLoader ("execute js after styles are loaded"), but browsers don't offer a
+        * way to get a callback from when a stylesheet is loaded (that is, including any
+        * @import rules inside). To work around this, we'll have a little time loop to check
+        * if the styles apply.
+        * Note: This test originally used new Image() and onerror to get a callback
+        * when the url is loaded, but that is fragile since it doesn't monitor the
+        * same request as the css @import, and Safari 4 has issues with
+        * onerror/onload not being fired at all in weird cases like this.
+        */
+       function assertStyleAsync( assert, $element, prop, val, fn ) {
+               var styleTestStart,
+                       el = $element.get( 0 ),
+                       styleTestTimeout = ( QUnit.config.testTimeout - 200 ) || 5000;
 
-       assert.equal( mw.msg( 'gender-plural-msg', 'male', 1 ), 'he is awesome', 'Gender test for male, plural count 1' );
-       assert.equal( mw.msg( 'gender-plural-msg', 'female', '1' ), 'she is awesome', 'Gender test for female, plural count 1' );
-       assert.equal( mw.msg( 'gender-plural-msg', 'unknown', 10 ), 'they are awesome', 'Gender test for neutral, plural count 10' );
+               function isCssImportApplied() {
+                       // Trigger reflow, repaint, redraw, whatever (cross-browser)
+                       var x = $element.css( 'height' );
+                       x = el.innerHTML;
+                       el.className = el.className;
+                       x = document.documentElement.clientHeight;
 
-       assert.equal( mw.msg( 'grammar-msg' ), 'Przeszukaj ' + mw.config.get( 'wgSiteName'), 'Grammar is resolved' );
+                       return $element.css( prop ) === val;
+               }
 
-       assert.equal( mw.msg( 'formatnum-msg', '987654321.654321' ), '987654321.654321', 'formatnum is resolved' );
+               function styleTestLoop() {
+                       var styleTestSince = new Date().getTime() - styleTestStart;
+                       // If it is passing or if we timed out, run the real test and stop the loop
+                       if ( isCssImportApplied() || styleTestSince > styleTestTimeout ) {
+                               assert.equal( $element.css( prop ), val,
+                                       'style "' + prop + ': ' + val + '" from url is applied (after ' + styleTestSince + 'ms)'
+                               );
 
-       assert.equal( mw.msg( 'int-msg' ), 'Some Other Message', 'int is resolved' );
-});
+                               if ( fn ) {
+                                       fn();
+                               }
 
-/**
- * The sync style load test (for @import). This is, in a way, also an open bug for
- * ResourceLoader ("execute js after styles are loaded"), but browsers don't offer a
- * way to get a callback from when a stylesheet is loaded (that is, including any
- * @import rules inside). To work around this, we'll have a little time loop to check
- * if the styles apply.
- * Note: This test originally used new Image() and onerror to get a callback
- * when the url is loaded, but that is fragile since it doesn't monitor the
- * same request as the css @import, and Safari 4 has issues with
- * onerror/onload not being fired at all in weird cases like this.
- */
-function assertStyleAsync( assert, $element, prop, val, fn ) {
-       var styleTestStart,
-               el = $element.get( 0 ),
-               styleTestTimeout = ( QUnit.config.testTimeout - 200 ) || 5000;
+                               return;
+                       }
+                       // Otherwise, keep polling
+                       setTimeout( styleTestLoop, 150 );
+               }
 
-       function isCssImportApplied() {
-               // Trigger reflow, repaint, redraw, whatever (cross-browser)
-               var x = $element.css( 'height' );
-               x = el.innerHTML;
-               el.className = el.className;
-               x = document.documentElement.clientHeight;
+               // Start the loop
+               styleTestStart = new Date().getTime();
+               styleTestLoop();
+       }
 
-               return $element.css( prop ) === val;
+       function urlStyleTest( selector, prop, val ) {
+               return QUnit.fixurl(
+                       mw.config.get( 'wgScriptPath' ) +
+                               '/tests/qunit/data/styleTest.css.php?' +
+                               $.param( {
+                                       selector: selector,
+                                       prop: prop,
+                                       val: val
+                               } )
+               );
        }
 
-       function styleTestLoop() {
-               var styleTestSince = new Date().getTime() - styleTestStart;
-               // If it is passing or if we timed out, run the real test and stop the loop
-               if ( isCssImportApplied() || styleTestSince > styleTestTimeout ) {
-                       assert.equal( $element.css( prop ), val,
-                               'style "' + prop + ': ' + val + '" from url is applied (after ' + styleTestSince + 'ms)'
-                       );
+       QUnit.asyncTest( 'mw.loader', 2, function ( assert ) {
+               var isAwesomeDone;
 
-                       if ( fn ) {
-                               fn();
-                       }
+               mw.loader.testCallback = function () {
+                       QUnit.start();
+                       assert.strictEqual( isAwesomeDone, undefined, 'Implementing module is.awesome: isAwesomeDone should still be undefined' );
+                       isAwesomeDone = true;
+               };
 
-                       return;
-               }
-               // Otherwise, keep polling
-               setTimeout( styleTestLoop, 150 );
-       }
+               mw.loader.implement( 'test.callback', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} );
 
-       // Start the loop
-       styleTestStart = new Date().getTime();
-       styleTestLoop();
-}
-
-function urlStyleTest( selector, prop, val ) {
-       return QUnit.fixurl(
-               mw.config.get( 'wgScriptPath' ) +
-                       '/tests/qunit/data/styleTest.css.php?' +
-                       $.param( {
-                               selector: selector,
-                               prop: prop,
-                               val: val
-                       } )
-       );
-}
-
-QUnit.asyncTest( 'mw.loader', 2, function ( assert ) {
-       var isAwesomeDone;
-
-       mw.loader.testCallback = function () {
-               QUnit.start();
-               assert.strictEqual( isAwesomeDone, undefined, 'Implementing module is.awesome: isAwesomeDone should still be undefined');
-               isAwesomeDone = true;
-       };
-
-       mw.loader.implement( 'test.callback', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} );
-
-       mw.loader.using( 'test.callback', function () {
-
-               // /sample/awesome.js declares the "mw.loader.testCallback" function
-               // which contains a call to start() and ok()
-               assert.strictEqual( isAwesomeDone, true, 'test.callback module should\'ve caused isAwesomeDone to be true' );
-               delete mw.loader.testCallback;
-
-       }, function () {
-               QUnit.start();
-               assert.ok( false, 'Error callback fired while loader.using "test.callback" module' );
-       });
-});
-
-QUnit.test( 'mw.loader.implement( styles={ "css": [text, ..] } )', 2, function ( assert ) {
-       var $element = $( '<div class="mw-test-implement-a"></div>' ).appendTo( '#qunit-fixture' );
-
-       assert.notEqual(
-               $element.css( 'float' ),
-               'right',
-               'style is clear'
-       );
-
-       mw.loader.implement(
-               'test.implement.a',
-               function () {
-                       assert.equal(
-                               $element.css( 'float' ),
-                               'right',
-                               'style is applied'
-                       );
-               },
-               {
-                       'all': '.mw-test-implement-a { float: right; }'
-               },
-               {}
-       );
-
-       mw.loader.load([
-               'test.implement.a'
-       ]);
-} );
-
-QUnit.asyncTest( 'mw.loader.implement( styles={ "url": { <media>: [url, ..] } } )', 7, function ( assert ) {
-       var $element1 = $( '<div class="mw-test-implement-b1"></div>' ).appendTo( '#qunit-fixture' ),
-               $element2 = $( '<div class="mw-test-implement-b2"></div>' ).appendTo( '#qunit-fixture' ),
-               $element3 = $( '<div class="mw-test-implement-b3"></div>' ).appendTo( '#qunit-fixture' );
-
-       assert.notEqual(
-               $element1.css( 'text-align' ),
-               'center',
-               'style is clear'
-       );
-       assert.notEqual(
-               $element2.css( 'float' ),
-               'left',
-               'style is clear'
-       );
-       assert.notEqual(
-               $element3.css( 'text-align' ),
-               'right',
-               'style is clear'
-       );
-
-       mw.loader.implement(
-               'test.implement.b',
-               function () {
-                       // Note: QUnit.start() must only be called when the entire test is
-                       // complete. So, make sure that we don't start until *both*
-                       // assertStyleAsync calls have completed.
-                       var pending = 2;
-                       assertStyleAsync( assert, $element2, 'float', 'left', function () {
-                               assert.notEqual( $element1.css( 'text-align' ), 'center', 'print style is not applied' );
-
-                               pending--;
-                               if ( pending === 0 ) {
-                                       QUnit.start();
-                               }
-                       } );
-                       assertStyleAsync( assert, $element3, 'float', 'right', function () {
-                               assert.notEqual( $element1.css( 'text-align' ), 'center', 'print style is not applied' );
+               mw.loader.using( 'test.callback', function () {
 
-                               pending--;
-                               if ( pending === 0 ) {
-                                       QUnit.start();
+                       // /sample/awesome.js declares the "mw.loader.testCallback" function
+                       // which contains a call to start() and ok()
+                       assert.strictEqual( isAwesomeDone, true, 'test.callback module should\'ve caused isAwesomeDone to be true' );
+                       delete mw.loader.testCallback;
+
+               }, function () {
+                       QUnit.start();
+                       assert.ok( false, 'Error callback fired while loader.using "test.callback" module' );
+               } );
+       } );
+
+       QUnit.test( 'mw.loader.implement( styles={ "css": [text, ..] } )', 2, function ( assert ) {
+               var $element = $( '<div class="mw-test-implement-a"></div>' ).appendTo( '#qunit-fixture' );
+
+               assert.notEqual(
+                       $element.css( 'float' ),
+                       'right',
+                       'style is clear'
+               );
+
+               mw.loader.implement(
+                       'test.implement.a',
+                       function () {
+                               assert.equal(
+                                       $element.css( 'float' ),
+                                       'right',
+                                       'style is applied'
+                               );
+                       },
+                       {
+                               'all': '.mw-test-implement-a { float: right; }'
+                       },
+                       {}
+               );
+
+               mw.loader.load( [
+                       'test.implement.a'
+               ] );
+       } );
+
+       QUnit.asyncTest( 'mw.loader.implement( styles={ "url": { <media>: [url, ..] } } )', 7, function ( assert ) {
+               var $element1 = $( '<div class="mw-test-implement-b1"></div>' ).appendTo( '#qunit-fixture' ),
+                       $element2 = $( '<div class="mw-test-implement-b2"></div>' ).appendTo( '#qunit-fixture' ),
+                       $element3 = $( '<div class="mw-test-implement-b3"></div>' ).appendTo( '#qunit-fixture' );
+
+               assert.notEqual(
+                       $element1.css( 'text-align' ),
+                       'center',
+                       'style is clear'
+               );
+               assert.notEqual(
+                       $element2.css( 'float' ),
+                       'left',
+                       'style is clear'
+               );
+               assert.notEqual(
+                       $element3.css( 'text-align' ),
+                       'right',
+                       'style is clear'
+               );
+
+               mw.loader.implement(
+                       'test.implement.b',
+                       function () {
+                               // Note: QUnit.start() must only be called when the entire test is
+                               // complete. So, make sure that we don't start until *both*
+                               // assertStyleAsync calls have completed.
+                               var pending = 2;
+                               assertStyleAsync( assert, $element2, 'float', 'left', function () {
+                                       assert.notEqual( $element1.css( 'text-align' ), 'center', 'print style is not applied' );
+
+                                       pending--;
+                                       if ( pending === 0 ) {
+                                               QUnit.start();
+                                       }
+                               } );
+                               assertStyleAsync( assert, $element3, 'float', 'right', function () {
+                                       assert.notEqual( $element1.css( 'text-align' ), 'center', 'print style is not applied' );
+
+                                       pending--;
+                                       if ( pending === 0 ) {
+                                               QUnit.start();
+                                       }
+                               } );
+                       },
+                       {
+                               'url': {
+                                       'print': [urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' )],
+                                       'screen': [
+                                               // bug 40834: Make sure it actually works with more than 1 stylesheet reference
+                                               urlStyleTest( '.mw-test-implement-b2', 'float', 'left' ),
+                                               urlStyleTest( '.mw-test-implement-b3', 'float', 'right' )
+                                       ]
                                }
-                       } );
-               },
-               {
-                       'url': {
-                               'print': [urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' )],
-                               'screen': [
-                                       // bug 40834: Make sure it actually works with more than 1 stylesheet reference
-                                       urlStyleTest( '.mw-test-implement-b2', 'float', 'left' ),
-                                       urlStyleTest( '.mw-test-implement-b3', 'float', 'right' )
-                               ]
-                       }
-               },
-               {}
-       );
+                       },
+                       {}
+               );
 
-       mw.loader.load([
-               'test.implement.b'
-       ]);
-} );
+               mw.loader.load( [
+                       'test.implement.b'
+               ] );
+       } );
 
 // Backwards compatibility
-QUnit.test( 'mw.loader.implement( styles={ <media>: text } ) (back-compat)', 2, function ( assert ) {
-       var $element = $( '<div class="mw-test-implement-c"></div>' ).appendTo( '#qunit-fixture' );
-
-       assert.notEqual(
-               $element.css( 'float' ),
-               'right',
-               'style is clear'
-       );
-
-       mw.loader.implement(
-               'test.implement.c',
-               function () {
-                       assert.equal(
-                               $element.css( 'float' ),
-                               'right',
-                               'style is applied'
-                       );
-               },
-               {
-                       'all': '.mw-test-implement-c { float: right; }'
-               },
-               {}
-       );
-
-       mw.loader.load([
-               'test.implement.c'
-       ]);
-} );
+       QUnit.test( 'mw.loader.implement( styles={ <media>: text } ) (back-compat)', 2, function ( assert ) {
+               var $element = $( '<div class="mw-test-implement-c"></div>' ).appendTo( '#qunit-fixture' );
+
+               assert.notEqual(
+                       $element.css( 'float' ),
+                       'right',
+                       'style is clear'
+               );
+
+               mw.loader.implement(
+                       'test.implement.c',
+                       function () {
+                               assert.equal(
+                                       $element.css( 'float' ),
+                                       'right',
+                                       'style is applied'
+                               );
+                       },
+                       {
+                               'all': '.mw-test-implement-c { float: right; }'
+                       },
+                       {}
+               );
+
+               mw.loader.load( [
+                       'test.implement.c'
+               ] );
+       } );
 
 // Backwards compatibility
-QUnit.asyncTest( 'mw.loader.implement( styles={ <media>: [url, ..] } ) (back-compat)', 4, function ( assert ) {
-       var $element = $( '<div class="mw-test-implement-d"></div>' ).appendTo( '#qunit-fixture' ),
-               $element2 = $( '<div class="mw-test-implement-d2"></div>' ).appendTo( '#qunit-fixture' );
-
-       assert.notEqual(
-               $element.css( 'float' ),
-               'right',
-               'style is clear'
-       );
-       assert.notEqual(
-               $element2.css( 'text-align' ),
-               'center',
-               'style is clear'
-       );
-
-       mw.loader.implement(
-               'test.implement.d',
-               function () {
-                       assertStyleAsync( assert, $element, 'float', 'right', function () {
-
-                               assert.notEqual( $element2.css( 'text-align' ), 'center', 'print style is not applied (bug 40500)' );
+       QUnit.asyncTest( 'mw.loader.implement( styles={ <media>: [url, ..] } ) (back-compat)', 4, function ( assert ) {
+               var $element = $( '<div class="mw-test-implement-d"></div>' ).appendTo( '#qunit-fixture' ),
+                       $element2 = $( '<div class="mw-test-implement-d2"></div>' ).appendTo( '#qunit-fixture' );
+
+               assert.notEqual(
+                       $element.css( 'float' ),
+                       'right',
+                       'style is clear'
+               );
+               assert.notEqual(
+                       $element2.css( 'text-align' ),
+                       'center',
+                       'style is clear'
+               );
+
+               mw.loader.implement(
+                       'test.implement.d',
+                       function () {
+                               assertStyleAsync( assert, $element, 'float', 'right', function () {
+
+                                       assert.notEqual( $element2.css( 'text-align' ), 'center', 'print style is not applied (bug 40500)' );
 
-                               QUnit.start();
-                       } );
-               },
-               {
-                       'all': [urlStyleTest( '.mw-test-implement-d', 'float', 'right' )],
-                       'print': [urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' )]
-               },
-               {}
-       );
-
-       mw.loader.load([
-               'test.implement.d'
-       ]);
-} );
+                                       QUnit.start();
+                               } );
+                       },
+                       {
+                               'all': [urlStyleTest( '.mw-test-implement-d', 'float', 'right' )],
+                               'print': [urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' )]
+                       },
+                       {}
+               );
+
+               mw.loader.load( [
+                       'test.implement.d'
+               ] );
+       } );
 
 // @import (bug 31676)
-QUnit.asyncTest( 'mw.loader.implement( styles has @import)', 5, function ( assert ) {
-       var isJsExecuted, $element;
-
-       mw.loader.implement(
-               'test.implement.import',
-               function () {
-                       assert.strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
-                       isJsExecuted = true;
+       QUnit.asyncTest( 'mw.loader.implement( styles has @import)', 5, function ( assert ) {
+               var isJsExecuted, $element;
 
-                       assert.equal( mw.loader.getState( 'test.implement.import' ), 'ready', 'module state is "ready" while implement() is executing javascript' );
+               mw.loader.implement(
+                       'test.implement.import',
+                       function () {
+                               assert.strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' );
+                               isJsExecuted = true;
 
-                       $element = $( '<div class="mw-test-implement-import">Foo bar</div>' ).appendTo( '#qunit-fixture' );
+                               assert.equal( mw.loader.getState( 'test.implement.import' ), 'ready', 'module state is "ready" while implement() is executing javascript' );
 
-                       assert.equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded before javascript execution' );
+                               $element = $( '<div class="mw-test-implement-import">Foo bar</div>' ).appendTo( '#qunit-fixture' );
 
-                       assertStyleAsync( assert, $element, 'float', 'right', function () {
-                               assert.equal( $element.css( 'text-align' ),'center',
-                                       'CSS styles after the @import rule are working'
-                               );
+                               assert.equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded before javascript execution' );
 
-                               QUnit.start();
-                       } );
-               },
-               {
-                       'css': [
-                               '@import url(\''
-                               + urlStyleTest( '.mw-test-implement-import', 'float', 'right' )
-                               + '\');\n'
-                               + '.mw-test-implement-import { text-align: center; }'
-                       ]
-               },
-               {
-                       'test-foobar': 'Hello Foobar, $1!'
-               }
-       );
-
-       mw.loader.load( 'test.implement' );
-
-});
-
-QUnit.asyncTest( 'mw.loader.implement( only messages )' , 2, function ( assert ) {
-       assert.assertFalse( mw.messages.exists( 'bug_29107' ), 'Verify that the test message doesn\'t exist yet' );
-
-       mw.loader.implement( 'test.implement.msgs', [], {}, { 'bug_29107': 'loaded' } );
-       mw.loader.using( 'test.implement.msgs', function() {
-               QUnit.start();
-               assert.ok( mw.messages.exists( 'bug_29107' ), 'Bug 29107: messages-only module should implement ok' );
-       }, function() {
-               QUnit.start();
-               assert.ok( false, 'Error callback fired while implementing "test.implement.msgs" module' );
-       });
-});
-
-QUnit.test( 'mw.loader erroneous indirect dependency', 3, function ( assert ) {
-       mw.loader.register( [
-               ['test.module1', '0'],
-               ['test.module2', '0', ['test.module1']],
-               ['test.module3', '0', ['test.module2']]
-       ] );
-       mw.loader.implement( 'test.module1', function () { throw new Error( 'expected' ); }, {}, {} );
-       assert.strictEqual( mw.loader.getState( 'test.module1' ), 'error', 'Expected "error" state for test.module1' );
-       assert.strictEqual( mw.loader.getState( 'test.module2' ), 'error', 'Expected "error" state for test.module2' );
-       assert.strictEqual( mw.loader.getState( 'test.module3' ), 'error', 'Expected "error" state for test.module3' );
-} );
-
-QUnit.test( 'mw.loader out-of-order implementation', 9, function ( assert ) {
-       mw.loader.register( [
-               ['test.module4', '0'],
-               ['test.module5', '0', ['test.module4']],
-               ['test.module6', '0', ['test.module5']]
-       ] );
-       mw.loader.implement( 'test.module4', function () {}, {}, {} );
-       assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-       assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
-       assert.strictEqual( mw.loader.getState( 'test.module6' ), 'registered', 'Expected "registered" state for test.module6' );
-       mw.loader.implement( 'test.module6', function () {}, {}, {} );
-       assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-       assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
-       assert.strictEqual( mw.loader.getState( 'test.module6' ), 'loaded', 'Expected "loaded" state for test.module6' );
-       mw.loader.implement( 'test.module5', function() {}, {}, {} );
-       assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
-       assert.strictEqual( mw.loader.getState( 'test.module5' ), 'ready', 'Expected "ready" state for test.module5' );
-       assert.strictEqual( mw.loader.getState( 'test.module6' ), 'ready', 'Expected "ready" state for test.module6' );
-} );
-
-QUnit.test( 'mw.loader missing dependency', 13, function ( assert ) {
-       mw.loader.register( [
-               ['test.module7', '0'],
-               ['test.module8', '0', ['test.module7']],
-               ['test.module9', '0', ['test.module8']]
-       ] );
-       mw.loader.implement( 'test.module8', function () {}, {}, {} );
-       assert.strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' );
-       assert.strictEqual( mw.loader.getState( 'test.module8' ), 'loaded', 'Expected "loaded" state for test.module8' );
-       assert.strictEqual( mw.loader.getState( 'test.module9' ), 'registered', 'Expected "registered" state for test.module9' );
-       mw.loader.state( 'test.module7', 'missing' );
-       assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
-       assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
-       assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
-       mw.loader.implement( 'test.module9', function () {}, {}, {} );
-       assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
-       assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
-       assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
-       mw.loader.using(
-               ['test.module7'],
-               function () {
-                       assert.ok( false, 'Success fired despite missing dependency' );
-                       assert.ok( true , 'QUnit expected() count dummy' );
-               },
-               function ( e, dependencies ) {
-                       assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
-                       assert.deepEqual( dependencies, ['test.module7'], 'Error callback called with module test.module7' );
-               }
-       );
-       mw.loader.using(
-               ['test.module9'],
-               function () {
-                       assert.ok( false, 'Success fired despite missing dependency' );
-                       assert.ok( true , 'QUnit expected() count dummy' );
-               },
-               function ( e, dependencies ) {
-                       assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
-                       dependencies.sort();
-                       assert.deepEqual(
-                               dependencies,
-                               ['test.module7', 'test.module8', 'test.module9'],
-                               'Error callback called with all three modules as dependencies'
-                       );
-               }
-       );
-} );
-
-QUnit.asyncTest( 'mw.loader dependency handling', 5, function ( assert ) {
-       mw.loader.addSource(
-               'testloader',
-               {
-                       loadScript: QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/load.mock.php' )
-               }
-       );
-
-       mw.loader.register( [
-               // [module, version, dependencies, group, source]
-               ['testMissing', '1', [], null, 'testloader'],
-               ['testUsesMissing', '1', ['testMissing'], null, 'testloader'],
-               ['testUsesNestedMissing', '1', ['testUsesMissing'], null, 'testloader']
-       ] );
-
-       function verifyModuleStates() {
-               assert.equal( mw.loader.getState( 'testMissing' ), 'missing', 'Module not known to server must have state "missing"' );
-               assert.equal( mw.loader.getState( 'testUsesMissing' ), 'error', 'Module with missing dependency must have state "error"' );
-               assert.equal( mw.loader.getState( 'testUsesNestedMissing' ), 'error', 'Module with indirect missing dependency must have state "error"' );
-       }
+                               assertStyleAsync( assert, $element, 'float', 'right', function () {
+                                       assert.equal( $element.css( 'text-align' ), 'center',
+                                               'CSS styles after the @import rule are working'
+                                       );
 
-       mw.loader.using( ['testUsesNestedMissing'],
-               function () {
-                       assert.ok( false, 'Error handler should be invoked.' );
-                       assert.ok( true ); // Dummy to reach QUnit expect()
+                                       QUnit.start();
+                               } );
+                       },
+                       {
+                               'css': [
+                                       '@import url(\''
+                                               + urlStyleTest( '.mw-test-implement-import', 'float', 'right' )
+                                               + '\');\n'
+                                               + '.mw-test-implement-import { text-align: center; }'
+                               ]
+                       },
+                       {
+                               'test-foobar': 'Hello Foobar, $1!'
+                       }
+               );
 
-                       verifyModuleStates();
+               mw.loader.load( 'test.implement' );
 
-                       QUnit.start();
-               },
-               function ( e, badmodules ) {
-                       assert.ok( true, 'Error handler should be invoked.' );
-                       // As soon as server spits out state('testMissing', 'missing');
-                       // it will bubble up and trigger the error callback.
-                       // Therefor the badmodules array is not testUsesMissing or testUsesNestedMissing.
-                       assert.deepEqual( badmodules, ['testMissing'], 'Bad modules as expected.' );
+       } );
 
-                       verifyModuleStates();
+       QUnit.asyncTest( 'mw.loader.implement( only messages )', 2, function ( assert ) {
+               assert.assertFalse( mw.messages.exists( 'bug_29107' ), 'Verify that the test message doesn\'t exist yet' );
 
+               mw.loader.implement( 'test.implement.msgs', [], {}, { 'bug_29107': 'loaded' } );
+               mw.loader.using( 'test.implement.msgs', function () {
                        QUnit.start();
+                       assert.ok( mw.messages.exists( 'bug_29107' ), 'Bug 29107: messages-only module should implement ok' );
+               }, function () {
+                       QUnit.start();
+                       assert.ok( false, 'Error callback fired while implementing "test.implement.msgs" module' );
+               } );
+       } );
+
+       QUnit.test( 'mw.loader erroneous indirect dependency', 3, function ( assert ) {
+               mw.loader.register( [
+                       ['test.module1', '0'],
+                       ['test.module2', '0', ['test.module1']],
+                       ['test.module3', '0', ['test.module2']]
+               ] );
+               mw.loader.implement( 'test.module1', function () {
+                       throw new Error( 'expected' );
+               }, {}, {} );
+               assert.strictEqual( mw.loader.getState( 'test.module1' ), 'error', 'Expected "error" state for test.module1' );
+               assert.strictEqual( mw.loader.getState( 'test.module2' ), 'error', 'Expected "error" state for test.module2' );
+               assert.strictEqual( mw.loader.getState( 'test.module3' ), 'error', 'Expected "error" state for test.module3' );
+       } );
+
+       QUnit.test( 'mw.loader out-of-order implementation', 9, function ( assert ) {
+               mw.loader.register( [
+                       ['test.module4', '0'],
+                       ['test.module5', '0', ['test.module4']],
+                       ['test.module6', '0', ['test.module5']]
+               ] );
+               mw.loader.implement( 'test.module4', function () {
+               }, {}, {} );
+               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
+               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
+               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'registered', 'Expected "registered" state for test.module6' );
+               mw.loader.implement( 'test.module6', function () {
+               }, {}, {} );
+               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
+               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'registered', 'Expected "registered" state for test.module5' );
+               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'loaded', 'Expected "loaded" state for test.module6' );
+               mw.loader.implement( 'test.module5', function () {
+               }, {}, {} );
+               assert.strictEqual( mw.loader.getState( 'test.module4' ), 'ready', 'Expected "ready" state for test.module4' );
+               assert.strictEqual( mw.loader.getState( 'test.module5' ), 'ready', 'Expected "ready" state for test.module5' );
+               assert.strictEqual( mw.loader.getState( 'test.module6' ), 'ready', 'Expected "ready" state for test.module6' );
+       } );
+
+       QUnit.test( 'mw.loader missing dependency', 13, function ( assert ) {
+               mw.loader.register( [
+                       ['test.module7', '0'],
+                       ['test.module8', '0', ['test.module7']],
+                       ['test.module9', '0', ['test.module8']]
+               ] );
+               mw.loader.implement( 'test.module8', function () {
+               }, {}, {} );
+               assert.strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' );
+               assert.strictEqual( mw.loader.getState( 'test.module8' ), 'loaded', 'Expected "loaded" state for test.module8' );
+               assert.strictEqual( mw.loader.getState( 'test.module9' ), 'registered', 'Expected "registered" state for test.module9' );
+               mw.loader.state( 'test.module7', 'missing' );
+               assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
+               assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
+               assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
+               mw.loader.implement( 'test.module9', function () {
+               }, {}, {} );
+               assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
+               assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
+               assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
+               mw.loader.using(
+                       ['test.module7'],
+                       function () {
+                               assert.ok( false, 'Success fired despite missing dependency' );
+                               assert.ok( true, 'QUnit expected() count dummy' );
+                       },
+                       function ( e, dependencies ) {
+                               assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
+                               assert.deepEqual( dependencies, ['test.module7'], 'Error callback called with module test.module7' );
+                       }
+               );
+               mw.loader.using(
+                       ['test.module9'],
+                       function () {
+                               assert.ok( false, 'Success fired despite missing dependency' );
+                               assert.ok( true, 'QUnit expected() count dummy' );
+                       },
+                       function ( e, dependencies ) {
+                               assert.strictEqual( $.isArray( dependencies ), true, 'Expected array of dependencies' );
+                               dependencies.sort();
+                               assert.deepEqual(
+                                       dependencies,
+                                       ['test.module7', 'test.module8', 'test.module9'],
+                                       'Error callback called with all three modules as dependencies'
+                               );
+                       }
+               );
+       } );
+
+       QUnit.asyncTest( 'mw.loader dependency handling', 5, function ( assert ) {
+               mw.loader.addSource(
+                       'testloader',
+                       {
+                               loadScript: QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/load.mock.php' )
+                       }
+               );
+
+               mw.loader.register( [
+                       // [module, version, dependencies, group, source]
+                       ['testMissing', '1', [], null, 'testloader'],
+                       ['testUsesMissing', '1', ['testMissing'], null, 'testloader'],
+                       ['testUsesNestedMissing', '1', ['testUsesMissing'], null, 'testloader']
+               ] );
+
+               function verifyModuleStates() {
+                       assert.equal( mw.loader.getState( 'testMissing' ), 'missing', 'Module not known to server must have state "missing"' );
+                       assert.equal( mw.loader.getState( 'testUsesMissing' ), 'error', 'Module with missing dependency must have state "error"' );
+                       assert.equal( mw.loader.getState( 'testUsesNestedMissing' ), 'error', 'Module with indirect missing dependency must have state "error"' );
                }
-       );
-} );
 
-QUnit.asyncTest( 'mw.loader( "//protocol-relative" ) (bug 30825)', 2, function ( assert ) {
-       // This bug was actually already fixed in 1.18 and later when discovered in 1.17.
-       // Test is for regressions!
+               mw.loader.using( ['testUsesNestedMissing'],
+                       function () {
+                               assert.ok( false, 'Error handler should be invoked.' );
+                               assert.ok( true ); // Dummy to reach QUnit expect()
+
+                               verifyModuleStates();
+
+                               QUnit.start();
+                       },
+                       function ( e, badmodules ) {
+                               assert.ok( true, 'Error handler should be invoked.' );
+                               // As soon as server spits out state('testMissing', 'missing');
+                               // it will bubble up and trigger the error callback.
+                               // Therefor the badmodules array is not testUsesMissing or testUsesNestedMissing.
+                               assert.deepEqual( badmodules, ['testMissing'], 'Bad modules as expected.' );
 
-       // Forge an URL to the test callback script
-       var target = QUnit.fixurl(
-               mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/qunitOkCall.js'
-       );
+                               verifyModuleStates();
 
-       // Confirm that mw.loader.load() works with protocol-relative URLs
-       target = target.replace( /https?:/, '' );
+                               QUnit.start();
+                       }
+               );
+       } );
 
-       assert.equal( target.substr( 0, 2 ), '//',
-               'URL must be relative to test relative URLs!'
-       );
+       QUnit.asyncTest( 'mw.loader( "//protocol-relative" ) (bug 30825)', 2, function ( assert ) {
+               // This bug was actually already fixed in 1.18 and later when discovered in 1.17.
+               // Test is for regressions!
 
-       // Async!
-       // The target calls QUnit.start
-       mw.loader.load( target );
-});
+               // Forge an URL to the test callback script
+               var target = QUnit.fixurl(
+                       mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/qunitOkCall.js'
+               );
 
-QUnit.test( 'mw.html', 13, function ( assert ) {
-       assert.throws( function () {
-               mw.html.escape();
-       }, TypeError, 'html.escape throws a TypeError if argument given is not a string' );
+               // Confirm that mw.loader.load() works with protocol-relative URLs
+               target = target.replace( /https?:/, '' );
 
-       assert.equal( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ),
-               '&lt;mw awesome=&quot;awesome&quot; value=&#039;test&#039; /&gt;', 'escape() escapes special characters to html entities' );
+               assert.equal( target.substr( 0, 2 ), '//',
+                       'URL must be relative to test relative URLs!'
+               );
 
-       assert.equal( mw.html.element(),
-               '<undefined/>', 'element() always returns a valid html string (even without arguments)' );
+               // Async!
+               // The target calls QUnit.start
+               mw.loader.load( target );
+       } );
 
-       assert.equal( mw.html.element( 'div' ), '<div/>', 'element() Plain DIV (simple)' );
+       QUnit.test( 'mw.html', 13, function ( assert ) {
+               assert.throws( function () {
+                       mw.html.escape();
+               }, TypeError, 'html.escape throws a TypeError if argument given is not a string' );
 
-       assert.equal( mw.html.element( 'div', {}, '' ), '<div></div>', 'element() Basic DIV (simple)' );
+               assert.equal( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ),
+                       '&lt;mw awesome=&quot;awesome&quot; value=&#039;test&#039; /&gt;', 'escape() escapes special characters to html entities' );
 
-       assert.equal(
-               mw.html.element(
-                       'div', {
-                               id: 'foobar'
-                       }
-               ),
-               '<div id="foobar"/>',
-               'html.element DIV (attribs)' );
-
-       assert.equal( mw.html.element( 'p', null, 12 ), '<p>12</p>', 'Numbers are valid content and should be casted to a string' );
-
-       assert.equal( mw.html.element( 'p', { title: 12 }, '' ), '<p title="12"></p>', 'Numbers are valid attribute values' );
-
-       // Example from https://www.mediawiki.org/wiki/ResourceLoader/Default_modules#mediaWiki.html
-       assert.equal(
-               mw.html.element(
-                       'div',
-                       {},
-                       new mw.html.Raw(
-                               mw.html.element( 'img', { src: '<' } )
-                       )
-               ),
-               '<div><img src="&lt;"/></div>',
-               'Raw inclusion of another element'
-       );
-
-       assert.equal(
-               mw.html.element(
-                       'option', {
-                               selected: true
-                       }, 'Foo'
-               ),
-               '<option selected="selected">Foo</option>',
-               'Attributes may have boolean values. True copies the attribute name to the value.'
-       );
-
-       assert.equal(
-               mw.html.element(
-                       'option', {
-                               value: 'foo',
-                               selected: false
-                       }, 'Foo'
-               ),
-               '<option value="foo">Foo</option>',
-               'Attributes may have boolean values. False keeps the attribute from output.'
-       );
-
-       assert.equal( mw.html.element( 'div',
+               assert.equal( mw.html.element(),
+                       '<undefined/>', 'element() always returns a valid html string (even without arguments)' );
+
+               assert.equal( mw.html.element( 'div' ), '<div/>', 'element() Plain DIV (simple)' );
+
+               assert.equal( mw.html.element( 'div', {}, '' ), '<div></div>', 'element() Basic DIV (simple)' );
+
+               assert.equal(
+                       mw.html.element(
+                               'div', {
+                                       id: 'foobar'
+                               }
+                       ),
+                       '<div id="foobar"/>',
+                       'html.element DIV (attribs)' );
+
+               assert.equal( mw.html.element( 'p', null, 12 ), '<p>12</p>', 'Numbers are valid content and should be casted to a string' );
+
+               assert.equal( mw.html.element( 'p', { title: 12 }, '' ), '<p title="12"></p>', 'Numbers are valid attribute values' );
+
+               // Example from https://www.mediawiki.org/wiki/ResourceLoader/Default_modules#mediaWiki.html
+               assert.equal(
+                       mw.html.element(
+                               'div',
+                               {},
+                               new mw.html.Raw(
+                                       mw.html.element( 'img', { src: '<' } )
+                               )
+                       ),
+                       '<div><img src="&lt;"/></div>',
+                       'Raw inclusion of another element'
+               );
+
+               assert.equal(
+                       mw.html.element(
+                               'option', {
+                                       selected: true
+                               }, 'Foo'
+                       ),
+                       '<option selected="selected">Foo</option>',
+                       'Attributes may have boolean values. True copies the attribute name to the value.'
+               );
+
+               assert.equal(
+                       mw.html.element(
+                               'option', {
+                                       value: 'foo',
+                                       selected: false
+                               }, 'Foo'
+                       ),
+                       '<option value="foo">Foo</option>',
+                       'Attributes may have boolean values. False keeps the attribute from output.'
+               );
+
+               assert.equal( mw.html.element( 'div',
                        null, 'a' ),
-               '<div>a</div>',
-               'html.element DIV (content)' );
+                       '<div>a</div>',
+                       'html.element DIV (content)' );
 
-       assert.equal( mw.html.element( 'a',
+               assert.equal( mw.html.element( 'a',
                        { href: 'http://mediawiki.org/w/index.php?title=RL&action=history' }, 'a' ),
-               '<a href="http://mediawiki.org/w/index.php?title=RL&amp;action=history">a</a>',
-               'html.element DIV (attribs + content)' );
+                       '<a href="http://mediawiki.org/w/index.php?title=RL&amp;action=history">a</a>',
+                       'html.element DIV (attribs + content)' );
 
-});
+       } );
 
 }( mediaWiki, jQuery ) );
index a9bbbf7..875ab91 100644 (file)
@@ -1,55 +1,53 @@
 ( function ( mw, $ ) {
-
-QUnit.module( 'mediawiki.user', QUnit.newMwEnvironment() );
-
-QUnit.test( 'options', 1, function ( assert ) {
-       assert.ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
-});
-
-QUnit.test( 'user status', 9, function ( assert ) {
-       /**
-        * Tests can be run under three different conditions:
-        *   1) From tests/qunit/index.html, user will be anonymous.
-        *   2) Logged in on [[Special:JavaScriptTest/qunit]]
-        *   3) Anonymously at the same special page.
-        */
-
-       // Forge an anonymous user:
-       mw.config.set( 'wgUserName', null );
-
-       assert.strictEqual( mw.user.getName(), null, 'user.getName() returns null when anonymous' );
-       assert.strictEqual( mw.user.name(), null, 'user.name() compatibility' );
-       assert.assertTrue( mw.user.isAnon(), 'user.isAnon() returns true when anonymous' );
-       assert.assertTrue( mw.user.anonymous(), 'user.anonymous() compatibility' );
-
-       // Not part of startUp module
-       mw.config.set( 'wgUserName', 'John' );
-
-       assert.equal( mw.user.getName(), 'John', 'user.getName() returns username when logged-in' );
-       assert.equal( mw.user.name(), 'John', 'user.name() compatibility' );
-       assert.assertFalse( mw.user.isAnon(), 'user.isAnon() returns false when logged-in' );
-       assert.assertFalse( mw.user.anonymous(), 'user.anonymous() compatibility' );
-
-       assert.equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
-});
-
-QUnit.asyncTest( 'getGroups', 3, function ( assert ) {
-       mw.user.getGroups( function ( groups ) {
-               // First group should always be '*'
-               assert.equal( $.type( groups ), 'array', 'Callback gets an array' );
-               assert.notStrictEqual( $.inArray( '*', groups ), -1, '"*"" is in the list' );
-               // Sort needed because of different methods if creating the arrays,
-               // only the content matters.
-               assert.deepEqual( groups.sort(), mw.config.get( 'wgUserGroups' ).sort(), 'Array contains all groups, just like wgUserGroups' );
-               QUnit.start();
-       });
-});
-
-QUnit.asyncTest( 'getRights', 1, function ( assert ) {
-       mw.user.getRights( function ( rights ) {
-               assert.equal( $.type( rights ), 'array', 'Callback gets an array' );
-               QUnit.start();
-       });
-});
-
+       QUnit.module( 'mediawiki.user', QUnit.newMwEnvironment() );
+
+       QUnit.test( 'options', 1, function ( assert ) {
+               assert.ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
+       } );
+
+       QUnit.test( 'user status', 9, function ( assert ) {
+               /**
+                * Tests can be run under three different conditions:
+                *   1) From tests/qunit/index.html, user will be anonymous.
+                *   2) Logged in on [[Special:JavaScriptTest/qunit]]
+                *   3) Anonymously at the same special page.
+                */
+
+               // Forge an anonymous user:
+               mw.config.set( 'wgUserName', null );
+
+               assert.strictEqual( mw.user.getName(), null, 'user.getName() returns null when anonymous' );
+               assert.strictEqual( mw.user.name(), null, 'user.name() compatibility' );
+               assert.assertTrue( mw.user.isAnon(), 'user.isAnon() returns true when anonymous' );
+               assert.assertTrue( mw.user.anonymous(), 'user.anonymous() compatibility' );
+
+               // Not part of startUp module
+               mw.config.set( 'wgUserName', 'John' );
+
+               assert.equal( mw.user.getName(), 'John', 'user.getName() returns username when logged-in' );
+               assert.equal( mw.user.name(), 'John', 'user.name() compatibility' );
+               assert.assertFalse( mw.user.isAnon(), 'user.isAnon() returns false when logged-in' );
+               assert.assertFalse( mw.user.anonymous(), 'user.anonymous() compatibility' );
+
+               assert.equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
+       } );
+
+       QUnit.asyncTest( 'getGroups', 3, function ( assert ) {
+               mw.user.getGroups( function ( groups ) {
+                       // First group should always be '*'
+                       assert.equal( $.type( groups ), 'array', 'Callback gets an array' );
+                       assert.notStrictEqual( $.inArray( '*', groups ), -1, '"*"" is in the list' );
+                       // Sort needed because of different methods if creating the arrays,
+                       // only the content matters.
+                       assert.deepEqual( groups.sort(), mw.config.get( 'wgUserGroups' ).sort(), 'Array contains all groups, just like wgUserGroups' );
+                       QUnit.start();
+               } );
+       } );
+
+       QUnit.asyncTest( 'getRights', 1, function ( assert ) {
+               mw.user.getRights( function ( rights ) {
+                       assert.equal( $.type( rights ), 'array', 'Callback gets an array' );
+                       QUnit.start();
+               } );
+       } );
 }( mediaWiki, jQuery ) );
index c4212df..bba3160 100644 (file)
@@ -3,11 +3,11 @@
 
        QUnit.test( 'rawurlencode', 1, function ( assert ) {
                assert.equal( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' );
-       });
+       } );
 
        QUnit.test( 'wikiUrlencode', 1, function ( assert ) {
                assert.equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
-       });
+       } );
 
        QUnit.test( 'wikiGetlink', 3, function ( assert ) {
                // Not part of startUp module
 
                href = mw.util.wikiGetlink();
                assert.equal( href, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
-       });
+       } );
 
        QUnit.test( 'wikiScript', 4, function ( assert ) {
-               mw.config.set({
+               mw.config.set( {
                        'wgScript': '/w/i.php', // customized wgScript for bug 39103
                        'wgLoadScript': '/w/l.php', // customized wgLoadScript for bug 39103
                        'wgScriptPath': '/w',
                        'wgScriptExtension': '.php'
-               });
+               } );
 
                assert.equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ),
                        'wikiScript() returns wgScript'
@@ -43,7 +43,7 @@
                        'wikiScript( load ) returns wgLoadScript'
                );
                assert.equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' );
-       });
+       } );
 
        QUnit.test( 'addCSS', 3, function ( assert ) {
                var $el, style;
@@ -57,7 +57,7 @@
 
                // Clean up
                $( style.ownerNode ).remove();
-       });
+       } );
 
        QUnit.asyncTest( 'toggleToc', 4, function ( assert ) {
                var tocHtml, $toggleLink;
 
                assert.strictEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' );
 
-               tocHtml =
-                       '<table id="toc" class="toc"><tr><td>' +
-                               '<div id="toctitle">' +
-                                       '<h2>Contents</h2>' +
-                                       '<span class="toctoggle">&nbsp;[<a href="#" class="internal" id="togglelink">Hide</a>&nbsp;]</span>' +
-                               '</div>' +
-                               '<ul><li></li></ul>' +
+               tocHtml = '<table id="toc" class="toc"><tr><td>' +
+                       '<div id="toctitle">' +
+                       '<h2>Contents</h2>' +
+                       '<span class="toctoggle">&nbsp;[<a href="#" class="internal" id="togglelink">Hide</a>&nbsp;]</span>' +
+                       '</div>' +
+                       '<ul><li></li></ul>' +
                        '</td></tr></table>';
-               $(tocHtml).appendTo( '#qunit-fixture' ),
-               $toggleLink = $( '#togglelink' );
+               $( tocHtml ).appendTo( '#qunit-fixture' ),
+                       $toggleLink = $( '#togglelink' );
 
                assert.strictEqual( $toggleLink.length, 1, 'Toggle link is appended to the page.' );
 
                actionA();
-       });
+       } );
 
        QUnit.test( 'getParamValue', 5, function ( assert ) {
-               var     url;
+               var url;
 
                url = 'http://example.org/?foo=wrong&foo=right#&foo=bad';
                assert.equal( mw.util.getParamValue( 'foo', url ), 'right', 'Use latest one, ignore hash' );
                url = 'http://example.org/#&foo=bad';
                assert.strictEqual( mw.util.getParamValue( 'foo', url ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' );
 
-               url = 'example.org?' + $.param({ 'TEST': 'a b+c' });
+               url = 'example.org?' + $.param( { 'TEST': 'a b+c' } );
                assert.strictEqual( mw.util.getParamValue( 'TEST', url ), 'a b+c', 'Bug 30441: getParamValue must understand "+" encoding of space' );
 
-               url = 'example.org?' + $.param({ 'TEST': 'a b+c d' }); // check for sloppy code from r95332 :)
+               url = 'example.org?' + $.param( { 'TEST': 'a b+c d' } ); // check for sloppy code from r95332 :)
                assert.strictEqual( mw.util.getParamValue( 'TEST', url ), 'a b+c d', 'Bug 30441: getParamValue must understand "+" encoding of space (multiple spaces)' );
-       });
+       } );
 
        QUnit.test( 'tooltipAccessKey', 3, function ( assert ) {
                assert.equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' );
                assert.ok( mw.util.tooltipAccessKeyRegexp instanceof RegExp, 'mw.util.tooltipAccessKeyRegexp instance of RegExp' );
                assert.ok( mw.util.updateTooltipAccessKeys, 'mw.util.updateTooltipAccessKeys' );
-       });
+       } );
 
        QUnit.test( '$content', 2, function ( assert ) {
                assert.ok( mw.util.$content instanceof jQuery, 'mw.util.$content instance of jQuery' );
                assert.strictEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' );
-       });
-
+       } );
 
        /**
         * Portlet names are prefixed with 'p-test' to avoid conflict with core
                assert.equal( $tbMW.next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' );
 
                cuQuux = mw.util.addPortletLink( 'p-test-custom', '#', 'Quux' );
-               $cuQuux = $(cuQuux);
+               $cuQuux = $( cuQuux );
 
                assert.equal(
                        $( '#p-test-custom #c-barmenu ul li' ).length,
 
                caFoo = mw.util.addPortletLink( 'p-test-views', '#', 'Foo' );
 
-               assert.strictEqual( $tbMW.find( 'span').length, 0, 'No <span> element should be added for porlets without vectorTabs class.' );
-               assert.strictEqual( $( caFoo ).find( 'span').length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
-       });
+               assert.strictEqual( $tbMW.find( 'span' ).length, 0, 'No <span> element should be added for porlets without vectorTabs class.' );
+               assert.strictEqual( $( caFoo ).find( 'span' ).length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
+       } );
 
        QUnit.test( 'jsMessage', 1, function ( assert ) {
                var a = mw.util.jsMessage( 'MediaWiki is <b>Awesome</b>.' );
 
                // Clean up
                $( '#mw-js-message' ).remove();
-       });
+       } );
 
        QUnit.test( 'validateEmail', 6, function ( assert ) {
                assert.strictEqual( mw.util.validateEmail( '' ), null, 'Should return null for empty string ' );
                // testEmailWithHyphens
                assert.strictEqual( mw.util.validateEmail( 'user-foo@example.org' ), true, 'Emails may contain a hyphen' );
                assert.strictEqual( mw.util.validateEmail( 'userfoo@ex-ample.org' ), true, 'Emails may contain a hyphen' );
-       });
+       } );
 
        QUnit.test( 'isIPv6Address', 40, function ( assert ) {
                // Shortcuts
                function assertFalseIPv6( addy, summary ) {
                        return assert.strictEqual( mw.util.isIPv6Address( addy ), false, summary );
                }
+
                function assertTrueIPv6( addy, summary ) {
                        return assert.strictEqual( mw.util.isIPv6Address( addy ), true, summary );
                }
                assertFalseIPv6( 'fc:100:300', 'IPv6 with only 3 words' );
 
                $.each(
-               ['fc:100::',
-               'fc:100:a::',
-               'fc:100:a:d::',
-               'fc:100:a:d:1::',
-               'fc:100:a:d:1:e::',
-               'fc:100:a:d:1:e:ac::'], function ( i, addy ){
-                       assertTrueIPv6( addy, addy + ' is a valid IP' );
-               });
+                       ['fc:100::',
+                               'fc:100:a::',
+                               'fc:100:a:d::',
+                               'fc:100:a:d:1::',
+                               'fc:100:a:d:1:e::',
+                               'fc:100:a:d:1:e:ac::'], function ( i, addy ) {
+                               assertTrueIPv6( addy, addy + ' is a valid IP' );
+                       } );
 
                assertFalseIPv6( 'fc:100:a:d:1:e:ac:0::', 'IPv6 with 8 words ending with "::"' );
                assertFalseIPv6( 'fc:100:a:d:1:e:ac:0:1::', 'IPv6 with 9 words ending with "::"' );
 
                assertTrueIPv6( '::', 'IPv6 zero address' );
                $.each(
-               ['::0',
-               '::fc',
-               '::fc:100',
-               '::fc:100:a',
-               '::fc:100:a:d',
-               '::fc:100:a:d:1',
-               '::fc:100:a:d:1:e',
-               '::fc:100:a:d:1:e:ac',
-
-               'fc:100:a:d:1:e:ac:0'], function ( i, addy ){
-                       assertTrueIPv6( addy, addy + ' is a valid IP' );
-               });
+                       ['::0',
+                               '::fc',
+                               '::fc:100',
+                               '::fc:100:a',
+                               '::fc:100:a:d',
+                               '::fc:100:a:d:1',
+                               '::fc:100:a:d:1:e',
+                               '::fc:100:a:d:1:e:ac',
+
+                               'fc:100:a:d:1:e:ac:0'], function ( i, addy ) {
+                               assertTrueIPv6( addy, addy + ' is a valid IP' );
+                       } );
 
                assertFalseIPv6( '::fc:100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' );
                assertFalseIPv6( '::fc:100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' );
 
                assertFalseIPv6( 'fc::100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' );
                assertFalseIPv6( 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' );
-       });
+       } );
 
        QUnit.test( 'isIPv4Address', 11, function ( assert ) {
                // Shortcuts
                function assertFalseIPv4( addy, summary ) {
                        assert.strictEqual( mw.util.isIPv4Address( addy ), false, summary );
                }
+
                function assertTrueIPv4( addy, summary ) {
                        assert.strictEqual( mw.util.isIPv4Address( addy ), true, summary );
                }
                assertTrueIPv4( '124.24.52.13', '124.24.52.134 is a valid IP' );
                assertTrueIPv4( '1.24.52.13', '1.24.52.13 is a valid IP' );
                assertFalseIPv4( '74.24.52.13/20', 'IPv4 ranges are not recogzized as valid IPs' );
-       });
+       } );
 }( mediaWiki, jQuery ) );