tor-browser

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

radionodelist.html (3219B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: the RadioNodeList interface</title>
      4 <link rel="author" title="Intel" href="http://www.intel.com/">
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/common-dom-interfaces.html#radionodelist">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="log"></div>
      9 <form >
     10  <input type="checkbox" name="rdo" value="0" id="r0" checked>
     11  <input type="radio" name="rdo" id="r1">
     12  <input type="radio" name="rdo" id="r2" value="2">
     13 </form>
     14 <script>
     15 
     16 var rdoList;
     17 
     18 setup(function () {
     19  rdoList = document.forms[0].elements.namedItem("rdo");
     20 });
     21 
     22 //on getting
     23 test(function () {
     24  assert_equals(rdoList.value, "", "The value attribute should be empty.");
     25 }, "The value attribute should be empty if no element is checked");
     26 
     27 test(function () {
     28  document.getElementById("r2").checked = true;
     29  assert_equals(rdoList.value, "2", "The value attribute should be 2.");
     30 }, "The RadioNodeList.value must be the first checked radio button's value");
     31 
     32 test(function () {
     33  document.getElementById("r1").checked = true;
     34  assert_equals(rdoList.value, "on", "The value attribute should be on.");
     35 
     36  document.getElementById("r1").value = 1;
     37  assert_equals(rdoList.value, "1", "The value attribute should be 1.");
     38 }, "Check the RadioNodeList.value on getting");
     39 
     40 //on setting
     41 test(function () {
     42  assert_equals(rdoList.value, document.getElementById("r1").value,
     43                "The value attribute should be equal to the first checked radio input element's value.");
     44  assert_false(document.getElementById("r2").checked,
     45               "The second radio input element should not be checked.");
     46 
     47  rdoList.value = "2";
     48  assert_equals(rdoList.value, document.getElementById("r2").value,
     49                "The value attribute should be equal to the second radio input element's value.");
     50  assert_true(document.getElementById("r2").checked,
     51              "The second radio input element should be checked.");
     52 
     53  //Do nothing if no element's value is equal to new value.
     54  rdoList.value = "3";
     55  assert_equals(rdoList.value, document.getElementById("r2").value,
     56                "The value attribute should be the second radio input element's value.");
     57  assert_true(document.getElementById("r2").checked,
     58              "The second radio input element should be checked.");
     59 }, "Check the RadioNodeList.value on setting");
     60 
     61 //setting to on, specific case
     62 test(function () {
     63  rdoList.value = "on";
     64  assert_equals(rdoList.value, document.getElementById("r2").value,
     65                "The value attribute should be the second radio input element's value.");
     66  assert_true(document.getElementById("r2").checked,
     67              "The second radio input element should be checked.");
     68 
     69  document.getElementById("r1").removeAttribute("value");
     70  rdoList.value = "on";
     71  assert_equals(rdoList.value, document.getElementById("r1").value,
     72                "The value attribute should be the first radio input element's value.");
     73  assert_true(document.getElementById("r1").checked,
     74              "The first radio input element should be checked.");
     75 }, "Check the RadioNodeList.value on setting to 'on'");
     76 
     77 
     78 </script>