Skip to content

Commit a36409b

Browse files
committed
Merge pull request #245 from Ms2ger/HTMLCollection-empty-name
Add a test for empty names in HTMLCollection in DOM.
2 parents 82aba0e + b3ca189 commit a36409b

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

dom/MANIFEST

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
dir collections
12
support common.js
23
support constants.js
34
dir errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!doctype html>
2+
<meta charset=utf-8>
3+
<title>HTMLCollection and empty names</title>
4+
<script src=/resources/testharness.js></script>
5+
<script src=/resources/testharnessreport.js></script>
6+
<div id=log></div>
7+
<div id=test>
8+
<div class=a id></div>
9+
<div class=a name></div>
10+
<a class=a name></a>
11+
</div>
12+
<script>
13+
test(function() {
14+
var c = document.getElementsByTagName("*");
15+
assert_false("" in c, "Empty string should not be in the collection.");
16+
assert_equals(c[""], undefined, "Named getter should return undefined for empty string.");
17+
assert_equals(c.namedItem(""), null, "namedItem should return null for empty string.");
18+
}, "Empty string as a name for Document.getElementsByTagName");
19+
20+
test(function() {
21+
var div = document.getElementById("test");
22+
var c = div.getElementsByTagName("*");
23+
assert_false("" in c, "Empty string should not be in the collection.");
24+
assert_equals(c[""], undefined, "Named getter should return undefined for empty string.");
25+
assert_equals(c.namedItem(""), null, "namedItem should return null for empty string.");
26+
}, "Empty string as a name for Element.getElementsByTagName");
27+
28+
test(function() {
29+
var c = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "a");
30+
assert_false("" in c, "Empty string should not be in the collection.");
31+
assert_equals(c[""], undefined, "Named getter should return undefined for empty string.");
32+
assert_equals(c.namedItem(""), null, "namedItem should return null for empty string.");
33+
}, "Empty string as a name for Document.getElementsByTagNameNS");
34+
35+
test(function() {
36+
var div = document.getElementById("test");
37+
var c = div.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "a");
38+
assert_false("" in c, "Empty string should not be in the collection.");
39+
assert_equals(c[""], undefined, "Named getter should return undefined for empty string.");
40+
assert_equals(c.namedItem(""), null, "namedItem should return null for empty string.");
41+
}, "Empty string as a name for Element.getElementsByTagNameNS");
42+
43+
test(function() {
44+
var c = document.getElementsByClassName("a");
45+
assert_false("" in c, "Empty string should not be in the collection.");
46+
assert_equals(c[""], undefined, "Named getter should return undefined for empty string.");
47+
assert_equals(c.namedItem(""), null, "namedItem should return null for empty string.");
48+
}, "Empty string as a name for Document.getElementsByClassName");
49+
50+
test(function() {
51+
var div = document.getElementById("test");
52+
var c = div.getElementsByClassName("a");
53+
assert_false("" in c, "Empty string should not be in the collection.");
54+
assert_equals(c[""], undefined, "Named getter should return undefined for empty string.");
55+
assert_equals(c.namedItem(""), null, "namedItem should return null for empty string.");
56+
}, "Empty string as a name for Element.getElementsByClassName");
57+
</script>

dom/collections/MANIFEST

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HTMLCollection-empty-name.html

0 commit comments

Comments
 (0)