tor-browser

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

mousemove-becomes-drag.html (1836B)


      1 <!DOCTYPE html>
      2 <title>Layout Instability: no shift in mouse moves with a button pressed</title>
      3 <link rel="help" href="https://wicg.github.io/layout-instability/" />
      4 <style>
      5 
      6 body { margin: 0; height: 2000px; }
      7 #draggable {
      8  top:50px;
      9  left:50px;
     10  width:50px;
     11  height:50px;
     12  background-color:blue;
     13  position:absolute
     14 }
     15 
     16 </style>
     17 <div id="draggable" ></div>
     18 <script src="/resources/testharness.js"></script>
     19 <script src="/resources/testharnessreport.js"></script>
     20 <script src="/resources/testdriver.js"></script>
     21 <script src="/resources/testdriver-actions.js"></script>
     22 <script src="/resources/testdriver-vendor.js"></script>
     23 <script src="resources/util.js"></script>
     24 <script>
     25 
     26 const draggable = document.getElementById("draggable");
     27 draggable.addEventListener('mousemove', function(event) {
     28  // Move the element when the mouse moves.
     29  draggable.style.top = event.pageY - 25 + 'px';
     30  event.preventDefault();
     31 }, false);
     32 
     33 generateMouseMoveSequence = () => new test_driver.Actions()
     34    .pointerMove(0, 0, {origin: draggable})
     35    .pointerDown()
     36    .pointerMove(0, 15, {origin: draggable})
     37    .pause(100)
     38    .pointerMove(0, 30, {origin: draggable})
     39    .pause(100)
     40    .pointerMove(0, 45, {origin: draggable})
     41    .pause(100)
     42    .pointerUp()
     43    .pause(100);
     44 
     45 promise_test(async () => {
     46 
     47  const watcher = new ScoreWatcher;
     48 
     49  // Wait for the initial render to complete.
     50  await waitForAnimationFrames(2);
     51 
     52  // Send pointer events for a sequence of mouse actions, mouse down, mouse moves and mouse up.
     53  await generateMouseMoveSequence().send();
     54 
     55  // Mouse moves which drag the objects should be counted as the excluding inputs
     56  // for the layout shift.
     57  assert_greater_than(watcher.score, 0);
     58  assert_equals(watcher.scoreWithInputExclusion, 0);
     59 
     60 }, "No layout shift when mouse moves with a button pressed.");
     61 
     62 </script>