tor-browser

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

pointerdown-becomes-tap.html (1743B)


      1 <!DOCTYPE html>
      2 <title>Layout Instability: shift in pointerdown becoming tap</title>
      3 <link rel="help" href="https://wicg.github.io/layout-instability/" />
      4 <style>
      5 
      6 body { margin: 0; height: 2000px; }
      7 #box {
      8  left: 0px;
      9  top: 0px;
     10  width: 400px;
     11  height: 500px;
     12  background: yellow;
     13  position: relative;
     14 }
     15 
     16 </style>
     17 <div id="box"></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 box = document.querySelector("#box");
     27 box.addEventListener("pointerdown", (e) => {
     28  // Generate a layout shift before we know what type of input this pointer
     29  // event sequence will become.
     30  box.style.top = "100px";
     31  e.preventDefault();
     32 });
     33 
     34 generateTapSequence = () => new test_driver.Actions()
     35    .addPointer("tp1", "touch")
     36    .pointerMove(0, 0, {sourceName: "tp1"})
     37    .pointerDown({sourceName: "tp1"})
     38    .pause(100)
     39    .pointerUp({sourceName: "tp1"})
     40    .pause(100);
     41 
     42 promise_test(async () => {
     43  const watcher = new ScoreWatcher;
     44 
     45  // Wait for the initial render to complete.
     46  await waitForAnimationFrames(2);
     47 
     48  // Send pointer events for a tap.
     49  await generateTapSequence().send();
     50 
     51  // The box is 400 x 500 and moves by 100px.
     52  const expectedExcludedScore = computeExpectedScore(400 * (500 + 100), 100);
     53 
     54  // Only the score that ignores hadRecentInput should increase.
     55  assert_equals(watcher.score, expectedExcludedScore);
     56  assert_equals(watcher.scoreWithInputExclusion, 0);
     57 
     58 }, "Shift in pointerdown excluded when it becomes a tap.");
     59 
     60 </script>