Make sure leading whitespace is trimmed for parseJSON. Fixes #6031.
[jquery.git] / test / unit / core.js
index 4576ab8..d8aba16 100644 (file)
@@ -807,7 +807,7 @@ test("jQuery.proxy", function(){
 });
 
 test("jQuery.parseJSON", function(){
-       expect(7);
+       expect(8);
        
        equals( jQuery.parseJSON(), null, "Nothing in, null out." );
        equals( jQuery.parseJSON( null ), null, "Nothing in, null out." );
@@ -815,6 +815,8 @@ test("jQuery.parseJSON", function(){
        
        same( jQuery.parseJSON("{}"), {}, "Plain object parsing." );
        same( jQuery.parseJSON('{"test":1}'), {"test":1}, "Plain object parsing." );
+
+       same( jQuery.parseJSON('\n{"test":1}'), {"test":1}, "Make sure leading whitespaces are handled." );
        
        try {
                jQuery.parseJSON("{a:1}");
@@ -829,4 +831,4 @@ test("jQuery.parseJSON", function(){
        } catch( e ) {
                ok( true, "Test malformed JSON string." );
        }
-});
\ No newline at end of file
+});