diff options
author | jaubourg <j@ubourg.net> | 2011-07-23 03:26:36 +0200 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-07-23 03:26:36 +0200 |
commit | 27291ff06ddb655f90a8d1eada71f7ac61499b12 (patch) | |
tree | ca9c6afc65281f764b00208bb45ce635d95fe744 /test/unit | |
parent | 0ed99097bda3bb6e302c3d93331f0e7312e42077 (diff) | |
download | jquery-27291ff06ddb655f90a8d1eada71f7ac61499b12.tar.gz jquery-27291ff06ddb655f90a8d1eada71f7ac61499b12.zip |
Fixes #9255: xml parsing error in $.parseXML is now properly detected for all browsers. Unit test added.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/core.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/unit/core.js b/test/unit/core.js index 3a1553526..8c285f6dd 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -867,7 +867,7 @@ test("jQuery.each(Object,Function)", function() { f[i] = "baz"; }); equals( "baz", f.foo, "Loop over a function" ); - + var stylesheet_count = 0; jQuery.each(document.styleSheets, function(i){ stylesheet_count++; @@ -984,6 +984,26 @@ test("jQuery.parseJSON", function(){ } }); +test("jQuery.parseXML", 4, function(){ + var xml, tmp; + try { + xml = jQuery.parseXML( "<p>A <b>well-formed</b> xml string</p>" ); + tmp = xml.getElementsByTagName( "p" )[ 0 ]; + ok( !!tmp, "<p> present in document" ); + tmp = tmp.getElementsByTagName( "b" )[ 0 ]; + ok( !!tmp, "<b> present in document" ); + strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", "<b> text is as expected" ); + } catch (e) { + strictEqual( e, undefined, "unexpected error" ); + } + try { + xml = jQuery.parseXML( "<p>Not a <<b>well-formed</b> xml string</p>" ); + ok( false, "invalid xml not detected" ); + } catch( e ) { + strictEqual( e, "Invalid XML: <p>Not a <<b>well-formed</b> xml string</p>", "invalid xml detected" ); + } +}); + test("jQuery.sub() - Static Methods", function(){ expect(18); var Subclass = jQuery.sub(); @@ -1108,7 +1128,7 @@ test("jQuery.sub() - .fn Methods", function(){ test("jQuery.camelCase()", function() { var tests = { - "foo-bar": "fooBar", + "foo-bar": "fooBar", "foo-bar-baz": "fooBarBaz" }; |