tor-browser

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

test_bug615833.html (3625B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=615697
      5 -->
      6 <head>
      7  <title>Test for Bug 615697</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=615697">Mozilla Bug 615697</a>
     14 <p id="display"></p>
     15 <div id="content">
     16  <input>
     17  <textarea></textarea>
     18  <input type='radio'>
     19  <input type='checkbox'>
     20  <select>
     21    <option>foo</option>
     22    <option>bar</option>
     23  </select>
     24  <select multiple size='1'>
     25    <option>tulip</option>
     26  </select>
     27 </div>
     28 <pre id="test">
     29 <script type="application/javascript">
     30 
     31 /** Test for Bug 615697 */
     32 
     33 /**
     34 * This test is making all elements trigger 'change' event.
     35 * You should read the test from bottom to top:
     36 * events are registered from the last one to the first one.
     37 *
     38 * Sometimes, elements are focused before a click. This might sound useless
     39 * but it guarantees to have the element visible before simulating the click.
     40 */
     41 
     42 var input = document.getElementsByTagName('input')[0];
     43 var textarea = document.getElementsByTagName('textarea')[0];
     44 var radio = document.getElementsByTagName('input')[1];
     45 var checkbox= document.getElementsByTagName('input')[2];
     46 var select = document.getElementsByTagName('select')[0];
     47 var selectMultiple = document.getElementsByTagName('select')[1];
     48 
     49 function checkChangeEvent(aEvent)
     50 {
     51  ok(aEvent.bubbles, "change event should bubble");
     52  ok(!aEvent.cancelable, "change event shouldn't be cancelable");
     53 }
     54 
     55 selectMultiple.addEventListener("change", function(aEvent) {
     56  checkChangeEvent(aEvent);
     57  SimpleTest.finish();
     58 }, {once: true});
     59 
     60 selectMultiple.addEventListener("focus", function() {
     61  SimpleTest.executeSoon(function () {
     62    synthesizeMouseAtCenter(selectMultiple, {});
     63  });
     64 }, {once: true});
     65 
     66 select.addEventListener("change", function(aEvent) {
     67  checkChangeEvent(aEvent);
     68  selectMultiple.focus();
     69 }, {once: true});
     70 
     71 select.addEventListener("keyup", function() {
     72  select.blur();
     73 }, {once: true});
     74 
     75 select.addEventListener("focus", function() {
     76  SimpleTest.executeSoon(function () {
     77    synthesizeKey("KEY_ArrowDown");
     78  });
     79 }, {once: true});
     80 
     81 checkbox.addEventListener("change", function(aEvent) {
     82  checkChangeEvent(aEvent);
     83  select.focus();
     84 }, {once: true});
     85 
     86 checkbox.addEventListener("focus", function() {
     87  SimpleTest.executeSoon(function () {
     88    synthesizeMouseAtCenter(checkbox, {});
     89  });
     90 }, {once: true});
     91 
     92 radio.addEventListener("change", function(aEvent) {
     93  checkChangeEvent(aEvent);
     94  checkbox.focus();
     95 }, {once: true});
     96 
     97 radio.addEventListener("focus", function() {
     98  SimpleTest.executeSoon(function () {
     99    synthesizeMouseAtCenter(radio, {});
    100  });
    101 }, {once: true});
    102 
    103 textarea.addEventListener("change", function(aEvent) {
    104  checkChangeEvent(aEvent);
    105  radio.focus();
    106 }, {once: true});
    107 
    108 textarea.addEventListener("input", function() {
    109  textarea.blur();
    110 }, {once: true});
    111 
    112 textarea.addEventListener("focus", function() {
    113  SimpleTest.executeSoon(function () {
    114    sendString("f");
    115  });
    116 }, {once: true});
    117 
    118 input.addEventListener("change", function(aEvent) {
    119  checkChangeEvent(aEvent);
    120  textarea.focus();
    121 }, {once: true});
    122 
    123 input.addEventListener("input", function() {
    124  input.blur();
    125 }, {once: true});
    126 
    127 input.addEventListener("focus", function() {
    128  SimpleTest.executeSoon(function () {
    129    sendString("f");
    130  });
    131 }, {once: true});
    132 
    133 SimpleTest.waitForExplicitFinish();
    134 SimpleTest.waitForFocus(function() {
    135  input.focus();
    136 });
    137 
    138 </script>
    139 </pre>
    140 </body>
    141 </html>