tor-browser

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

helper_bug982141.html (4738B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=982141
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <meta name="viewport" content="width=980, user-scalable=no">
      9  <title>Test for Bug 982141, helper page</title>
     10  <script type="application/javascript" src="apz_test_utils.js"></script>
     11  <script src="/tests/SimpleTest/paint_listener.js"></script>
     12  <script type="application/javascript">
     13 
     14    // In this test we have a simple page with a scrollable <div> which has
     15    // enough content to make it scrollable. We test that this <div> got
     16    // a displayport.
     17 
     18    function test() {
     19      // Get the content- and compositor-side test data from nsIDOMWindowUtils.
     20      var utils = SpecialPowers.getDOMWindowUtils(window);
     21      var contentTestData = utils.getContentAPZTestData();
     22      var compositorTestData = utils.getCompositorAPZTestData();
     23 
     24      // Get the sequence number of the last paint on the compositor side.
     25      // We do this before converting the APZ test data because the conversion
     26      // loses the order of the paints.
     27      ok(!!compositorTestData.paints.length,
     28                    "expected at least one paint in compositor test data");
     29      var lastCompositorPaint = compositorTestData.paints[compositorTestData.paints.length - 1];
     30      var lastCompositorPaintSeqNo = lastCompositorPaint.sequenceNumber;
     31 
     32      // Convert the test data into a representation that's easier to navigate.
     33      contentTestData = convertTestData(contentTestData);
     34      compositorTestData = convertTestData(compositorTestData);
     35 
     36      // Reconstruct the APZC tree structure in the last paint.
     37      var apzcTree = buildApzcTree(compositorTestData.paints[lastCompositorPaintSeqNo]);
     38 
     39      // The apzc tree for this page should consist of a single child APZC on
     40      // the RCD node (the child is for scrollable <div>). Note that in e10s/B2G
     41      // cases the RCD will be the root of the tree but on Fennec it will not.
     42      var rcd = findRcdNode(apzcTree);
     43      ok(rcd != null, "found the RCD node");
     44      is(rcd.children.length, 1, "expected a single child APZC");
     45      var childScrollId = rcd.children[0].scrollId;
     46 
     47      // We should have content-side data for the same paint.
     48      ok(lastCompositorPaintSeqNo in contentTestData.paints,
     49                    "expected a content paint with sequence number" + lastCompositorPaintSeqNo);
     50      var correspondingContentPaint = contentTestData.paints[lastCompositorPaintSeqNo];
     51 
     52      var dp = getPropertyAsRect(correspondingContentPaint, childScrollId, "displayport");
     53      var subframe = document.getElementById("subframe");
     54      // The clientWidth and clientHeight may be less than 50 if there are scrollbars showing.
     55      // In general they will be (50 - <scrollbarwidth>, 50 - <scrollbarheight>).
     56      ok(subframe.clientWidth > 0, "Expected a non-zero clientWidth, got: " + subframe.clientWidth);
     57      ok(subframe.clientHeight > 0, "Expected a non-zero clientHeight, got: " + subframe.clientHeight);
     58      ok(dp.width >= subframe.clientWidth && dp.height >= subframe.clientHeight,
     59                    "expected a displayport at least as large as the scrollable element, got " + JSON.stringify(dp));
     60    }
     61 
     62    waitUntilApzStable()
     63    .then(forceLayerTreeToCompositor)
     64    .then(test)
     65    .then(subtestDone, subtestFailed);
     66 
     67  </script>
     68 </head>
     69 <body style="overflow: hidden;"><!-- This combined with the user-scalable=no ensures the root frame is not scrollable -->
     70  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=982141">Mozilla Bug 982141</a>
     71  <!-- A scrollable subframe, with enough content to make it have a nonzero scroll range -->
     72  <div id="subframe" style="height: 50px; width: 50px; overflow: scroll">
     73    <div style="width: 100px">
     74      Wide content so that the vertical scrollbar for the parent div
     75      doesn't eat into the 50px width and reduce the width of the
     76      displayport.
     77    </div>
     78    Line 1<br>
     79    Line 2<br>
     80    Line 3<br>
     81    Line 4<br>
     82    Line 5<br>
     83    Line 6<br>
     84    Line 7<br>
     85    Line 8<br>
     86    Line 9<br>
     87    Line 10<br>
     88    Line 11<br>
     89    Line 12<br>
     90    Line 13<br>
     91    Line 14<br>
     92    Line 15<br>
     93    Line 16<br>
     94    Line 17<br>
     95    Line 18<br>
     96    Line 19<br>
     97    Line 20<br>
     98    Line 21<br>
     99    Line 22<br>
    100    Line 23<br>
    101    Line 24<br>
    102    Line 25<br>
    103    Line 26<br>
    104    Line 27<br>
    105    Line 28<br>
    106    Line 29<br>
    107    Line 30<br>
    108    Line 31<br>
    109    Line 32<br>
    110    Line 33<br>
    111    Line 34<br>
    112    Line 35<br>
    113    Line 36<br>
    114    Line 37<br>
    115    Line 38<br>
    116    Line 39<br>
    117    Line 40<br>
    118    Line 41<br>
    119    Line 42<br>
    120    Line 43<br>
    121    Line 44<br>
    122    Line 45<br>
    123    Line 46<br>
    124    Line 40<br>
    125    Line 48<br>
    126    Line 49<br>
    127    Line 50<br>
    128  </div>
    129 </body>
    130 </html>