Merge "SpecialMovepage: Convert form to use OOUI controls"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.test.js
index fd3f990..b55b1e7 100644 (file)
 
                // Multiple values at once
                someValues = {
-                       'foo': 'bar',
-                       'lorem': 'ipsum',
-                       'MediaWiki': true
+                       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'
+                       foo: 'bar',
+                       lorem: 'ipsum'
                }, 'Map.get returns multiple values correctly as an object' );
 
                assert.deepEqual( conf, new mw.Map( conf.values ), 'new mw.Map maps over existing values-bearing object' );
 
                assert.deepEqual( conf.get( [ 'foo', 'notExist' ] ), {
-                       'foo': 'bar',
-                       'notExist': null
+                       foo: 'bar',
+                       notExist: null
                }, 'Map.get return includes keys that were not found as null values' );
 
                // Interacting with globals and accessing the values object
         * 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
+        * `@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
                                QUnit.start();
                        },
                        {
-                               'all': '.mw-test-implement-a { float: right; }'
+                               all: '.mw-test-implement-a { float: right; }'
                        }
                );
 
                                } );
                        },
                        {
-                               'url': {
-                                       'print': [ urlStyleTest( '.mw-test-implement-b1', 'text-align', 'center' ) ],
-                                       'screen': [
+                               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' )
                                QUnit.start();
                        },
                        {
-                               'all': '.mw-test-implement-c { float: right; }'
+                               all: '.mw-test-implement-c { float: right; }'
                        }
                );
 
                                } );
                        },
                        {
-                               'all': [ urlStyleTest( '.mw-test-implement-d', 'float', 'right' ) ],
-                               'print': [ urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' ) ]
+                               all: [ urlStyleTest( '.mw-test-implement-d', 'float', 'right' ) ],
+                               print: [ urlStyleTest( '.mw-test-implement-d2', 'text-align', 'center' ) ]
                        }
                );
 
                                assert.strictEqual( isJsExecuted, undefined, 'script not executed multiple times' );
                                isJsExecuted = true;
 
-                               assert.equal( mw.loader.getState( 'test.implement.import' ), 'loading', 'module state during implement() script execution' );
+                               assert.equal( mw.loader.getState( 'test.implement.import' ), 'executing', 'module state during implement() script execution' );
 
                                $element = $( '<div class="mw-test-implement-import">Foo bar</div>' ).appendTo( '#qunit-fixture' );
 
                                } );
                        },
                        {
-                               'css': [
+                               css: [
                                        '@import url(\''
                                                + urlStyleTest( '.mw-test-implement-import', 'float', 'right' )
                                                + '\');\n'
                                QUnit.start();
                        },
                        {
-                               'all': '.mw-test-implement-e { float: right; }'
+                               all: '.mw-test-implement-e { float: right; }'
                        }
                );
 
                                );
                        },
                        {
-                               'all': '.mw-test-implement-e2 { float: left; }'
+                               all: '.mw-test-implement-e2 { float: left; }'
                        }
                );
 
        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' } );
+               // jscs: disable requireCamelCaseOrUpperCaseIdentifiers
+               mw.loader.implement( 'test.implement.msgs', [], {}, { bug_29107: 'loaded' } );
+               // jscs: enable requireCamelCaseOrUpperCaseIdentifiers
                mw.loader.using( 'test.implement.msgs', function () {
                        QUnit.start();
                        assert.ok( mw.messages.exists( 'bug_29107' ), 'Bug 29107: messages-only module should implement ok' );
                mw.loader.load( target );
        } );
 
+       QUnit.asyncTest( 'mw.loader() executing race (T112232)', 2, function ( assert ) {
+               var done = false;
+
+               // The red herring schedules its CSS buffer first. In T112232, a bug in the
+               // state machine would cause the job for testRaceLoadMe to run with an earlier job.
+               mw.loader.implement(
+                       'testRaceRedHerring',
+                       function () {},
+                       { css: [ '.mw-testRaceRedHerring {}' ] }
+               );
+               mw.loader.implement(
+                       'testRaceLoadMe',
+                       function () {
+                               done = true;
+                       },
+                       { css: [ '.mw-testRaceLoadMe { float: left; }' ] }
+               );
+
+               mw.loader.load( [ 'testRaceRedHerring', 'testRaceLoadMe' ] );
+               mw.loader.using( 'testRaceLoadMe', function () {
+                       assert.strictEqual( done, true, 'script ran' );
+                       assert.strictEqual( mw.loader.getState( 'testRaceLoadMe' ), 'ready', 'state' );
+               } ).always( QUnit.start );
+       } );
+
        QUnit.test( 'mw.html', 13, function ( assert ) {
                assert.throws( function () {
                        mw.html.escape();