tor-browser

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

helper_bug1806400.html (1881B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta name="viewport" content="width=device-width; initial-scale=1.0">
      4 <title>Tests that :active state is changed with `touchstart` event listener</title>
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <script src="/tests/SimpleTest/paint_listener.js"></script>
      7 <script src="apz_test_utils.js"></script>
      8 <script src="apz_test_native_event_utils.js"></script>
      9 <style>
     10  #button {
     11    width: 100px;
     12    height: 100px;
     13  }
     14 </style>
     15 <button id="button">Button</button>
     16 <script>
     17 async function test() {
     18  // Set up an active touchstart event listner.
     19  let eventPromise =  promiseOneEvent(document.documentElement, "touchstart");
     20  await promiseApzFlushedRepaints();
     21 
     22  await synthesizeNativeTouch(button, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
     23  await eventPromise;
     24 
     25  // In JS there's no way to ensure `APZStateChange::eStartTouch` notification
     26  // has been processed. So we wait for `:active` state change here.
     27  await SimpleTest.promiseWaitForCondition(
     28    () => button.matches(":active"),
     29    "Waiting for :active state change");
     30  ok(button.matches(":active"), "should be active");
     31 
     32  eventPromise =  promiseOneEvent(button, "touchend");
     33  await synthesizeNativeTouch(button, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE);
     34  await eventPromise;
     35 
     36  // Same as above. We need to wait for not `:active` state here.
     37  await SimpleTest.promiseWaitForCondition(
     38    () => !button.matches(":active"),
     39    "Waiting for :active state change");
     40  ok(!button.matches(":active"), "should not be active");
     41 }
     42 
     43 if (getPlatform() == "windows") {
     44  // Bug 1875916. On Windows synthesizeNativeTouch(TOUCH_REMOVE) causes
     45  // `InjectTouchInput failure` with ERROR_TIMEOUT.
     46  ok(true, "Test doesn't need to run on Windows");
     47  subtestDone();
     48 } else {
     49  waitUntilApzStable()
     50  .then(test)
     51  .then(subtestDone, subtestFailed);
     52 }
     53 </script>
     54 </html>