Adding unit test for bug 27427. Currently broken. Fix (provided by Michael M. through...
authorKrinkle <krinkle@users.mediawiki.org>
Sat, 30 Jul 2011 07:38:01 +0000 (07:38 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sat, 30 Jul 2011 07:38:01 +0000 (07:38 +0000)
* (bug 27427) mw.util.getParamValue shouldn't return value from hash even if param is only present in hash

CREDITS
tests/qunit/suites/resources/mediawiki/mediawiki.util.js

diff --git a/CREDITS b/CREDITS
index 25e5d2a..06108ad 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -122,6 +122,7 @@ following names for their contribution to the product.
 * Max Sikström
 * Michael Dale
 * Michael De La Rue
+* Michael M.
 * Michael Walsh
 * Mike Horvath
 * Mormegil
index 7fb8fe9..4dfb0dc 100644 (file)
@@ -107,12 +107,15 @@ test( 'toggleToc', function() {
 });
 
 test( 'getParamValue', function() {
-       expect(2);
+       expect(3);
+
+       var     url1 = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad';
 
-       var url = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad';
+       equal( mw.util.getParamValue( 'foo', url1 ), 'right', 'Use latest one, ignore hash' );
+       strictEqual( mw.util.getParamValue( 'bar', url1 ), null, 'Return null when not found' );
 
-       equal( mw.util.getParamValue( 'foo', url ), 'right', 'Use latest one, ignore hash' );
-       strictEqual( mw.util.getParamValue( 'bar', url ), null, 'Return null when not found' );
+       var url2 = 'http://mediawiki.org/#&foo=bad';
+       strictEqual( mw.util.getParamValue( 'foo', url2 ), null, 'Ignore hash if param is not in querystring but in hash (bug 27427)' );
 });
 
 test( 'tooltipAccessKey', function() {