tor-browser

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

test_save_restore_radio_groups.html (2111B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=350022
      5 -->
      6 <head>
      7  <title>Test for Bug 350022</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=350022">Mozilla Bug 350022</a>
     13 <p id="display"></p>
     14 <div id="content"><!-- style="display: none">-->
     15  <iframe src="save_restore_radio_groups.sjs"></iframe>
     16  <iframe src="save_restore_radio_groups.sjs"></iframe>
     17 </div>
     18 <pre id="test">
     19 <script type="application/javascript">
     20 
     21 /** Test for Bug 350022 */
     22 
     23 function checkRadioGroup(aFrame, aResults)
     24 {
     25  var radios = frames[aFrame].document.getElementsByTagName('input');
     26 
     27  is(radios.length, aResults.length,
     28     "Radio group should have " + aResults.length + "elements");
     29 
     30  for (var i=0; i<aResults.length; ++i) {
     31    is(radios[i].checked, aResults[i],
     32       "Radio checked state should be " + aResults[i]);
     33  }
     34 }
     35 
     36 SimpleTest.waitForExplicitFinish();
     37 addLoadEvent(function() {
     38  /**
     39   * We have two iframes each containing one radio button group.
     40   * We are going to change the selected radio button in one group.
     41   * Then, both iframes will be reloaded and the new groups will have another
     42   * radio checked by default.
     43   * For the first group (which had a selection change), nothing should change.
     44   * For the second, the selected radio button should change.
     45   */
     46  checkRadioGroup(0, [true, false, false]);
     47  checkRadioGroup(1, [true, false, false]);
     48 
     49  frames[0].document.getElementsByTagName('input')[2].checked = true;
     50  checkRadioGroup(0, [false, false, true]);
     51 
     52  framesElts = document.getElementsByTagName('iframe');
     53  framesElts[0].addEventListener("load", function() {
     54    checkRadioGroup(0, [false, false, true]);
     55 
     56    framesElts[1].addEventListener("load", function() {
     57      checkRadioGroup(1, [false, true, false]);
     58      SimpleTest.finish();
     59    }, {once: true});
     60 
     61    frames[1].location.reload();
     62  }, {once: true});
     63 
     64  frames[0].location.reload();
     65 });
     66 
     67 </script>
     68 </pre>
     69 </body>
     70 </html>