| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
gTestfile = '13.5.4.2.js'; |
| 8 |
|
| 9 |
START("13.5.4.2 - XMLList attribute()"); |
| 10 |
|
| 11 |
TEST(1, true, XMLList.prototype.hasOwnProperty("attribute")); |
| 12 |
|
| 13 |
|
| 14 |
emps = new XMLList(); |
| 15 |
TEST(2, "xml", typeof(emps.attribute("id"))); |
| 16 |
TEST_XML(3, "", emps.attribute("id")); |
| 17 |
|
| 18 |
|
| 19 |
emps += <employee id="0"><name>Jim</name><age>25</age></employee>; |
| 20 |
|
| 21 |
TEST(4, "xml", typeof(emps.attribute("id"))); |
| 22 |
TEST_XML(5, 0, emps.attribute("id")); |
| 23 |
|
| 24 |
|
| 25 |
emps += <employee id="1"><name>Joe</name><age>20</age></employee>; |
| 26 |
TEST(6, "xml", typeof(emps.attribute("id"))); |
| 27 |
|
| 28 |
correct = new XMLList(); |
| 29 |
correct += new XML("0"); |
| 30 |
correct += new XML("1"); |
| 31 |
TEST(7, correct, emps.attribute("id")); |
| 32 |
|
| 33 |
|
| 34 |
TEST(8, "xml", typeof(emps.attribute("foobar"))); |
| 35 |
|
| 36 |
|
| 37 |
try { |
| 38 |
emps.attribute(null); |
| 39 |
SHOULD_THROW(9); |
| 40 |
} catch (ex) { |
| 41 |
TEST(9, "TypeError", ex.name); |
| 42 |
} |
| 43 |
|
| 44 |
try { |
| 45 |
emps.attribute(undefined); |
| 46 |
SHOULD_THROW(10); |
| 47 |
} catch (ex) { |
| 48 |
TEST(10, "TypeError", ex.name); |
| 49 |
} |
| 50 |
|
| 51 |
END(); |