tor-browser

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

test_drag_thumb_in_link.html (2097B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=367028
      5 -->
      6 <head>
      7 <title>Test for Bug 367028</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 <style>
     12 #scroller {
     13  display: block;
     14  width: 200px;
     15  height: 100px;
     16  overflow: scroll;
     17  background: beige;
     18  border: 1px solid black;
     19 }
     20 
     21 #biggerblock {
     22  display: block;
     23  width: 100px;
     24  height: 150px;
     25  line-height: 150px;
     26  white-space: nowrap;
     27  overflow: hidden;
     28  background: khaki;
     29 }
     30 </style>
     31 </head>
     32 <body>
     33 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=367028">Mozilla Bug 367028</a>
     34 <p id="display"></p>
     35 <div id="content" style="display: none"></div>
     36 <a id="scroller" href="#">
     37  block anchor<span id="biggerblock">bigger block</span>
     38 </a>
     39 <script type="application/javascript">
     40 
     41 function waitForEvent(aTarget, aEvent) {
     42  return new Promise(aResolve => {
     43    aTarget.addEventListener(aEvent, aResolve, { once: true });
     44  });
     45 }
     46 
     47 /** Test for Bug 367028 */
     48 
     49 add_task(async function drag_thumb_in_link() {
     50  let scroller = document.getElementById("scroller");
     51  scroller.ondragstart = function(e) {
     52    e.preventDefault();
     53    ok(false, "dragging on scroller bar should not trigger drag-and-drop operation");
     54    scroller.ondragstart = null;
     55  };
     56 
     57  // Click the scroll bar.
     58  let x = scroller.getBoundingClientRect().width - 5;
     59  let y = scroller.getBoundingClientRect().height - 70;
     60  synthesizeMouse(scroller, x, y, { type : "mousedown" }, window);
     61  synthesizeMouse(scroller, x, y, { type : "mousemove" }, window);
     62 
     63  let scrollPromise = waitForEvent(scroller, "scroll");
     64  x = scroller.getBoundingClientRect().width + 20;
     65  y = scroller.getBoundingClientRect().height - 30;
     66  synthesizeMouse(scroller, x, y, { type : "mousemove" }, window);
     67  synthesizeMouse(scroller, x, y, { type : "mouseup" }, window);
     68  await scrollPromise;
     69 
     70  ok(true, "Dragging scroller bar should scroll");
     71  scroller.ondragstart = null;
     72 });
     73 
     74 </script>
     75 </body>
     76 </html>