document.getElementsByName-null-undef.html (1142B)
1 <!DOCTYPE html> 2 <title>Calling getElementsByName with null and undefined</title> 3 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"> 5 <link rel="help" href="https://webidl.spec.whatwg.org/#es-DOMString"> 6 <link rel="help" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf#page=57"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <div id="log"></div> 10 <script> 11 test(function() { 12 var n = document.createElement("div"); 13 n.setAttribute("name", "null"); 14 15 document.body.appendChild(n); 16 this.add_cleanup(function() { document.body.removeChild(n) }); 17 18 assert_equals(document.getElementsByName(null)[0], n); 19 }, "getElementsByName(null)"); 20 21 test(function() { 22 var u = document.createElement("div"); 23 u.setAttribute("name", "undefined"); 24 25 document.body.appendChild(u); 26 this.add_cleanup(function() { document.body.removeChild(u) }); 27 28 assert_equals(document.getElementsByName(undefined)[0], u); 29 }, "getElementsByName(undefined)"); 30 </script>