document.embeds-document.plugins-01.html (3300B)
1 <!DOCTYPE html> 2 <title>document.embeds and document.plugins</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-embeds"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-plugins"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <div id="log"></div> 9 <script> 10 test(function() { 11 assert_equals(document.embeds, document.embeds, 12 "embeds should be constant"); 13 assert_equals(document.plugins, document.plugins, 14 "plugins should be constant"); 15 assert_equals(document.embeds, document.plugins, 16 "embeds should be the same as plugins"); 17 assert_equals(document.embeds.length, 0); 18 assert_equals(document.plugins.length, 0); 19 }, "No plugins"); 20 21 test(function() { 22 var embed = document.body.appendChild(document.createElement("embed")); 23 this.add_cleanup(function() { document.body.removeChild(embed) }); 24 25 assert_array_equals(document.embeds, [embed]); 26 assert_array_equals(document.plugins, [embed]); 27 28 assert_equals(document.embeds, document.embeds, 29 "embeds should be constant"); 30 assert_equals(document.plugins, document.plugins, 31 "plugins should be constant"); 32 assert_equals(document.embeds, document.plugins, 33 "embeds should be the same as plugins"); 34 }, "One plugin"); 35 36 test(function() { 37 var embed1 = document.createElement("embed"), 38 embed2 = document.createElement("embed"); 39 40 document.body.appendChild(embed2); 41 this.add_cleanup(function() { document.body.removeChild(embed2) }); 42 document.body.insertBefore(embed1, embed2); 43 this.add_cleanup(function() { document.body.removeChild(embed1) }); 44 45 assert_array_equals(document.embeds, [embed1, embed2]); 46 assert_array_equals(document.plugins, [embed1, embed2]); 47 48 assert_equals(document.embeds, document.embeds, 49 "embeds should be constant"); 50 assert_equals(document.plugins, document.plugins, 51 "plugins should be constant"); 52 assert_equals(document.embeds, document.plugins, 53 "embeds should be the same as plugins"); 54 }, "Two plugins"); 55 56 test(function() { 57 var embed1 = document.createElement("embed"), 58 embed2 = document.createElement("embed"); 59 document.body.appendChild(embed1); 60 this.add_cleanup(function() { document.body.removeChild(embed1) }); 61 var embeds = document.embeds; 62 assert_true(embeds instanceof HTMLCollection); 63 assert_equals(embeds.length, 1); 64 65 document.body.appendChild(embed2); 66 assert_equals(embeds.length, 2); 67 68 document.body.removeChild(embed2); 69 assert_equals(embeds.length, 1); 70 }, "Document.embeds should be a live collection"); 71 72 test(function() { 73 var embed1 = document.createElement("embed"), 74 embed2 = document.createElement("embed"); 75 document.body.appendChild(embed1); 76 this.add_cleanup(function() { document.body.removeChild(embed1) }); 77 var pls = document.plugins; 78 assert_true(pls instanceof HTMLCollection); 79 assert_equals(pls.length, 1); 80 81 document.body.appendChild(embed2); 82 assert_equals(pls.length, 2); 83 84 document.body.removeChild(embed2); 85 assert_equals(pls.length, 1); 86 }, "Document.plugins should be a live collection"); 87 </script>