Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame^] | 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 | |
| 58 | test(function() { |
| 59 | var div = document.getElementById("test"); |
| 60 | var c = div.children; |
| 61 | assert_false("" in c, "Empty string should not be in the collection."); |
| 62 | assert_equals(c[""], undefined, "Named getter should return undefined for empty string."); |
| 63 | assert_equals(c.namedItem(""), null, "namedItem should return null for empty string."); |
| 64 | }, "Empty string as a name for Element.children"); |
| 65 | </script> |