tor-browser

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

helper_override_root.html (2242B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width; initial-scale=1.0">
      6  <title>Simple wheel scroll cancellation</title>
      7  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      8  <script type="application/javascript" src="apz_test_utils.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <script type="application/javascript">
     11 
     12 async function test() {
     13  let wheelEventPromise = new Promise(resolve => {
     14    // Add a non-passive listener on the document, so that we have a document-level
     15    // APZ-aware listener, and the entire document is put in the dispatch-to-content
     16    // region
     17    document.addEventListener("wheel", function(e) {
     18      // spin for 2 seconds to give APZ time to scroll, if the event region override
     19      // is broken and it decides not to wait for the main thread. Note that it's
     20      // possible the APZ controller thread is busy for whatever reason so APZ
     21      // may not scroll. That might cause this test to only fail intermittently
     22      // instead of consistently if the behaviour being tested regresses.
     23      var now = Date.now();
     24      while (Date.now() - now < 2000);
     25 
     26      // Cancel the scroll. If this works then we know APZ waited for this listener
     27      // to run.
     28      e.preventDefault();
     29      resolve()
     30    }, { passive: false });
     31  });
     32 
     33  // Ensure APZ gets a paint with the d-t-c region
     34  await promiseApzFlushedRepaints();
     35 
     36  await synthesizeNativeWheel(document.body, 100, 100, 0, -50);
     37  dump("Finished native wheel, waiting for listener to run...\n");
     38 
     39  await wheelEventPromise;
     40  await promiseOnlyApzControllerFlushed();
     41 
     42  is(window.scrollY, 0, "check that the window didn't scroll");
     43 }
     44 
     45 if (window.top != window) {
     46    dump("Running inside an iframe! stealing functions from window.top...\n");
     47    window.subtestDone = window.top.subtestDone;
     48    window.SimpleTest = window.top.SimpleTest;
     49    window.is = window.top.is;
     50    window.ok = window.top.ok;
     51 }
     52 
     53 waitUntilApzStable()
     54  .then(test)
     55  .then(subtestDone);
     56 
     57  </script>
     58 </head>
     59 <body style="height: 5000px; background-image: linear-gradient(green,red);">
     60  This page should not be wheel-scrollable.
     61 </body>
     62 </html>