1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/test/unit/test_xml_parser.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +function run_test () { 1.5 + for (var i = 0; i < tests.length && tests[i][0]; ++i) { 1.6 + if (!tests[i][0].call()) { 1.7 + do_throw(tests[i][1]); 1.8 + } 1.9 + } 1.10 +} 1.11 + 1.12 +var tests = [ 1.13 + [ test1, "Unable to parse basic XML document" ], 1.14 + [ test2, "ParseXML doesn't return nsIDOMDocument" ], 1.15 + [ test3, "ParseXML return value's documentElement is not nsIDOMElement" ], 1.16 + [ test4, "" ], 1.17 + [ test5, "" ], 1.18 + [ test6, "" ], 1.19 + [ null ] 1.20 +]; 1.21 + 1.22 +function test1() { 1.23 + return ParseXML("<root/>"); 1.24 +} 1.25 + 1.26 +function test2() { 1.27 + return (ParseXML("<root/>") instanceof nsIDOMDocument); 1.28 +} 1.29 + 1.30 +function test3() { 1.31 + return (ParseXML("<root/>").documentElement instanceof nsIDOMElement); 1.32 +} 1.33 + 1.34 +function test4() { 1.35 + var doc = ParseXML("<root/>"); 1.36 + do_check_eq(doc.documentElement.namespaceURI, null); 1.37 + return true; 1.38 +} 1.39 + 1.40 +function test5() { 1.41 + var doc = ParseXML("<root xmlns=''/>"); 1.42 + do_check_eq(doc.documentElement.namespaceURI, null); 1.43 + return true; 1.44 +} 1.45 + 1.46 +function test6() { 1.47 + var doc = ParseXML("<root xmlns='ns1'/>"); 1.48 + do_check_neq(doc.documentElement.namespaceURI, null); 1.49 + do_check_eq(doc.documentElement.namespaceURI, 'ns1'); 1.50 + return true; 1.51 +}