tor-browser

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

test_bug534833.html (4266B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=534833
      5 -->
      6 <head>
      7  <title>Test for Bug 534833</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=534833">Mozilla Bug 534833</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none">
     16  
     17 </div>
     18 <pre id="test">
     19 <script type="application/javascript">
     20 
     21 /** Test for Bug 534833 */
     22 SimpleTest.waitForExplicitFinish();
     23 addLoadEvent(runTests);
     24 
     25 var input1GotClick = 0;
     26 var input2GotClick = 0;
     27 var textarea1GotClick = 0;
     28 var textarea2GotClick = 0;
     29 var div1GotClick = 0;
     30 var div2GotClick = 0;
     31 
     32 var tests = [ { element: "text",  clickText: true  },
     33              { element: "text2", clickText: false },
     34              { element: "area",  clickText: true  },
     35              { element: "area2", clickText: false  },
     36              { element: "d",     clickText: true  },
     37              { element: "d",     clickText: false },
     38              { element: "d2",    clickText: true  },
     39              { element: "d2",    clickText: false }
     40             ];
     41 
     42 function nextTest_() {
     43  if (!tests.length) {
     44    finishTests();
     45    return;
     46  }
     47 
     48  var test = tests.shift();
     49  var el = document.getElementById(test.element);
     50  el.scrollIntoView(true);
     51  if (test.clickText) {
     52    synthesizeMouse(el, 5, 5, {type : "mousedown" });
     53    synthesizeMouse(el, 5, 5, {type : "mouseup" });
     54  } else {
     55    synthesizeMouse(el, el.getBoundingClientRect().width - 5, 5, {type : "mousedown" });
     56    synthesizeMouse(el, el.getBoundingClientRect().width - 5, 5, {type : "mouseup" });
     57  }
     58  nextTest();
     59 }
     60 
     61 function nextTest() {
     62  var el = document.getElementById("initialfocus");
     63 
     64  el.addEventListener("focus", function() {
     65    setTimeout(nextTest_, 0);
     66  }, {once: true});
     67  el.focus();
     68 }
     69 
     70 function runTests() {
     71  var t = document.getElementById("text");
     72  var t2 = document.getElementById("text2");
     73  var a = document.getElementById("area");
     74  var a2 = document.getElementById("area2");
     75  var d = document.getElementById("d");
     76  var d2 = document.getElementById("d2");
     77 
     78  // input 1
     79  t.onfocus = function(e) {
     80    t.value = "";
     81  }
     82  t.onclick = function(e) {
     83    ++input1GotClick;
     84  }
     85 
     86  // input 2
     87  t2.onfocus = function(e) {
     88    t2.value = "";
     89  }
     90  t2.onclick = function(e) {
     91    ++input2GotClick;
     92  }
     93 
     94  // textarea 1
     95  a.onfocus = function(e) {
     96    a.value = "";
     97  }
     98  a.onclick = function(e) {
     99    ++textarea1GotClick;
    100  }
    101 
    102  // textarea 2
    103  a2.onfocus = function(e) {
    104    a2.value = "";
    105  }
    106  a2.onclick = function(e) {
    107    ++textarea2GotClick;
    108  }
    109 
    110  // div 1
    111  var c = 0;
    112  d.onmousedown = function(e) {
    113    d.textContent = (++c) + " / click before or after |";
    114  }
    115  d.onclick = function(e) {
    116    ++div1GotClick;
    117  }
    118 
    119  // div 2
    120  var c2 = 0;
    121  d2.onmousedown = function(e) {
    122    d2.firstChild.data = (++c2) + " / click before or after |";
    123  }
    124  d2.onclick = function(e) {
    125    ++div2GotClick;
    126  }
    127  nextTest();
    128 }
    129 
    130 function finishTests() {
    131  is(input1GotClick, 1, "input element should have got a click!");
    132  is(input2GotClick, 1, "input element should have got a click! (2)");
    133  is(textarea1GotClick, 1, "textarea element should have got a click!");
    134  is(textarea2GotClick, 1, "textarea element should have got a click! (2)");
    135  is(div1GotClick, 2, "div element's content text was replaced, it should have got 2 click!");
    136  is(div2GotClick, 2, "div element's content text was modified, it should have got 2 clicks!");
    137  SimpleTest.finish();
    138 }
    139 
    140 </script>
    141 </pre>
    142 <input type="text" id="initialfocus" inputmode="none"><br>
    143 <input type="text" id="text" value="click before |" style="width: 95%;" inputmode="none"><br>
    144 <input type="text" id="text2" value="click after |" style="width: 95%;" inputmode="none">
    145 <br>
    146 <textarea id="area" rows="2" style="width: 95%;" inputmode="none">
    147 click before
    148            |
    149 </textarea><br>
    150 <textarea id="area2" rows="2" style="width: 95%;" inputmode="none">
    151 click after |
    152 </textarea>
    153 <div id="d" style="border: 1px solid black;">click before or after |</div>
    154 <div id="d2" style="border: 1px solid black;">click before or after |</div>
    155 </body>
    156 </html>