tor-browser

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

elementTiming.html (1747B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>TestDriver actions: element timing</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-actions.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 
     10 <style>
     11 div#test1, div#test2 {
     12  position: fixed;
     13  top: 0;
     14  left: 0;
     15  width: 100px;
     16  height: 100px;
     17  background-color: blue;
     18 }
     19 
     20 div#test2 {
     21  display: none;
     22  left: -100px;
     23  background-color: green;
     24 }
     25 </style>
     26 
     27 <div id="test1">
     28 </div>
     29 
     30 <div id="test2">
     31 </div>
     32 
     33 <script>
     34 let events = [];
     35 
     36 promise_test(async t => {
     37  let test1 = document.getElementById("test1");
     38  let test2 = document.getElementById("test2");
     39  test1.addEventListener("click",
     40    () => {
     41      test2.style.display = "block";
     42      test2.style.top = "100px";
     43      test2.style.left = "0"
     44    });
     45  test2.addEventListener("click",
     46    e => {
     47      events.push(e.clientX);
     48      events.push(e.clientY);
     49    });
     50 
     51  const waitCondition = new Promise((resolve, reject)=>{setTimeout(resolve, 5000);});
     52  const test1ClickWatcher = new EventWatcher(t, test1, ["click"], ()=>waitCondition);
     53  const test2ClickWatcher = new EventWatcher(t, test2, ["click"], ()=>waitCondition);
     54  let waitForClicks = Promise.all([test1ClickWatcher.wait_for(["click"]), test2ClickWatcher.wait_for(["click"])]);
     55 
     56  await new test_driver.Actions()
     57    .pointerMove(0, 0, {origin: test1})
     58    .pointerDown()
     59    .pointerUp()
     60    .send();
     61  await new test_driver.Actions()
     62      .pointerMove(0, 0, {origin: test2})
     63      .pointerDown()
     64      .pointerUp()
     65      .send();
     66  await waitForClicks;
     67  assert_array_equals(events, [50, 150])
     68 });
     69 </script>