tor-browser

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

common-HTMLOptionsCollection-namedItem.html (1885B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title id='title'>HTMLOptionsCollection</title>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 <body>
     10 <div id="log"></div>
     11 <select id="selly">
     12  <option id="id1" name="name1">1</option>
     13  <option id="id2" name="name2">2</option>
     14  <option id="id3" name="name3">3</option>
     15  <option id="id4" name="name4">4</option>
     16  <option name="nameonly">nameonly</option>
     17  <option id="id3">duplicate ID</option>
     18  <option name="name4">duplicate name</option>
     19  <option id="mixed1">mixed ID</option>
     20  <option name="mixed1">mixed name</option>
     21 </select>
     22 
     23 <script>
     24 var selly;
     25 setup(function() {
     26    selly = document.getElementById('selly');
     27 });
     28 
     29 test(function () {
     30    assert_equals(selly.namedItem('nameonly')["value"], "nameonly");
     31 }, "if only one item has a *name* or id value matching the parameter, return that object and stop");
     32 
     33 test(function () {
     34    assert_equals(selly.namedItem('id2')["value"], "2");
     35 }, "if only one item has a name or *id* value matching the parameter, return that object and stop");
     36 
     37 test(function () {
     38    assert_equals(selly.namedItem('thisdoesnotexist'), null);
     39 }, "if no item has a name or id value matching the parameter, return null and stop");
     40 
     41 test(function () {
     42    assert_equals(selly.namedItem('id3')["value"], "3");
     43 }, "if multiple items have a name or *id* value matching the parameter, return the first object and stop");
     44 
     45 test(function () {
     46    assert_equals(selly.namedItem('name4')["value"], "4");
     47 }, "if multiple items have a *name* or id value matching the parameter, return the first object and stop");
     48 
     49 test(function () {
     50    assert_equals(selly.namedItem('mixed1')["value"], "mixed ID");
     51 }, "if multiple items have a *name* or *id* value matching the parameter, return the first object and stop");
     52 </script>
     53 </body>
     54 </html>