Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | |
150 | 150 | var isAwesomeDone; |
151 | 151 | |
152 | | - // Asynchronous ahead |
| 152 | + // Async ahead |
153 | 153 | stop(); |
154 | 154 | |
155 | 155 | mw.loader.testCallback = function () { |
— | — | @@ -157,23 +157,74 @@ |
158 | 158 | isAwesomeDone = true; |
159 | 159 | }; |
160 | 160 | |
161 | | - mw.loader.implement( 'is.awesome', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} ); |
| 161 | + mw.loader.implement( 'test.callback', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/callMwLoaderTestCallback.js' )], {}, {} ); |
162 | 162 | |
163 | | - mw.loader.using( 'is.awesome', function () { |
| 163 | + mw.loader.using( 'test.callback', function () { |
164 | 164 | |
165 | 165 | // /sample/awesome.js declares the "mw.loader.testCallback" function |
166 | 166 | // which contains a call to start() and ok() |
167 | | - strictEqual(isAwesomeDone, true, "is.awesome module should've caused isAwesomeDone to be true") |
| 167 | + strictEqual( isAwesomeDone, true, "test.callback module should've caused isAwesomeDone to be true" ); |
168 | 168 | delete mw.loader.testCallback; |
169 | 169 | |
170 | 170 | }, function () { |
171 | 171 | start(); |
172 | | - ok( false, 'Error callback fired while loader.using "is.awesome" module' ); |
| 172 | + ok( false, 'Error callback fired while loader.using "test.callback" module' ); |
173 | 173 | }); |
| 174 | +}); |
174 | 175 | |
| 176 | +test( 'mw.loader.implement', function () { |
| 177 | + expect(5 - 2); |
| 178 | + |
| 179 | + var isJsExecuted, $element; |
| 180 | + |
| 181 | + // Async ahead |
| 182 | + stop(); |
| 183 | + |
| 184 | + mw.loader.implement( |
| 185 | + 'test.implement', |
| 186 | + function () { |
| 187 | + start(); |
| 188 | + |
| 189 | + strictEqual( isJsExecuted, undefined, 'javascript not executed multiple times' ); |
| 190 | + isJsExecuted = true; |
| 191 | + |
| 192 | + equal( mw.loader.getState( 'test.implement' ), 'loaded', 'module state is "loaded" while implement() is executing javascript' ); |
| 193 | + |
| 194 | + $element = $( '<div class="mw-test-loaderimplement">Foo bar</div>' ); |
| 195 | + $element.appendTo( 'body' ); |
| 196 | + |
| 197 | + // @broken: equal( $element.css( 'text-align' ),'center', 'CSS stylesheet was applied in time. ("text-align: center")' ); |
| 198 | + |
| 199 | + // Marked broken due to a bug in qunit/index.html, via Special:JavaScriptTest/qunit it works fine |
| 200 | + |
| 201 | + // CSS @import is easily broken when concatenating stylesheets (bug 34669) |
| 202 | + // @broken: equal( $element.css( 'float' ), 'right', 'CSS stylesheet was applied in time via @import (bug 34669). ("float: right")' ); |
| 203 | + |
| 204 | + equal( mw.msg( 'test-foobar' ), 'Hello Foobar, $1!', 'Messages are loaded in time' ); |
| 205 | + |
| 206 | + }, |
| 207 | + { |
| 208 | + "all": "@import url('" |
| 209 | + + QUnit.fixurl( mw.config.get( 'wgScriptPath' ) |
| 210 | + + '/tests/qunit/data/styleTest.css.php?' |
| 211 | + + $.param({ |
| 212 | + selector: '.mw-test-loaderimplement', |
| 213 | + prop: 'float', |
| 214 | + val: 'right' |
| 215 | + }) ) |
| 216 | + + "');\n" |
| 217 | + + '.mw-test-loaderimplement { text-align: center; }' |
| 218 | + }, |
| 219 | + { |
| 220 | + "test-foobar": "Hello Foobar, $1!" |
| 221 | + } |
| 222 | + ); |
| 223 | + |
| 224 | + mw.loader.load( 'test.implement' ); |
| 225 | + |
175 | 226 | }); |
176 | 227 | |
177 | | -test( 'mw.loader.bug29107' , function() { |
| 228 | +test( 'mw.loader bug29107' , function () { |
178 | 229 | expect(2); |
179 | 230 | |
180 | 231 | // Message doesn't exist already |