Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js |
— | — | @@ -89,8 +89,7 @@ |
90 | 90 | ); |
91 | 91 | |
92 | 92 | mw.util.addCSS( |
93 | | - '#mw-mwutiltest-table tr td { padding:0 !important; }' + // Override wikitable padding for <td> |
94 | | - '.mw-mwutiltest-head:hover { cursor: pointer; } ' // Header-clicks hide/show the below rows |
| 93 | + '#mw-mwutiltest-table tr td { padding:0 !important; }' // Override wikitable padding for <td> |
95 | 94 | ); |
96 | 95 | |
97 | 96 | mw.test.$table = $( 'table#mw-mwutiltest-table' ); |
— | — | @@ -150,6 +149,30 @@ |
151 | 150 | mw.test.addTest( '$.escapeRE( "0123456789" )', |
152 | 151 | '0123456789 (string)' ); |
153 | 152 | |
| 153 | + mw.test.addTest( '$.isDomElement( document.getElementById("mw-mwutiltest-table") )', |
| 154 | + 'true (boolean)' ); |
| 155 | + |
| 156 | + mw.test.addTest( '$.isDomElement( document.getElementById("not-existant-id") )', |
| 157 | + 'false (boolean)' ); // returns null |
| 158 | + |
| 159 | + mw.test.addTest( '$.isDomElement( document.getElementsByClassName("wikitable") )', |
| 160 | + 'false (boolean)' ); // returns an array |
| 161 | + |
| 162 | + mw.test.addTest( '$.isDomElement( document.getElementsByClassName("wikitable")[0] )', |
| 163 | + 'true (boolean)' ); |
| 164 | + |
| 165 | + mw.test.addTest( '$.isDomElement( jQuery( "#mw-mwutiltest-table" ) )', |
| 166 | + 'false (boolean)' ); // returns jQuery object |
| 167 | + |
| 168 | + mw.test.addTest( '$.isDomElement( jQuery( "#mw-mwutiltest-table" ).get(0) )', |
| 169 | + 'true (boolean)' ); |
| 170 | + |
| 171 | + mw.test.addTest( '$.isDomElement( document.createElement( "div" ) )', |
| 172 | + 'true (boolean)' ); |
| 173 | + |
| 174 | + mw.test.addTest( '$.isDomElement( {some: "thing" } )', |
| 175 | + 'false (boolean)' ); |
| 176 | + |
154 | 177 | mw.test.addTest( 'typeof $.isEmpty', |
155 | 178 | 'function (string)' ); |
156 | 179 | |
— | — | @@ -192,11 +215,11 @@ |
193 | 216 | mw.test.addTest( 'mw.config.exists( ["wgSomeName", "wgTitle"] )', |
194 | 217 | 'false (boolean)' ); |
195 | 218 | |
196 | | - mw.test.addTest( 'mw.config.get( "wgTitle" )', |
197 | | - 'BlankPage (string)' ); |
| 219 | + mw.test.addTest( 'mw.config.get( "wgCanonicalNamespace" )', |
| 220 | + 'Special (string)' ); |
198 | 221 | |
199 | | - mw.test.addTest( 'var a = mw.config.get( ["wgTitle"] ); a.wgTitle', |
200 | | - 'BlankPage (string)' ); |
| 222 | + mw.test.addTest( 'var a = mw.config.get( ["wgCanonicalNamespace"] ); a.wgCanonicalNamespace', |
| 223 | + 'Special (string)' ); |
201 | 224 | |
202 | 225 | mw.test.addTest( 'typeof mw.html', |
203 | 226 | 'object (string)' ); |
— | — | @@ -246,10 +269,13 @@ |
247 | 270 | mw.test.addTest( 'typeof mw.util.addCSS', |
248 | 271 | 'function (string)' ); |
249 | 272 | |
250 | | - mw.test.addTest( 'var a = mw.util.addCSS( ".plainlinks { color:green; }" ); a.disabled;', |
| 273 | + mw.test.addTest( 'var a = mw.util.addCSS( "#mw-js-message { background-color: #AFA !important; }" ); a.disabled;', |
251 | 274 | 'false (boolean)', |
252 | 275 | '(boolean)' ); |
253 | 276 | |
| 277 | + mw.test.addTest( 'typeof mw.util.toggleToc', |
| 278 | + 'function (string)' ); |
| 279 | + |
254 | 280 | mw.test.addTest( 'typeof mw.util.wikiGetlink', |
255 | 281 | 'function (string)' ); |
256 | 282 | |
— | — | @@ -262,6 +288,9 @@ |
263 | 289 | mw.test.addTest( 'mw.util.getParamValue( "foo", "http://mw.org/?foo=wrong&foo=right#&foo=bad" )', |
264 | 290 | 'right (string)' ); |
265 | 291 | |
| 292 | + mw.test.addTest( 'typeof mw.util.tooltipAccessKeyPrefix', |
| 293 | + 'string (string)' ); |
| 294 | + |
266 | 295 | mw.test.addTest( 'mw.util.tooltipAccessKeyRegexp.constructor.name', |
267 | 296 | 'RegExp (string)' ); |
268 | 297 | |
— | — | @@ -274,6 +303,9 @@ |
275 | 304 | mw.test.addTest( 'mw.util.$content.size()', |
276 | 305 | '1 (number)' ); |
277 | 306 | |
| 307 | + mw.test.addTest( 'mw.util.isMainPage()', |
| 308 | + 'false (boolean)' ); |
| 309 | + |
278 | 310 | mw.test.addTest( 'typeof mw.util.addPortletLink', |
279 | 311 | 'function (string)' ); |
280 | 312 | |
— | — | @@ -408,7 +440,11 @@ |
409 | 441 | |
410 | 442 | numberOfTests++; |
411 | 443 | headNumberOfTests++; |
412 | | - var doesReturn = eval( exec ); |
| 444 | + try { |
| 445 | + var doesReturn = eval( exec ); |
| 446 | + } catch (e){ |
| 447 | + mw.log ('mw.util.test> ' + e ); |
| 448 | + } |
413 | 449 | doesReturn = doesReturn + ' (' + typeof doesReturn + ')'; |
414 | 450 | var $thisrow = $testrows.eq( i - numberOfHeaders ); // since headers are rows as well |
415 | 451 | $thisrow.find( '> td' ).eq(2).html( mw.html.escape( doesReturn ).replace(/ /g, ' ' ) ); |
— | — | @@ -424,7 +460,7 @@ |
425 | 461 | headNumberOfPartials++; |
426 | 462 | } |
427 | 463 | } else { |
428 | | - $thisrow.find( '> td' ).eq(3).css( 'background', '#FAA' ).text( 'ERROR' ); |
| 464 | + $thisrow.css( 'background', '#FAA' ).find( '> td' ).eq(3).text( 'ERROR' ); |
429 | 465 | numberOfErrors++; |
430 | 466 | headNumberOfErrors++; |
431 | 467 | } |
— | — | @@ -434,12 +470,6 @@ |
435 | 471 | numberOfPasseds + ' passed test(s). ' + numberOfErrors + ' error(s). ' + |
436 | 472 | numberOfPartials + ' partially passed test(s). </p>' ); |
437 | 473 | |
438 | | - // hide all tests. TODO hide only OK? |
439 | | - mw.test.$table.find( '.mw-mwutiltest-test' ).hide(); |
440 | | - // clickable header to show/hide the tests |
441 | | - mw.test.$table.find( '.mw-mwutiltest-head' ).click(function() { |
442 | | - $(this).nextUntil( '.mw-mwutiltest-head' ).toggle(); |
443 | | - }); |
444 | 474 | } |
445 | 475 | } ); |
446 | 476 | } |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -16,14 +16,8 @@ |
17 | 17 | escapeRE : function( str ) { |
18 | 18 | return str.replace ( /([\\{}()|.?*+\-^$\[\]])/g, "\\$1" ); |
19 | 19 | }, |
20 | | - // $.isDomElement( document.getElementById('content') ) === true |
21 | | - // $.isDomElement( document.getElementsByClassName('portal') ) === false (array) |
22 | | - // $.isDomElement( document.getElementsByClassName('portal')[0] ) === true |
23 | | - // $.isDomElement( $('#content') ) === false (jQuery object) |
24 | | - // $.isDomElement( $('#content').get(0) ) === true |
25 | | - // $.isDomElement( 'hello world' ) === false |
26 | 20 | isDomElement : function( el ) { |
27 | | - return !!el.nodeType; |
| 21 | + return !!el && !!el.nodeType; |
28 | 22 | }, |
29 | 23 | isEmpty : function( v ) { |
30 | 24 | var key; |