tor-browser

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

helper_basic_onetouchpinch.html (3688B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width">
      6  <title>Sanity check for one-touch pinch zooming</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 src="/tests/SimpleTest/EventUtils.js"></script>
     11  <script type="application/javascript">
     12 
     13 async function test() {
     14  let visResEvt = new EventCounter(window.visualViewport, "resize");
     15  let visScrEvt = new EventCounter(window.visualViewport, "scroll");
     16  // Our internal visual viewport events aren't restricted to the visual view-
     17  // port itself, so we can listen on the window itself, however the event
     18  // listener needs to be in the system group.
     19  let visResEvtInternal = new EventCounter(window, "mozvisualresize",
     20                                           { mozSystemGroup: true });
     21  let visScrEvtInternal = new EventCounter(window, "mozvisualscroll",
     22                                           { mozSystemGroup: true });
     23  let visResEvtContent = new EventCounter(window, "mozvisualresize");
     24  let visScrEvtContent = new EventCounter(window, "mozvisualscroll");
     25 
     26  var initial_resolution = await getResolution();
     27  ok(initial_resolution > 0,
     28      "The initial_resolution is " + initial_resolution + ", which is some sane value");
     29 
     30  // This listener will trigger the test to continue once APZ is done with
     31  // processing the scroll.
     32  let transformEndPromise = promiseTransformEnd();
     33 
     34  var zoom_in = [
     35      [ { x: 150, y: 300 } ],
     36      [ null ],
     37      [ { x: 150, y: 300 } ],
     38      [ { x: 150, y: 305 } ],
     39      [ { x: 150, y: 310 } ],
     40      [ { x: 150, y: 315 } ],
     41      [ { x: 150, y: 320 } ],
     42      [ { x: 150, y: 325 } ],
     43  ];
     44 
     45  var touchIds = [0];
     46  await synthesizeNativeTouchSequences(document.body, zoom_in, null, touchIds);
     47 
     48  // Wait for the APZ:TransformEnd to be fired after touch events are processed.
     49  await transformEndPromise;
     50 
     51  // Flush state and get the resolution we're at now
     52  await promiseApzFlushedRepaints();
     53  let final_resolution = await getResolution();
     54  ok(final_resolution > initial_resolution, "The final resolution (" + final_resolution + ") is greater after zooming in");
     55 
     56  // Check we've got the expected events.
     57  // Zooming the page should fire visual viewport resize events:
     58  visResEvt.unregister();
     59  ok(visResEvt.count > 0, "Got some visual viewport resize events");
     60  visResEvtInternal.unregister();
     61  ok(visResEvtInternal.count > 0, "Got some mozvisualresize events");
     62 
     63  // We're zooming somewhere in the middle of the page, so the visual
     64  // viewport's coordinates change, too.
     65  // This is true both relative to the page (mozvisualscroll), as well as
     66  // relative to the layout viewport (visual viewport "scroll" event).
     67  visScrEvt.unregister();
     68  ok(visScrEvt.count > 0, "Got some visual viewport scroll events");
     69  visScrEvtInternal.unregister();
     70  ok(visScrEvtInternal.count > 0, "Got some mozvisualscroll events");
     71 
     72  // Our internal events shouldn't leak to normal content.
     73  visResEvtContent.unregister();
     74  is(visResEvtContent.count, 0, "Got no mozvisualresize events in content");
     75  visScrEvtContent.unregister();
     76  is(visScrEvtContent.count, 0, "Got no mozvisualscroll events in content");
     77 }
     78 
     79 waitUntilApzStable()
     80 .then(test)
     81 .then(subtestDone, subtestFailed);
     82 
     83  </script>
     84 </head>
     85 <body>
     86  Here is some text to stare at as the test runs. It serves no functional
     87  purpose, but gives you an idea of the zoom level. It's harder to tell what
     88  the zoom level is when the page is just solid white.
     89 </body>
     90 </html>