webapps

view DOMCore/tests/submissions/Ms2ger/Document-getElementsByTagName.html @ 549:2de86e9886ef

Add test for tagName
author Ms2ger <ms2ger@gmail.com>
date Tue, 05 Jul 2011 14:49:03 +0200
parents 2cacf695d391
children a88b5a758f9a
line source
1 <!DOCTYPE html>
2 <title>Document.getElementsByTagName</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <body>
6 <div id="log"></div>
7 <script>
8 test(function() {
9 assert_true(document.getElementsByTagName("html") instanceof NodeList, "NodeList")
10 assert_false(document.getElementsByTagName("html") instanceof HTMLCollection, "HTMLCollection")
11 assert_true(document.getElementsByTagName("html") !== document.getElementsByTagName("html"), "no caching")
12 })
13 test(function() {
14 var l = document.getElementsByTagName("nosuchtag")
15 l[5] = "foopy"
16 assert_equals(l.item(5), null)
17 }, "Expandos shouldn't affect item()")
18 test(function() {
19 assert_equals(document.createElementNS("http://www.w3.org/1999/xhtml", "i").localName, "i") // Sanity
20 var i = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "I"))
21 assert_equals(i.localName, "I")
22 assert_equals(i.tagName, "I")
23 assert_equals(document.getElementsByTagName("I").length, 0)
24 assert_equals(document.getElementsByTagName("i").length, 0)
25 assert_equals(document.body.getElementsByTagName("I").length, 0)
26 assert_equals(document.body.getElementsByTagName("i").length, 0)
27 })
28 test(function() {
29 var t = document.body.appendChild(document.createElementNS("test", "te:st"))
30 assert_equals(document.getElementsByTagName("st").length, 0)
31 assert_equals(document.getElementsByTagName("te:st")[0], t)
32 })
33 test(function() {
34 var h = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "te:st"))
35 assert_equals(document.getElementsByTagName("st")[0], h)
36 assert_equals(document.getElementsByTagName("TE:ST").length, 0)
37 })
38 </script>
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.