HTMLCollection-delete.html (1109B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>Deleting properties from HTMLCollection</title> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <div id=log></div> 7 <i id=foo></i> 8 <script> 9 let c, expected; 10 setup(() => { 11 // These might be cached anyway, so explicitly use a single object. 12 c = document.getElementsByTagName("i"); 13 expected = document.getElementById("foo"); 14 }); 15 16 test(() => { 17 assert_equals(c[0], expected, "before"); 18 delete c[0]; 19 assert_equals(c[0], expected, "after"); 20 }, "Loose id"); 21 22 test(() => { 23 assert_equals(c[0], expected, "before"); 24 assert_throws_js(TypeError, function() { 25 "use strict"; 26 delete c[0]; 27 }); 28 assert_equals(c[0], expected, "after"); 29 }, "Strict id"); 30 31 test(() => { 32 assert_equals(c.foo, expected, "before"); 33 delete c.foo; 34 assert_equals(c.foo, expected, "after"); 35 }, "Loose name"); 36 37 test(() => { 38 assert_equals(c.foo, expected, "before"); 39 assert_throws_js(TypeError, function() { 40 "use strict"; 41 delete c.foo; 42 }); 43 assert_equals(c.foo, expected, "after"); 44 }, "Strict name"); 45 </script>