tor-browser

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

helper_bug1280013.html (3287B)


      1 <!DOCTYPE HTML>
      2 <html style="overflow:hidden">
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=width-device; initial-scale=1.0">
      6  <title>Test for bug 1280013</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 async function test() {
     12  ok(screen.height > 500, "Screen height must be at least 500 pixels for this test to work");
     13 
     14  // Scroll down to the iframe. Do it in two drags instead of one in case the
     15  // device screen is short.
     16  let transformEnd = promiseTransformEnd();
     17  await synthesizeNativeTouchDrag(window, 10, 200, 0, -175);
     18  await transformEnd;
     19 
     20  transformEnd = promiseTransformEnd();
     21  await synthesizeNativeTouchDrag(window, 10, 200, 0, -175);
     22  await transformEnd;
     23 
     24  // Now the top of the visible area should be at y=350 of the top-level page,
     25  // so if the screen is >= 500px tall, the entire iframe should be visible, at
     26  // least vertically.
     27 
     28  // However, because of the overflow:hidden on the root elements, all this
     29  // scrolling is happening in APZ and is not reflected in the main-thread
     30  // scroll position (it is stored in the callback transform instead). We check
     31  // this by checking the scroll offset.
     32  await promiseOnlyApzControllerFlushed();
     33  is(window.scrollY, 0, "Main-thread scroll position is still at 0");
     34 
     35  // Scroll the iframe by 150px.
     36  var subframe = document.getElementById("subframe");
     37  transformEnd = promiseTransformEnd();
     38  await synthesizeNativeTouchDrag(subframe, 10, 100, 0, -150);
     39  await transformEnd;
     40 
     41  // Flush any pending paints on the APZ side, and wait for the main thread
     42  // to process them all so that we get the correct test data
     43  await promiseApzFlushedRepaints();
     44 
     45  // get the displayport for the subframe
     46  var utils = SpecialPowers.getDOMWindowUtils(window);
     47  var contentPaints = utils.getContentAPZTestData().paints;
     48  var lastPaint = convertScrollFrameData(getLastNonemptyBucket(contentPaints).scrollFrames);
     49  var foundIt = 0;
     50  for (var scrollId in lastPaint) {
     51    if (("contentDescription" in lastPaint[scrollId]) &&
     52        (lastPaint[scrollId].contentDescription.includes("tall_html"))) {
     53      var dp = getPropertyAsRect(lastPaint, scrollId, "displayport");
     54      ok(dp.y <= 0, "The displayport top should be less than or equal to zero to cover the visible part of the subframe; it is " + dp.y);
     55      ok(dp.y + dp.height >= subframe.clientHeight, "The displayport bottom should be greater than the clientHeight; it is " + (dp.y + dp.height));
     56      foundIt++;
     57    }
     58  }
     59  is(foundIt, 1, "Found exactly one displayport for the subframe we were interested in.");
     60 }
     61 
     62 SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
     63 waitUntilApzStable()
     64 .then(test)
     65 .then(subtestDone, subtestFailed);
     66 
     67  </script>
     68 </head>
     69 <body style="overflow:hidden">
     70  The iframe below is at (0, 400). Scroll it into view, and then scroll the contents. The content should be fully rendered in high-resolution.
     71  <iframe id="subframe" style="position:absolute; left: 0px; top: 400px; width: 300px; height: 175px" src="helper_tall.html"></iframe>
     72 </body>
     73 </html>