diff options
author | jaubourg <j@ubourg.net> | 2012-03-07 17:37:14 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2012-03-07 17:37:14 +0100 |
commit | d30859eb6bd5af9aafa9db003e17835ff594d019 (patch) | |
tree | 8c1063cbc91b2dd4d363c0a7ab454b3e0d8bad6e /test/unit/core.js | |
parent | bd56456b1e886c7b03211212ac3c0a6a310b5cde (diff) | |
download | jquery-d30859eb6bd5af9aafa9db003e17835ff594d019.tar.gz jquery-d30859eb6bd5af9aafa9db003e17835ff594d019.zip |
Makes parseXML act like parseJSON when given an empty or non-string input: now returns null rather than throwing an exception. Incidently fixes #10527. Unit tests added.
Diffstat (limited to 'test/unit/core.js')
-rw-r--r-- | test/unit/core.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/unit/core.js b/test/unit/core.js index 23642e03d..e87c10664 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1113,7 +1113,7 @@ test("jQuery.parseJSON", function(){ } }); -test("jQuery.parseXML", 4, function(){ +test("jQuery.parseXML", 8, function(){ var xml, tmp; try { xml = jQuery.parseXML( "<p>A <b>well-formed</b> xml string</p>" ); @@ -1131,6 +1131,18 @@ test("jQuery.parseXML", 4, function(){ } catch( e ) { strictEqual( e.message, "Invalid XML: <p>Not a <<b>well-formed</b> xml string</p>", "invalid xml detected" ); } + try { + xml = jQuery.parseXML( "" ); + strictEqual( xml, null, "empty string => null document" ); + xml = jQuery.parseXML(); + strictEqual( xml, null, "undefined string => null document" ); + xml = jQuery.parseXML( null ); + strictEqual( xml, null, "null string => null document" ); + xml = jQuery.parseXML( true ); + strictEqual( xml, null, "non-string => null document" ); + } catch( e ) { + ok( false, "empty input throws exception" ); + } }); test("jQuery.sub() - Static Methods", function(){ |