Index: trunk/phase3/tests/qunit/data/testrunner.js |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * Load TestSwarm agent |
16 | 16 | */ |
17 | 17 | if ( QUnit.urlParams.swarmURL ) { |
18 | | - document.write("<scr" + "ipt src='" + QUnit.fixurl( 'data/testwarm.inject.js' ) + "'></scr" + "ipt>"); |
| 18 | + document.write("<scr" + "ipt src='" + QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/testwarm.inject.js' ) + "'></scr" + "ipt>"); |
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
Index: trunk/phase3/tests/qunit/index.html |
— | — | @@ -9,6 +9,25 @@ |
10 | 10 | <script> |
11 | 11 | function startUp(){ |
12 | 12 | mw.config = new mw.Map( false ); |
| 13 | + |
| 14 | + /** |
| 15 | + * Guess wgScriptPath (for access to /tests/qunit/data/) |
| 16 | + */ |
| 17 | + |
| 18 | + // Regular expression to extract the path for the QUnit tests |
| 19 | + // Takes into account that tests could be run from a file:// URL |
| 20 | + // by excluding the 'index.html' part from the URL |
| 21 | + var rePath = /(?:[^#\?](?!index.html))*\/?/; |
| 22 | + |
| 23 | + // Extract path to /tests/qunit/ |
| 24 | + var qunitTestsPath = rePath.exec( location.href )[0]; |
| 25 | + |
| 26 | + // Traverse up to script path |
| 27 | + var pathParts = qunitTestsPath.split( '/' ); |
| 28 | + pathParts.pop(); pathParts.pop(); pathParts.pop(); |
| 29 | + var scriptPath = pathParts.join( '/' ); |
| 30 | + |
| 31 | + mw.config.set( 'wgScriptPath', scriptPath ); |
13 | 32 | } |
14 | 33 | </script> |
15 | 34 | |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | test( 'wikiScript', function() { |
41 | 41 | expect(2); |
42 | 42 | |
| 43 | + var prevConfig = mw.config.get([ 'wgScript', 'wgScriptPath', 'wgScriptExtension' ]); |
43 | 44 | mw.config.set({ |
44 | 45 | 'wgScript': '/w/index.php', |
45 | 46 | 'wgScriptPath': '/w', |
— | — | @@ -48,6 +49,8 @@ |
49 | 50 | equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'Defaults to index.php and is equal to wgScript' ); |
50 | 51 | equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' ); |
51 | 52 | |
| 53 | + // Restore mw.config |
| 54 | + mw.config.set( prevConfig ); |
52 | 55 | }); |
53 | 56 | |
54 | 57 | test( 'addCSS', function() { |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js |
— | — | @@ -124,43 +124,13 @@ |
125 | 125 | }); |
126 | 126 | |
127 | 127 | test( 'mw.loader', function() { |
128 | | - expect(5); |
| 128 | + expect(1); |
129 | 129 | |
130 | | - // Regular expression to extract the path for the QUnit tests |
131 | | - // Takes into account that tests could be run from a file:// URL |
132 | | - // by excluding the 'index.html' part from the URL |
133 | | - var rePath = /(?:[^#\?](?!index.html))*\/?/; |
134 | | - |
135 | | - // Four assertions to test the above regular expression: |
136 | | - equal( |
137 | | - rePath.exec( 'http://path/to/tests/?foobar' )[0], |
138 | | - "http://path/to/tests/", |
139 | | - "Extracting path from http URL with query" |
140 | | - ); |
141 | | - equal( |
142 | | - rePath.exec( 'http://path/to/tests/#frag' )[0], |
143 | | - "http://path/to/tests/", |
144 | | - "Extracting path from http URL with fragment" |
145 | | - ); |
146 | | - equal( |
147 | | - rePath.exec( 'file://path/to/tests/index.html?foobar' )[0], |
148 | | - "file://path/to/tests/", |
149 | | - "Extracting path from local URL (file://) with query" |
150 | | - ); |
151 | | - equal( |
152 | | - rePath.exec( 'file://path/to/tests/index.html#frag' )[0], |
153 | | - "file://path/to/tests/", |
154 | | - "Extracting path from local URL (file://) with fragment" |
155 | | - ); |
156 | | - |
157 | 130 | // Asynchronous ahead |
158 | 131 | stop(5000); |
159 | 132 | |
160 | | - // Extract path |
161 | | - var tests_path = rePath.exec( location.href ); |
| 133 | + mw.loader.implement( 'is.awesome', [QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/defineTestCallback.js' )], {}, {} ); |
162 | 134 | |
163 | | - mw.loader.implement( 'is.awesome', [QUnit.fixurl( tests_path + 'data/defineTestCallback.js' )], {}, {} ); |
164 | | - |
165 | 135 | mw.loader.using( 'is.awesome', function() { |
166 | 136 | |
167 | 137 | // /sample/awesome.js declares the "mw.loader.testCallback" function |