tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nameditem-names.html (3556B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Named items: supported property names</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 <div id="log"></div>
      8 <embed name="exposed_embed">
      9  <embed name="not_exposed_embed">
     10  </embed>
     11 </embed>
     12 <form name="form">
     13 </form>
     14 <iframe name="iframe">
     15 </iframe>
     16 <img name="img">
     17 <object name="exposed_object_with_name">
     18  <object name="not_exposed_object_with_name">
     19  </object>
     20 </object>
     21 <object id="exposed_object_with_id">
     22  <object id="not_exposed_object_with_id">
     23  </object>
     24 </object>
     25 <img name="img_with_id" id="img_id">
     26 <img id="img_with_just_id">
     27 <template id="template">
     28  <img name="img_in_template">
     29 </template>
     30 <img name="42">
     31 <script>
     32 var names = Object.getOwnPropertyNames(document);
     33 
     34 test(function() {
     35  assert_true(names.includes("exposed_embed"))
     36 }, "An embed name appears in a document's property names if the embed is exposed.");
     37 
     38 test(function() {
     39  assert_false(names.includes("not_exposed_embed"))
     40 }, "An embed name does not appears in a document's property names if the embed is inside another embed.");
     41 
     42 test(function() {
     43  assert_true(names.includes("form"))
     44 }, "A form name appears in a document's property names.");
     45 
     46 test(function() {
     47  assert_true(names.includes("iframe"))
     48 }, "An iframe name appears in a document's property names.");
     49 
     50 test(function() {
     51  assert_true(names.includes("img"))
     52 }, "An img name appears in a document's property names when the img has no id.");
     53 
     54 test(function() {
     55  assert_true(names.includes("exposed_object_with_name"))
     56 }, "An object name appears in a document's property names if the object is exposed.");
     57 
     58 test(function() {
     59  assert_true(names.includes("exposed_object_with_id"))
     60 }, "An object id appears in a document's property names if the object is exposed.");
     61 
     62 test(function() {
     63  assert_false(names.includes("not_exposed_object_with_name"))
     64 }, "An object name does not appear in a document's property names if the object is inside another object.");
     65 
     66 test(function() {
     67  assert_false(names.includes("not_exposed_object_with_id"))
     68 }, "An object id does not appear in a document's property names if the object is inside another object.");
     69 
     70 test(function() {
     71  assert_true(names.includes("img_with_id"))
     72 }, "An img name appears in a document's property names when the img has an id.");
     73 
     74 test(function() {
     75  assert_true(names.includes("img_id"))
     76 }, "An img id appears in a document's property names when the img has a name.");
     77 
     78 test(function() {
     79  assert_false(names.includes("img_with_just_id"))
     80 }, "An img id does not appear in a document's property names when the img has no name.");
     81 
     82 test(function() {
     83  assert_true(names.includes("42"))
     84 }, "A document's property names can include integer strings.");
     85 
     86 test(function() {
     87  assert_false(names.includes("template"))
     88 }, "A template name does not appear in a document's property names.");
     89 
     90 test(function() {
     91  assert_false(names.includes("img_in_template"))
     92 }, "An img name does not appear in a document's property names when the img is in a template's document fragment.");
     93 
     94 test(function() {
     95  var form_index = names.indexOf("form");
     96  assert_equals(names.indexOf("iframe"), form_index + 1);
     97  assert_equals(names.indexOf("img"), form_index + 2);
     98  assert_greater_than(names.indexOf("img_id"), names.indexOf("img"));
     99  assert_greater_than(names.indexOf("42"), names.indexOf("img_id"));
    100 }, "A document's property names appear in tree order.");
    101 </script>