Index: branches/JSTesting/tests/qunit/QUnitTestResources.php |
— | — | @@ -18,10 +18,7 @@ |
19 | 19 | # jquery.tablesorter.test.js: Broken |
20 | 20 | #'tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js', // has mw-config def |
21 | 21 | 'tests/qunit/suites/resources/jquery/jquery.textSelection.test.js', |
22 | | - # mediawiki.test.js: Tries to load from /data/ directory, fails when ran from the |
23 | | - # SpecialPage since it uses regex to get the current path and loads from that + /data/ |
24 | | - # (index.php/Data in this case..) |
25 | | - #'tests/qunit/suites/resources/mediawiki/mediawiki.test.js', |
| 22 | + 'tests/qunit/suites/resources/mediawiki/mediawiki.test.js', |
26 | 23 | 'tests/qunit/suites/resources/mediawiki/mediawiki.title.test.js', // has mw-config def |
27 | 24 | 'tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js', |
28 | 25 | 'tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js', |
Index: branches/JSTesting/tests/qunit/suites/resources/mediawiki/mediawiki.test.js |
— | — | @@ -173,13 +173,30 @@ |
174 | 174 | // This bug was actually already fixed in 1.18 and later when discovered in 1.17. |
175 | 175 | // Test is for regressions! |
176 | 176 | |
177 | | - expect(1); |
| 177 | + expect(2); |
178 | 178 | |
| 179 | + var wgServer = mw.config.get( 'wgServer' ), |
| 180 | + basePath = mw.config.get( 'wgScriptPath' ); |
| 181 | + |
| 182 | + // From [[Special:JavaScriptTest]] we need to preprend the script path |
| 183 | + // with the actual server (http://localhost/). |
| 184 | + // Running from file tests/qunit/index.html, wgScriptPath is already |
| 185 | + // including the wgServer part |
| 186 | + if( wgServer !== null ) { |
| 187 | + basePath = wgServer + wgScriptPath; |
| 188 | + } |
| 189 | + // Forge an URL to the test callback script |
| 190 | + var target = QUnit.fixurl( |
| 191 | + basePath + '/tests/qunit/data/qunitOkCall.js' |
| 192 | + ); |
| 193 | + |
179 | 194 | // Confirm that mw.loader.load() works with protocol-relative URLs |
180 | | - var loc = window.location, |
181 | | - base = ('//' + loc.hostname + loc.pathname).replace(/\/[^\/]*$/, ''), |
182 | | - target = base + '/data/qunitOkCall.js?' + (new Date()).getTime(); |
| 195 | + target = target.replace( /https?:/, '' ); |
183 | 196 | |
| 197 | + equal( target.substr( 0, 2 ), '//', |
| 198 | + 'URL must be relative to test relative URLs!' |
| 199 | + ); |
| 200 | + |
184 | 201 | // Async! |
185 | 202 | stop(); |
186 | 203 | mw.loader.load( target ); |