tor-browser

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

pointerevent_mouse-pointer-on-scrollbar.html (1930B)


      1 <!DOCTYPE HTML>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/resources/testdriver.js"></script>
      5 <script src="/resources/testdriver-vendor.js"></script>
      6 <script src="/resources/testdriver-actions.js"></script>
      7 <script type="text/javascript" src="../pointerevent_support.js"></script>
      8 <style>
      9 #target {
     10  height: 100px;
     11  width: 100px;
     12  overflow-y: scroll;
     13 }
     14 #spacer {
     15  background: green;
     16  height: 200px;
     17 }
     18 </style>
     19 <h1>Verifies that pointerup/down are fired correctly for corresponding mouse events on the scollbar.</h1>
     20 <div id="target">
     21 <div id="spacer"></div>
     22 </div>
     23 
     24 <div id="console"></div>
     25 
     26 <script>
     27 var receivedEvents = [];
     28 var targetDiv = document.getElementById('target');
     29 
     30 function init() {
     31  var eventList = ["mousedown", "mouseup", "pointerdown", "pointerup"];
     32  eventList.forEach(function(eventName) {
     33    targetDiv.addEventListener(eventName, function(event) {
     34      receivedEvents.push(event.type + "@target");
     35    });
     36  });
     37 }
     38 
     39 function performActions(x, y){
     40  return new test_driver.Actions()
     41        .pointerMove(0, 0)
     42        .pointerMove(x, y)
     43        .pointerDown(0)
     44        .pointerUp(0)
     45        .send()
     46        .then(()=>resolveWhen(()=>receivedEvents.length == 4));
     47 }
     48 
     49 function runTests() {
     50  var rect = targetDiv.getBoundingClientRect();
     51  var x1 = rect.right - 5;
     52  var y1 = rect.top + 20;
     53 
     54  test(function(){
     55    assert_equals(targetDiv, document.elementFromPoint(x1,y1),
     56      "Didn't hit the scrollbar as expected");
     57  }, `Test point (${x1},${y1}) is on the scrollbar`);
     58 
     59  promise_test(async () => {
     60    await performActions(Math.ceil(x1), Math.ceil(y1));
     61    assert_array_equals(receivedEvents, ["pointerdown@target", "mousedown@target",
     62      "pointerup@target", "mouseup@target"]);
     63  }, "Verifies that pointerup/down are fired correctly for corresponding mouse events on the scollbar.");
     64 }
     65 
     66 init();
     67 runTests();
     68 </script>