nameditem-no-shadowing.tentative.html (1735B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Named items: property names don't shadow</title> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <!-- interface Document --> 9 <img name="constructor"> 10 <img name="currentScript"> 11 <img name="forms"> 12 <img name="onreadystatechange"> 13 14 <!-- interface Node --> 15 <img name="firstChild"> 16 <img name="isSameNode"> 17 18 <!-- Object.prototype --> 19 <img name="__proto__"> 20 21 <img name="foobar"> 22 23 <script id="this-script"> 24 test(function() { 25 assert_equals(document.constructor, HTMLDocument); 26 }, "document.constructor is not shadowed"); 27 28 test(function() { 29 assert_equals(document.currentScript, document.getElementById("this-script")); 30 }, "document.currentScript is not shadowed"); 31 32 test(function() { 33 assert_true(document.forms instanceof HTMLCollection); 34 assert_equals(document.forms.length, 0); 35 }, "document.forms is not shadowed"); 36 37 test(function() { 38 assert_equals(document.onreadystatechange, null); 39 }, "document.onreadystatechange is not shadowed"); 40 41 test(function() { 42 assert_true(document.firstChild instanceof DocumentType); 43 assert_equals(document.firstChild, document.childNodes[0]); 44 }, "document.firstChild is not shadowed"); 45 46 test(function() { 47 assert_true(document.isSameNode instanceof Function); 48 assert_true(document.isSameNode(document)); 49 }, "document.isSameNode() is not shadowed"); 50 51 test(function() { 52 assert_equals(document.__proto__, HTMLDocument.prototype); 53 }, "document.__proto__ is not shadowed"); 54 55 test(function() { 56 assert_true(document.foobar instanceof HTMLImageElement); 57 }, "document.foobar works (sanity check)"); 58 </script>