Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | // Build page |
71 | 71 | document.title = 'mediaWiki JavaScript library test suite - ' + mw.config.get( 'wgSiteName' ); |
72 | 72 | $( '#firstHeading' ).text( 'mediaWiki JavaScript library test suite' ); |
73 | | - var skinLinksText = 'Test in: '; |
| 73 | + var skinLinksText = 'Test in: ', |
74 | 74 | skinLinks = [], |
75 | 75 | availableSkins = mw.config.get( 'wgAvailableSkins' ), |
76 | 76 | skincode = ''; |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | // Try to roughly keep the order similar to the order in the files |
101 | 101 | // or alphabetical (depending on the context) |
102 | 102 | |
103 | | - // Main modules and their aliases |
| 103 | + /** Main modules and their aliases **/ |
104 | 104 | mw.test.addHead( 'Main modules and their aliases' ); |
105 | 105 | |
106 | 106 | mw.test.addTest( 'typeof mediaWiki', |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | mw.test.addTest( 'typeof $', |
116 | 116 | 'function (string)' ); |
117 | 117 | |
118 | | - // Prototype functions added by MediaWiki |
| 118 | + /** Prototype functions added by MediaWiki **/ |
119 | 119 | mw.test.addHead( 'Prototype functions added by MediaWiki' ); |
120 | 120 | |
121 | 121 | mw.test.addTest( 'typeof $.trimLeft', |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | mw.test.addTest( 'typeof $.compareObject', |
167 | 167 | 'function (string)' ); |
168 | 168 | |
169 | | - // mediawiki.js |
| 169 | + /** mediawiki.js **/ |
170 | 170 | mw.test.addHead( 'mediawiki.js' ); |
171 | 171 | |
172 | 172 | mw.test.addTest( 'mw.config instanceof mw.Map', |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | mw.test.addTest( 'typeof mw.user.anonymous()', |
218 | 218 | 'boolean (string)' ); |
219 | 219 | |
220 | | - // mediawiki.util.js |
| 220 | + /** mediawiki.util.js **/ |
221 | 221 | mw.test.addHead( 'mediawiki.util.js' ); |
222 | 222 | |
223 | 223 | mw.test.addTest( 'typeof mw.util', |
— | — | @@ -298,6 +298,40 @@ |
299 | 299 | mw.test.addTest( 'mw.util.validateEmail( "userfoo@ex-ample.org" )', |
300 | 300 | 'true (boolean)' ); |
301 | 301 | |
| 302 | + // From IPTest.php IPv6 |
| 303 | + mw.test.addTest( 'mw.util.isIPv6Address( "" )', |
| 304 | + 'false (boolean)' ); |
| 305 | + mw.test.addTest( 'mw.util.isIPv6Address( ":fc:100::" )', |
| 306 | + 'false (boolean)' ); |
| 307 | + mw.test.addTest( 'mw.util.isIPv6Address( "fc:100::" )', |
| 308 | + 'true (boolean)' ); |
| 309 | + mw.test.addTest( 'mw.util.isIPv6Address( "fc:100:a:d:1:e:ac::" )', |
| 310 | + 'true (boolean)' ); |
| 311 | + mw.test.addTest( 'mw.util.isIPv6Address( ":::" )', |
| 312 | + 'false (boolean)' ); |
| 313 | + mw.test.addTest( 'mw.util.isIPv6Address( "::0:" )', |
| 314 | + 'false (boolean)' ); |
| 315 | + |
| 316 | + // From IPTest.php IPv4 |
| 317 | + mw.test.addTest( 'mw.util.isIPv4Address( "" )', |
| 318 | + 'false (boolean)' ); |
| 319 | + mw.test.addTest( 'mw.util.isIPv4Address( "...." )', |
| 320 | + 'false (boolean)' ); |
| 321 | + mw.test.addTest( 'mw.util.isIPv4Address( "abc" )', |
| 322 | + 'false (boolean)' ); |
| 323 | + mw.test.addTest( 'mw.util.isIPv4Address( "124.24.52" )', |
| 324 | + 'false (boolean)' ); |
| 325 | + mw.test.addTest( 'mw.util.isIPv4Address( ".24.52.13" )', |
| 326 | + 'false (boolean)' ); |
| 327 | + mw.test.addTest( 'mw.util.isIPv4Address( "124.24.52.13" )', |
| 328 | + 'true (boolean)' ); |
| 329 | + mw.test.addTest( 'mw.util.isIPv4Address( "1.24.52.13" )', |
| 330 | + 'true (boolean)' ); |
| 331 | + mw.test.addTest( 'mw.util.isIPv4Address( "74.24.52.13/20" )', // Range |
| 332 | + 'false (boolean)' ); |
| 333 | + // @FIXME: The regex that's been in MW JS has never supported ranges but it should |
| 334 | + // The regex is expected to return false for that reason |
| 335 | + |
302 | 336 | // jQuery plugins |
303 | 337 | mw.test.addHead( 'jQuery plugins' ); |
304 | 338 | |
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -545,14 +545,14 @@ |
546 | 546 | ); |
547 | 547 | return (null !== mailtxt.match( HTML5_email_regexp ) ); |
548 | 548 | }, |
549 | | - // Note: borrows from IP.php |
| 549 | + // Note: borrows from IP::isIPv4 |
550 | 550 | 'isIPv4Address' : function( address, allowBlock ) { |
551 | 551 | var block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : ''; |
552 | 552 | var RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])'; |
553 | 553 | var RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE; |
554 | 554 | return address.search( new RegExp( '^' + RE_IP_ADD + block + '$' ) ) != -1; |
555 | 555 | }, |
556 | | - // Note: borrows from IP.php |
| 556 | + // Note: borrows from IP::isIPv6 |
557 | 557 | 'isIPv6Address' : function( address, allowBlock ) { |
558 | 558 | var block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : ''; |
559 | 559 | var RE_IPV6_ADD = |