| Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js |
| — | — | @@ -1,497 +0,0 @@ |
| 2 | | -/** |
| 3 | | - * mediaWiki JavaScript library test suite |
| 4 | | - * |
| 5 | | - * Available on Special:BlankPage?action=mwutiltest&debug=true |
| 6 | | - * |
| 7 | | - * @author Krinkle <krinklemail@gmail.com> |
| 8 | | - */ |
| 9 | | - |
| 10 | | -( function( $, mw ) { |
| 11 | | - |
| 12 | | - mw.test = { |
| 13 | | - |
| 14 | | - /* Variables */ |
| 15 | | - '$table' : null, |
| 16 | | - // contains either a header or a test |
| 17 | | - // test: [ code, result, contain ] see addTest |
| 18 | | - // header: [ 'HEADER', escapedtitle, id ] see addHead |
| 19 | | - 'addedTests' : [], |
| 20 | | - 'headResults' : [], |
| 21 | | - 'numberOfHeader' : 0, |
| 22 | | - |
| 23 | | - /* Functions */ |
| 24 | | - |
| 25 | | - /** |
| 26 | | - * Adds a row to the test-table |
| 27 | | - * |
| 28 | | - * @param code String Code of the test to be executed |
| 29 | | - * @param result String Expected result in 'var (vartype)' form |
| 30 | | - * @param contain String Important part of the result, |
| 31 | | - * if result is different but does contain this it will not return ERROR but PARTIALLY |
| 32 | | - */ |
| 33 | | - 'addTest' : function( code, result, contain ) { |
| 34 | | - if ( !contain ) { |
| 35 | | - contain = result; |
| 36 | | - } |
| 37 | | - this.addedTests.push( [code, result, contain] ); |
| 38 | | - this.$table.append( '<tr class="mw-mwutiltest-test">' |
| 39 | | - + '<td>' + mw.html.escape( code ).replace( / /g, ' ' ) |
| 40 | | - + '</td><td>' + mw.html.escape( result ).replace( / /g, ' ' ) |
| 41 | | - + '</td><td></td><td>?</td></tr>' ); |
| 42 | | - return true; |
| 43 | | - }, |
| 44 | | - |
| 45 | | - /** |
| 46 | | - * Adds a heading to the test-table |
| 47 | | - * |
| 48 | | - * @param title String Title of the section |
| 49 | | - */ |
| 50 | | - 'addHead' : function( title ) { |
| 51 | | - if ( !title ) { |
| 52 | | - return false; |
| 53 | | - } |
| 54 | | - var escapedtitle = mw.html.escape( title ).replace( / /g, ' ' ); |
| 55 | | - this.addedTests.push( [ 'HEADER', escapedtitle, mw.test.numberOfHeader++ ] ); |
| 56 | | - this.$table.append( |
| 57 | | - '<tr class="mw-mwutiltest-head" id="mw-mwutiltest-head' |
| 58 | | - + mw.test.numberOfHeader + '"><th colspan="4">' |
| 59 | | - + escapedtitle + '</th></tr>' |
| 60 | | - ); |
| 61 | | - return true; |
| 62 | | - }, |
| 63 | | - |
| 64 | | - /* Initialisation */ |
| 65 | | - 'initialised' : false, |
| 66 | | - 'init' : function() { |
| 67 | | - if ( this.initialised === false ) { |
| 68 | | - this.initialised = true; |
| 69 | | - |
| 70 | | - $(document).ready( function() { |
| 71 | | - if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Blankpage' |
| 72 | | - && mw.util.getParamValue( 'action' ) === 'mwutiltest' ) { |
| 73 | | - |
| 74 | | - // Build page |
| 75 | | - document.title = 'mediaWiki JavaScript library test suite - ' + mw.config.get( 'wgSiteName' ); |
| 76 | | - $( '#firstHeading' ).text( 'mediaWiki JavaScript library test suite' ); |
| 77 | | - var skinLinksHtml = 'Test in: ', |
| 78 | | - skinLinks = [], |
| 79 | | - availableSkins = mw.config.get( 'wgAvailableSkins' ), |
| 80 | | - skincode = ''; |
| 81 | | - for ( skincode in availableSkins ) { |
| 82 | | - skinLinks.push( |
| 83 | | - mw.html.element( |
| 84 | | - 'a', { |
| 85 | | - 'href': mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ) |
| 86 | | - + '?action=mwutiltest&debug=true&useskin=' + encodeURIComponent( skincode ) |
| 87 | | - }, |
| 88 | | - availableSkins[skincode] |
| 89 | | - ) |
| 90 | | - ); |
| 91 | | - } |
| 92 | | - skinLinksHtml += skinLinks.join( ' | ' ) + '.'; |
| 93 | | - mw.util.$content.html( |
| 94 | | - '<p>Below is a list of tests to confirm proper functionality of the mediaWiki JavaScript library</p>' |
| 95 | | - + '<p>' + skinLinksHtml + '</p>' |
| 96 | | - + '<hr />' |
| 97 | | - + '<table id="mw-mwutiltest-table" class="wikitable"' |
| 98 | | - + ' style="white-space:break; font-family:monospace,\'Courier New\'; width:100%;">' |
| 99 | | - + '<tr><th>Exec</th><th>Should return</th><th>Does return</th><th>Equal ?</th></tr>' |
| 100 | | - + '</table>' |
| 101 | | - ); |
| 102 | | - |
| 103 | | - mw.util.addCSS( |
| 104 | | - // Override wikitable padding for <td> |
| 105 | | - '#mw-mwutiltest-table tr td { padding:0 !important; }' |
| 106 | | - ); |
| 107 | | - |
| 108 | | - mw.test.$table = $( 'table#mw-mwutiltest-table' ); |
| 109 | | - |
| 110 | | - /* Populate tests */ |
| 111 | | - // Try to roughly keep the order similar to the order in the files |
| 112 | | - // or alphabetical (depending on the context) |
| 113 | | - |
| 114 | | - /** Main modules and their aliases **/ |
| 115 | | - mw.test.addHead( 'Main modules and their aliases' ); |
| 116 | | - |
| 117 | | - mw.test.addTest( 'typeof mediaWiki', |
| 118 | | - 'object (string)' ); |
| 119 | | - |
| 120 | | - mw.test.addTest( 'typeof mw', |
| 121 | | - 'object (string)' ); |
| 122 | | - |
| 123 | | - mw.test.addTest( 'typeof jQuery', |
| 124 | | - 'function (string)' ); |
| 125 | | - |
| 126 | | - mw.test.addTest( 'typeof $', |
| 127 | | - 'function (string)' ); |
| 128 | | - |
| 129 | | - /** Prototype functions added by MediaWiki **/ |
| 130 | | - mw.test.addHead( 'Prototype functions added by MediaWiki' ); |
| 131 | | - |
| 132 | | - mw.test.addTest( 'typeof $.trimLeft', |
| 133 | | - 'function (string)' ); |
| 134 | | - |
| 135 | | - mw.test.addTest( '$.trimLeft( " foo bar " )', |
| 136 | | - 'foo bar (string)' ); |
| 137 | | - |
| 138 | | - mw.test.addTest( 'typeof $.trimRight', |
| 139 | | - 'function (string)' ); |
| 140 | | - |
| 141 | | - mw.test.addTest( '$.trimRight( " foo bar " )', |
| 142 | | - ' foo bar (string)' ); |
| 143 | | - |
| 144 | | - mw.test.addTest( 'typeof $.ucFirst', |
| 145 | | - 'function (string)' ); |
| 146 | | - |
| 147 | | - mw.test.addTest( '$.ucFirst( "mediawiki" )', |
| 148 | | - 'Mediawiki (string)' ); |
| 149 | | - |
| 150 | | - mw.test.addTest( 'typeof $.escapeRE', |
| 151 | | - 'function (string)' ); |
| 152 | | - |
| 153 | | - mw.test.addTest( '$.escapeRE( "<!-- ([{+mW+}]) $^|?>" )', |
| 154 | | - '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?> (string)' ); // double escaped |
| 155 | | - |
| 156 | | - mw.test.addTest( '$.escapeRE( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" )', |
| 157 | | - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ (string)' ); |
| 158 | | - |
| 159 | | - mw.test.addTest( '$.escapeRE( "abcdefghijklmnopqrstuvwxyz" )', |
| 160 | | - 'abcdefghijklmnopqrstuvwxyz (string)' ); |
| 161 | | - |
| 162 | | - mw.test.addTest( '$.escapeRE( "0123456789" )', |
| 163 | | - '0123456789 (string)' ); |
| 164 | | - |
| 165 | | - mw.test.addTest( '$.isDomElement( document.getElementById("mw-mwutiltest-table") )', |
| 166 | | - 'true (boolean)' ); |
| 167 | | - |
| 168 | | - mw.test.addTest( '$.isDomElement( document.getElementById("not-existant-id") )', |
| 169 | | - 'false (boolean)' ); // returns null |
| 170 | | - |
| 171 | | - mw.test.addTest( '$.isDomElement( document.getElementsByClassName("wikitable") )', |
| 172 | | - 'false (boolean)' ); // returns an array |
| 173 | | - |
| 174 | | - mw.test.addTest( '$.isDomElement( document.getElementsByClassName("wikitable")[0] )', |
| 175 | | - 'true (boolean)' ); |
| 176 | | - |
| 177 | | - mw.test.addTest( '$.isDomElement( jQuery( "#mw-mwutiltest-table" ) )', |
| 178 | | - 'false (boolean)' ); // returns jQuery object |
| 179 | | - |
| 180 | | - mw.test.addTest( '$.isDomElement( jQuery( "#mw-mwutiltest-table" ).get(0) )', |
| 181 | | - 'true (boolean)' ); |
| 182 | | - |
| 183 | | - mw.test.addTest( '$.isDomElement( document.createElement( "div" ) )', |
| 184 | | - 'true (boolean)' ); |
| 185 | | - |
| 186 | | - mw.test.addTest( '$.isDomElement( {some: "thing" } )', |
| 187 | | - 'false (boolean)' ); |
| 188 | | - |
| 189 | | - mw.test.addTest( 'typeof $.isEmpty', |
| 190 | | - 'function (string)' ); |
| 191 | | - |
| 192 | | - mw.test.addTest( '$.isEmpty( "string" )', |
| 193 | | - 'false (boolean)' ); |
| 194 | | - |
| 195 | | - mw.test.addTest( '$.isEmpty( "0" )', |
| 196 | | - 'true (boolean)' ); |
| 197 | | - |
| 198 | | - mw.test.addTest( '$.isEmpty([])', |
| 199 | | - 'true (boolean)' ); |
| 200 | | - |
| 201 | | - mw.test.addTest( 'typeof $.compareArray', |
| 202 | | - 'function (string)' ); |
| 203 | | - |
| 204 | | - mw.test.addTest( '$.compareArray( [1, "a", [], [2, "b"] ], [1, "a", [], [2, "b"] ] )', |
| 205 | | - 'true (boolean)' ); |
| 206 | | - |
| 207 | | - mw.test.addTest( '$.compareArray( [1], [2] )', |
| 208 | | - 'false (boolean)' ); |
| 209 | | - |
| 210 | | - mw.test.addTest( 'typeof $.compareObject', |
| 211 | | - 'function (string)' ); |
| 212 | | - |
| 213 | | - /** mediawiki.js **/ |
| 214 | | - mw.test.addHead( 'mediawiki.js' ); |
| 215 | | - |
| 216 | | - mw.test.addTest( 'mw.config instanceof mw.Map', |
| 217 | | - 'true (boolean)' ); |
| 218 | | - |
| 219 | | - mw.test.addTest( 'mw.config.exists()', |
| 220 | | - 'true (boolean)' ); |
| 221 | | - |
| 222 | | - mw.test.addTest( 'mw.config.exists( "wgSomeName" )', |
| 223 | | - 'false (boolean)' ); |
| 224 | | - |
| 225 | | - mw.test.addTest( 'mw.config.exists( ["wgCanonicalNamespace", "wgTitle"] )', |
| 226 | | - 'true (boolean)' ); |
| 227 | | - |
| 228 | | - mw.test.addTest( 'mw.config.exists( ["wgSomeName", "wgTitle"] )', |
| 229 | | - 'false (boolean)' ); |
| 230 | | - |
| 231 | | - mw.test.addTest( 'mw.config.get( "wgCanonicalNamespace" )', |
| 232 | | - 'Special (string)' ); |
| 233 | | - |
| 234 | | - mw.test.addTest( 'var a = mw.config.get( ["wgCanonicalNamespace"] ); a.wgCanonicalNamespace', |
| 235 | | - 'Special (string)' ); |
| 236 | | - |
| 237 | | - mw.test.addTest( 'typeof mw.html', |
| 238 | | - 'object (string)' ); |
| 239 | | - |
| 240 | | - mw.test.addTest( 'mw.html.escape( \'<mw awesome="awesome">\' )', |
| 241 | | - '<mw awesome="awesome"> (string)' ); |
| 242 | | - |
| 243 | | - mw.test.addTest( 'mw.html.element( "hr" )', |
| 244 | | - '<hr/> (string)' ); |
| 245 | | - |
| 246 | | - mw.test.addTest( 'mw.html.element( "img", { "src": "http://mw.org/?title=Main page&action=edit" } )', |
| 247 | | - '<img src="http://mw.org/?title=Main page&action=edit"/> (string)' ); |
| 248 | | - |
| 249 | | - mw.test.addTest( 'typeof mw.loader', |
| 250 | | - 'object (string)' ); |
| 251 | | - |
| 252 | | - mw.test.addTest( 'typeof mw.loader.using', |
| 253 | | - 'function (string)' ); |
| 254 | | - |
| 255 | | - mw.test.addTest( 'typeof mw.Map', |
| 256 | | - 'function (string)' ); |
| 257 | | - |
| 258 | | - mw.test.addTest( 'typeof mw.user', |
| 259 | | - 'object (string)' ); |
| 260 | | - |
| 261 | | - mw.test.addTest( 'typeof mw.user.anonymous()', |
| 262 | | - 'boolean (string)' ); |
| 263 | | - |
| 264 | | - /** mediawiki.util.js **/ |
| 265 | | - mw.test.addHead( 'mediawiki.util.js' ); |
| 266 | | - |
| 267 | | - mw.test.addTest( 'typeof mw.util', |
| 268 | | - 'object (string)' ); |
| 269 | | - |
| 270 | | - mw.test.addTest( 'typeof mw.util.rawurlencode', |
| 271 | | - 'function (string)' ); |
| 272 | | - |
| 273 | | - mw.test.addTest( 'mw.util.rawurlencode( "Test:A & B/Here" )', |
| 274 | | - 'Test%3AA%20%26%20B%2FHere (string)' ); |
| 275 | | - |
| 276 | | - mw.test.addTest( 'typeof mw.util.wikiUrlencode', |
| 277 | | - 'function (string)' ); |
| 278 | | - |
| 279 | | - mw.test.addTest( 'mw.util.wikiUrlencode( "Test:A & B/Here" )', |
| 280 | | - 'Test:A_%26_B/Here (string)' ); |
| 281 | | - |
| 282 | | - mw.test.addTest( 'typeof mw.util.addCSS', |
| 283 | | - 'function (string)' ); |
| 284 | | - |
| 285 | | - mw.test.addTest( 'var a = mw.util.addCSS( "div#mw-js-message { background-color: rgb(170,255,170); }" ); a.disabled', |
| 286 | | - 'false (boolean)' ); |
| 287 | | - |
| 288 | | - mw.test.addTest( 'typeof mw.util.toggleToc', |
| 289 | | - 'function (string)' ); |
| 290 | | - |
| 291 | | - mw.test.addTest( 'typeof mw.util.wikiGetlink', |
| 292 | | - 'function (string)' ); |
| 293 | | - |
| 294 | | - mw.test.addTest( 'typeof mw.util.getParamValue', |
| 295 | | - 'function (string)' ); |
| 296 | | - |
| 297 | | - mw.test.addTest( 'mw.util.getParamValue( "action" )', |
| 298 | | - 'mwutiltest (string)' ); |
| 299 | | - |
| 300 | | - mw.test.addTest( 'mw.util.getParamValue( "foo", "http://mw.org/?foo=wrong&foo=right#&foo=bad" )', |
| 301 | | - 'right (string)' ); |
| 302 | | - |
| 303 | | - mw.test.addTest( 'typeof mw.util.tooltipAccessKeyPrefix', |
| 304 | | - 'string (string)' ); |
| 305 | | - |
| 306 | | - mw.test.addTest( 'mw.util.tooltipAccessKeyRegexp.constructor.name', |
| 307 | | - 'RegExp (string)' ); |
| 308 | | - |
| 309 | | - mw.test.addTest( 'typeof mw.util.updateTooltipAccessKeys', |
| 310 | | - 'function (string)' ); |
| 311 | | - |
| 312 | | - mw.test.addTest( 'mw.util.$content instanceof jQuery', |
| 313 | | - 'true (boolean)' ); |
| 314 | | - |
| 315 | | - mw.test.addTest( 'mw.util.$content.size()', |
| 316 | | - '1 (number)' ); |
| 317 | | - |
| 318 | | - mw.test.addTest( 'typeof mw.util.addPortletLink', |
| 319 | | - 'function (string)' ); |
| 320 | | - |
| 321 | | - mw.test.addTest( 'typeof mw.util.addPortletLink( "p-tb", "http://mediawiki.org/wiki/ResourceLoader", "ResourceLoader", "t-rl", "More info about ResourceLoader on MediaWiki.org ", "l", "#t-specialpages" )', |
| 322 | | - 'object (string)' ); |
| 323 | | - |
| 324 | | - mw.test.addTest( 'var a = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/", "MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", "#t-rl" ); $(a).text();', |
| 325 | | - 'MediaWiki.org (string)' ); |
| 326 | | - |
| 327 | | - mw.test.addTest( 'typeof mw.util.addPortletLink( "p-tb", "http://www.mediawiki.org/wiki/ResourceLoader/Default_modules", "Default modules", "t-rl", "All default modules present in MediaWiki" )', |
| 328 | | - 'object (string)' ); |
| 329 | | - |
| 330 | | - mw.test.addTest( 'typeof mw.util.jsMessage', |
| 331 | | - 'function (string)' ); |
| 332 | | - |
| 333 | | - mw.test.addTest( 'mw.util.jsMessage( mw.config.get( "wgSiteName" ) + " is <b>Awesome</b>." )', |
| 334 | | - 'true (boolean)' ); |
| 335 | | - |
| 336 | | - mw.test.addTest( 'jQuery( "#mw-js-message" ).css( "background-color" )', |
| 337 | | - 'rgb(170, 255, 170) (string)' ); |
| 338 | | - |
| 339 | | - // TODO: Import tests from PHPUnit test suite for user::isValidEmailAddr |
| 340 | | - mw.test.addTest( 'mw.util.validateEmail( "" )', |
| 341 | | - 'null (object)' ); |
| 342 | | - |
| 343 | | - mw.test.addTest( 'mw.util.validateEmail( "user@localhost" )', |
| 344 | | - 'true (boolean)' ); |
| 345 | | - |
| 346 | | - // testEmailWithCommasAreInvalids |
| 347 | | - mw.test.addTest( 'mw.util.validateEmail( "user,foo@example.org" )', |
| 348 | | - 'false (boolean)' ); |
| 349 | | - mw.test.addTest( 'mw.util.validateEmail( "userfoo@ex,ample.org" )', |
| 350 | | - 'false (boolean)' ); |
| 351 | | - // testEmailWithHyphens |
| 352 | | - mw.test.addTest( 'mw.util.validateEmail( "user-foo@example.org" )', |
| 353 | | - 'true (boolean)' ); |
| 354 | | - mw.test.addTest( 'mw.util.validateEmail( "userfoo@ex-ample.org" )', |
| 355 | | - 'true (boolean)' ); |
| 356 | | - |
| 357 | | - // From IPTest.php IPv6 |
| 358 | | - mw.test.addTest( 'mw.util.isIPv6Address( "" )', |
| 359 | | - 'false (boolean)' ); |
| 360 | | - mw.test.addTest( 'mw.util.isIPv6Address( ":fc:100::" )', |
| 361 | | - 'false (boolean)' ); |
| 362 | | - mw.test.addTest( 'mw.util.isIPv6Address( "fc:100::" )', |
| 363 | | - 'true (boolean)' ); |
| 364 | | - mw.test.addTest( 'mw.util.isIPv6Address( "fc:100:a:d:1:e:ac::" )', |
| 365 | | - 'true (boolean)' ); |
| 366 | | - mw.test.addTest( 'mw.util.isIPv6Address( ":::" )', |
| 367 | | - 'false (boolean)' ); |
| 368 | | - mw.test.addTest( 'mw.util.isIPv6Address( "::0:" )', |
| 369 | | - 'false (boolean)' ); |
| 370 | | - |
| 371 | | - // From IPTest.php IPv4 |
| 372 | | - mw.test.addTest( 'mw.util.isIPv4Address( "" )', |
| 373 | | - 'false (boolean)' ); |
| 374 | | - mw.test.addTest( 'mw.util.isIPv4Address( "...." )', |
| 375 | | - 'false (boolean)' ); |
| 376 | | - mw.test.addTest( 'mw.util.isIPv4Address( "abc" )', |
| 377 | | - 'false (boolean)' ); |
| 378 | | - mw.test.addTest( 'mw.util.isIPv4Address( "124.24.52" )', |
| 379 | | - 'false (boolean)' ); |
| 380 | | - mw.test.addTest( 'mw.util.isIPv4Address( ".24.52.13" )', |
| 381 | | - 'false (boolean)' ); |
| 382 | | - mw.test.addTest( 'mw.util.isIPv4Address( "124.24.52.13" )', |
| 383 | | - 'true (boolean)' ); |
| 384 | | - mw.test.addTest( 'mw.util.isIPv4Address( "1.24.52.13" )', |
| 385 | | - 'true (boolean)' ); |
| 386 | | - mw.test.addTest( 'mw.util.isIPv4Address( "74.24.52.13/20" )', // Range |
| 387 | | - 'false (boolean)' ); |
| 388 | | - // @FIXME: The regex that's been in MW JS has never supported ranges but it should |
| 389 | | - // The regex is expected to return false for that reason |
| 390 | | - |
| 391 | | - // jQuery plugins |
| 392 | | - mw.test.addHead( 'jQuery plugins' ); |
| 393 | | - |
| 394 | | - mw.test.addTest( 'typeof $.client', |
| 395 | | - 'object (string)' ); |
| 396 | | - |
| 397 | | - mw.test.addTest( 'typeof $.client.profile', |
| 398 | | - 'function (string)' ); |
| 399 | | - |
| 400 | | - mw.test.addTest( 'var a = $.client.profile(); typeof a.name', |
| 401 | | - 'string (string)' ); |
| 402 | | - |
| 403 | | - mw.test.addTest( 'typeof $.fn.makeCollapsible', |
| 404 | | - 'function (string)' ); |
| 405 | | - |
| 406 | | - |
| 407 | | - // End of tests. |
| 408 | | - mw.test.addHead( '*** End of tests ***' ); |
| 409 | | - |
| 410 | | - // Run tests and compare results |
| 411 | | - var exec, |
| 412 | | - result, |
| 413 | | - resulttype, |
| 414 | | - numberOfTests = 0, |
| 415 | | - numberOfPasseds = 0, |
| 416 | | - numberOfPartials = 0, |
| 417 | | - numberOfErrors = 0, |
| 418 | | - headNumberOfTests = 0, |
| 419 | | - headNumberOfPasseds = 0, |
| 420 | | - headNumberOfPartials = 0, |
| 421 | | - headNumberOfErrors = 0, |
| 422 | | - numberOfHeaders = 0, |
| 423 | | - previousHeadTitle = '', |
| 424 | | - $testrows = mw.test.$table.find( 'tr:has(td)' ); |
| 425 | | - |
| 426 | | - $.each( mw.test.addedTests, function( i, item ) { |
| 427 | | - |
| 428 | | - // New header |
| 429 | | - if( item[0] == 'HEADER' ) { |
| 430 | | - |
| 431 | | - // update current header with its tests results |
| 432 | | - mw.test.$table.find( 'tr#mw-mwutiltest-head' + numberOfHeaders +' > th' ) |
| 433 | | - .html( previousHeadTitle + ' <span style="float:right">(' |
| 434 | | - + 'Tests: ' + headNumberOfTests |
| 435 | | - + ' OK: ' + headNumberOfPasseds |
| 436 | | - + ' Partial: ' + headNumberOfPartials |
| 437 | | - + ' Error: ' + headNumberOfErrors |
| 438 | | - + ')</span>' ); |
| 439 | | - |
| 440 | | - numberOfHeaders++; |
| 441 | | - // Reset values for the new header; |
| 442 | | - headNumberOfTests = 0; |
| 443 | | - headNumberOfPasseds = 0; |
| 444 | | - headNumberOfPartials = 0; |
| 445 | | - headNumberOfErrors = 0; |
| 446 | | - |
| 447 | | - previousHeadTitle = item[1]; |
| 448 | | - |
| 449 | | - return true; |
| 450 | | - } |
| 451 | | - |
| 452 | | - exec = item[0]; |
| 453 | | - var shouldreturn = item[1]; |
| 454 | | - var shouldcontain = item[2]; |
| 455 | | - |
| 456 | | - numberOfTests++; |
| 457 | | - headNumberOfTests++; |
| 458 | | - try { |
| 459 | | - var doesReturn = eval( exec ); |
| 460 | | - } catch (e){ |
| 461 | | - mw.log ('mw.util.test> ' + e ); |
| 462 | | - } |
| 463 | | - doesReturn = doesReturn + ' (' + typeof doesReturn + ')'; |
| 464 | | - var $thisrow = $testrows.eq( i - numberOfHeaders ); // since headers are rows as well |
| 465 | | - $thisrow.find( '> td' ) |
| 466 | | - .eq(2) |
| 467 | | - .html( mw.html.escape( doesReturn ).replace(/ /g, ' ' ) ); |
| 468 | | - |
| 469 | | - if ( doesReturn.indexOf( shouldcontain ) !== -1 ) { |
| 470 | | - if ( doesReturn == shouldreturn ) { |
| 471 | | - $thisrow.find( '>td' ).eq(3).css( 'background', '#AFA' ).text( 'OK' ); |
| 472 | | - numberOfPasseds++; |
| 473 | | - headNumberOfPasseds++; |
| 474 | | - } else { |
| 475 | | - $thisrow.find( '>td' ).eq(3).css( 'background', '#FFA' ).html( '<small>PARTIALLY</small>' ); |
| 476 | | - numberOfPartials++; |
| 477 | | - headNumberOfPartials++; |
| 478 | | - } |
| 479 | | - } else { |
| 480 | | - $thisrow.css( 'background', '#FAA' ).find( '>td' ).eq(3).text( 'ERROR' ); |
| 481 | | - numberOfErrors++; |
| 482 | | - headNumberOfErrors++; |
| 483 | | - } |
| 484 | | - |
| 485 | | - } ); |
| 486 | | - mw.test.$table.before( '<p><strong>Ran ' + numberOfTests + ' tests. ' + |
| 487 | | - numberOfPasseds + ' passed test(s). ' + numberOfErrors + ' error(s). ' + |
| 488 | | - numberOfPartials + ' partially passed test(s). </p>' ); |
| 489 | | - |
| 490 | | - } |
| 491 | | - } ); |
| 492 | | - } |
| 493 | | - } |
| 494 | | - }; |
| 495 | | - |
| 496 | | - mw.test.init(); |
| 497 | | - |
| 498 | | -} )(jQuery, mediaWiki); |
| \ No newline at end of file |
| Index: trunk/phase3/resources/Resources.php |
| — | — | @@ -444,7 +444,6 @@ |
| 445 | 445 | 'jquery.makeCollapsible', |
| 446 | 446 | 'jquery.placeholder', |
| 447 | 447 | ), |
| 448 | | - 'debugScripts' => 'resources/mediawiki.util/mediawiki.util.test.js', |
| 449 | 448 | ), |
| 450 | 449 | 'mediawiki.util.jpegmeta' => array( |
| 451 | 450 | 'scripts' => 'resources/mediawiki.util/mediawiki.util.jpegmeta.js', |