tor-browser

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

wheel-event-transactions-multiple-action-chains.html (2833B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/resources/testdriver.js"></script>
      9 <script src="/resources/testdriver-actions.js"></script>
     10 <script src="/resources/testdriver-vendor.js"></script>
     11 <script src="scroll_support.js"></script>
     12 <style>
     13 body {
     14  margin: 0;
     15  padding: 0;
     16  height: 200vh;
     17 }
     18 
     19 #initial {
     20  background: red;
     21  width: 100%;
     22  height: 25px;
     23  padding: 0;
     24  margin: 0;
     25 }
     26 
     27 #second {
     28  background: green;
     29  width: 100%;
     30  height: 200vh;
     31  padding: 0;
     32  margin: 0;
     33 }
     34 
     35 </style>
     36 <head>
     37 <body>
     38 <div id="initial"></div>
     39 <div id="second"></div>
     40 </body>
     41 
     42 <script>
     43 
     44 promise_test(async (t) => {
     45  await new Promise(resolve => addEventListener("load", resolve, {once: true}));
     46 
     47  await waitForCompositorReady();
     48 
     49  await waitForCompositorCommit();
     50 
     51  let firstEventTargets = [];
     52  let secondEventTargets = [];
     53  let isFirstGroup = true;
     54  window.addEventListener("wheel", (e) => {
     55    if (isFirstGroup) {
     56      firstEventTargets.push(e.target);
     57    } else {
     58      secondEventTargets.push(e.target);
     59    }
     60  }, {passive: true});
     61 
     62  await waitForCompositorCommit();
     63 
     64  // The first action chain should target the initial element
     65  await new test_driver.Actions()
     66    .addWheel("wheel1")
     67    .scroll(40, 2, 0, 30, {origin: "viewport"})
     68    .send();
     69 
     70  // Start logging event targets in the second transaction
     71  isFirstGroup = false;
     72 
     73  // The second chain should target the second element and the prior wheel event
     74  // group should have no impact on this action chain.
     75  await new test_driver.Actions()
     76    .addWheel("wheel1")
     77    .scroll(40, 30, 0, 30, {origin: "viewport"})
     78    .send();
     79 
     80  // TODO(dlrobertson): Use the scrollend event here to wait for the
     81  // wheel scroll to finish instead of waitForAnimationEnd().
     82  await waitForAnimationEnd(() => { return document.scrollingElement.scrollTop; });
     83  await waitForCompositorCommit();
     84 
     85  assert_greater_than(firstEventTargets.length, 0,
     86                      "There should be at least one event in the first transaction");
     87  assert_greater_than(secondEventTargets.length, 0,
     88                      "There should be at least one event in the second transaction");
     89 
     90  firstEventTargets.forEach((wheelEventTarget, i) => {
     91    assert_equals(wheelEventTarget, initial,
     92                  "Wheel event at index `" + i + "` did not target the initial element");
     93  });
     94 
     95  secondEventTargets.forEach((wheelEventTarget, i) => {
     96    assert_equals(wheelEventTarget, second,
     97                  "Wheel event at index `" + i + "` did not target the second element");
     98  });
     99 }, "Two separate webdriver action chains should have different wheel event transactions");
    100 </script>
    101 </html>