| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/element-traversal.js"></script> | 7 <script> |
| 8 description("This test checks the implementation of the ElementTraversal API."); |
| 9 |
| 10 debug('Test with no children'); |
| 11 var noChildren = document.createElement('div'); |
| 12 |
| 13 shouldBe("noChildren.firstElementChild", "null"); |
| 14 shouldBe("noChildren.lastElementChild", "null"); |
| 15 shouldBe("noChildren.previousElementSibling", "null"); |
| 16 shouldBe("noChildren.nextElementSibling", "null"); |
| 17 shouldBe("noChildren.childElementCount", "0"); |
| 18 |
| 19 debug('Test with no element children'); |
| 20 var noElementChildren = document.createElement('div'); |
| 21 noElementChildren.appendChild(document.createComment("comment but not an element
")); |
| 22 noElementChildren.appendChild(document.createTextNode("no elements here")); |
| 23 |
| 24 shouldBe("noElementChildren.firstElementChild", "null"); |
| 25 shouldBe("noElementChildren.lastElementChild", "null"); |
| 26 shouldBe("noElementChildren.previousElementSibling", "null"); |
| 27 shouldBe("noElementChildren.nextElementSibling", "null"); |
| 28 shouldBe("noElementChildren.childElementCount", "0"); |
| 29 |
| 30 debug('Test with elements'); |
| 31 var children = document.createElement('div'); |
| 32 children.appendChild(document.createComment("first comment")); |
| 33 var first = document.createElement('p'); |
| 34 children.appendChild(first); |
| 35 children.appendChild(document.createComment("a comment")); |
| 36 var last = document.createElement('p'); |
| 37 children.appendChild(last); |
| 38 children.appendChild(document.createComment("last comment")); |
| 39 |
| 40 shouldBe("children.firstElementChild", "first"); |
| 41 shouldBe("children.lastElementChild", "last"); |
| 42 shouldBe("first.nextElementSibling", "last"); |
| 43 shouldBe("first.nextElementSibling.nextElementSibling", "null"); |
| 44 shouldBe("last.previousElementSibling", "first"); |
| 45 shouldBe("last.previousElementSibling.previousElementSibling", "null"); |
| 46 shouldBe("children.childElementCount", "2"); |
| 47 </script> |
| 8 </body> | 48 </body> |
| 9 </html> | 49 </html> |
| OLD | NEW |