Fix intermittent QUnit failure
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.test.js
index 9286558..dc7bd0a 100644 (file)
@@ -277,15 +277,25 @@ QUnit.asyncTest( 'mw.loader.implement( styles={ "url": { <media>: [url, ..] } }
        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' );
 
-                               QUnit.start();
+                               pending--;
+                               if ( pending === 0 ) {
+                                       QUnit.start();
+                               }
                        } );
                        assertStyleAsync( assert, $element3, 'float', 'right', function () {
                                assert.notEqual( $element1.css( 'text-align' ), 'center', 'print style is not applied' );
 
-                               QUnit.start();
+                               pending--;
+                               if ( pending === 0 ) {
+                                       QUnit.start();
+                               }
                        } );
                },
                {