|
1 function run_test () { |
|
2 for (var i = 0; i < tests.length && tests[i][0]; ++i) { |
|
3 if (!tests[i][0].call()) { |
|
4 do_throw(tests[i][1]); |
|
5 } |
|
6 } |
|
7 } |
|
8 |
|
9 var tests = [ |
|
10 [ test1, "Unable to parse basic XML document" ], |
|
11 [ test2, "ParseXML doesn't return nsIDOMDocument" ], |
|
12 [ test3, "ParseXML return value's documentElement is not nsIDOMElement" ], |
|
13 [ test4, "" ], |
|
14 [ test5, "" ], |
|
15 [ test6, "" ], |
|
16 [ null ] |
|
17 ]; |
|
18 |
|
19 function test1() { |
|
20 return ParseXML("<root/>"); |
|
21 } |
|
22 |
|
23 function test2() { |
|
24 return (ParseXML("<root/>") instanceof nsIDOMDocument); |
|
25 } |
|
26 |
|
27 function test3() { |
|
28 return (ParseXML("<root/>").documentElement instanceof nsIDOMElement); |
|
29 } |
|
30 |
|
31 function test4() { |
|
32 var doc = ParseXML("<root/>"); |
|
33 do_check_eq(doc.documentElement.namespaceURI, null); |
|
34 return true; |
|
35 } |
|
36 |
|
37 function test5() { |
|
38 var doc = ParseXML("<root xmlns=''/>"); |
|
39 do_check_eq(doc.documentElement.namespaceURI, null); |
|
40 return true; |
|
41 } |
|
42 |
|
43 function test6() { |
|
44 var doc = ParseXML("<root xmlns='ns1'/>"); |
|
45 do_check_neq(doc.documentElement.namespaceURI, null); |
|
46 do_check_eq(doc.documentElement.namespaceURI, 'ns1'); |
|
47 return true; |
|
48 } |