tor-browser

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

test_bug861217.html (7394B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=861217
      5 -->
      6 <head>
      7  <title>Test for Bug 861217</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
     10 </head>
     11 <body onload="runTest()">
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=861217">Mozilla Bug 861217</a>
     13 <p id="display"></p>
     14 <div id="content">
     15  <table border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed; width: 50px">
     16    <tbody>
     17      <tr>
     18        <td id="tableCell1" style="overflow: hidden"><div style="width: 100px; height: 100px; background-color: DodgerBlue">1</div></td>
     19      </tr>
     20      <tr>
     21        <td id="tableCell2" style="overflow: hidden"><div style="margin-top: 5px; margin-left: 7px; width: 100px; height: 100px; background-color: SkyBlue">2</div></td>
     22      </tr>
     23      <tr>
     24        <td id="tableCell3" style="overflow: hidden"><div style="display: inline-block; margin-right: 8px; margin-bottom: 10px; width: 100px; height: 100px; background-color: Khaki">3</div></td>
     25      </tr>
     26      <tr>
     27        <td id="tableCell4" style="overflow: hidden"><div style="display: inline-block; margin-right: 3px; margin-left: 1px; box-sizing: border-box; width: 100px; height: 100px; border-left: 6px solid black; border-bottom: 2px solid black; background-color: LightCoral">4</div></td>
     28      </tr>
     29      <tr>
     30        <td id="tableCell5" style="overflow: hidden"><div style="display: inline-block; border-right: 9px solid black; width: 100px; height: 100px; background-color: LightSeaGreen">5</div></td>
     31      </tr>
     32      <tr>
     33        <td id="tableCell6" style="overflow: hidden"><div style="box-sizing: border-box; width: 100px; height: 100px; padding-top: 3px; padding-right: 13px; background-color: Orange">6</div></td>
     34      </tr>
     35      <tr>
     36        <td id="tableCell7" style="overflow: hidden"><div style="display: inline-block; margin-right: 11px; margin-left: 4px; box-sizing: border-box; width: 100px; height: 100px; border-right: 6px solid black; border-bottom: 8px solid black; padding-top: 5px; padding-right: 9px; padding-bottom: 8px; padding-left: 7px; background-color: Silver">7</div></td>
     37      </tr>
     38      <tr>
     39        <td id="tableCell8" style="overflow: hidden"><div style="display: inline-block; margin-top: 7px; margin-bottom: 1px; border-right: 6px solid black; border-bottom: 8px solid black; padding-top: 5px; padding-right: 9px; padding-bottom: 8px; padding-left: 7px; width: 100px; height: 100px; background-color: Turquoise">8</div></td>
     40      </tr>
     41    </tbody>
     42  </table>
     43  <div id="status" style="display: none"></div>
     44 </div>
     45 <pre id="test">
     46 <script class="testbody" type="text/javascript">
     47 
     48 SimpleTest.waitForExplicitFinish();
     49 
     50 /** Test for Bug 861217 */
     51 async function runTest() {
     52  // This test needs to be run on environments where the zoom level == 1, but
     53  // there are a couple of cases it's not run on such kind of environments.
     54  // 1) run this test solely like mach mochitest dom/tests/mochitest/general/test_bug861217.html .
     55  //    In this case the zoom level is smaller than 1 since there's no meta viewport.
     56  // 2) run test test along with other tests in the same directory.
     57  //    In this case this test runs inside an iframe in the mochitest harness'
     58  //    top level document which doesn't have any meta viewport either.
     59  // To avoid these situations we forcibly set the zoom level 1 here.
     60  const resolution = await SpecialPowers.spawn(window.top, [], () => {
     61    return SpecialPowers.getDOMWindowUtils(content.window).getResolution();
     62  });
     63 
     64  SimpleTest.registerCleanupFunction(async () => {
     65    await SpecialPowers.spawn(window.top, [resolution], (aResolution) => {
     66      SpecialPowers.getDOMWindowUtils(content.window).setResolutionAndScaleTo(aResolution);
     67    });
     68  });
     69  await SpecialPowers.spawn(window.top, [], () => {
     70    SpecialPowers.getDOMWindowUtils(content.window).setResolutionAndScaleTo(1.0);
     71  });
     72  await SimpleTest.promiseWaitForCondition(async () => {
     73    const resolution = await SpecialPowers.spawn(window.top, [], () => {
     74      return SpecialPowers.getDOMWindowUtils(content.window).getResolution();
     75    });
     76    return resolution == 1.0;
     77  }, "Waiting for zoom level 1.0");
     78 
     79  var tableCell1 = document.getElementById("tableCell1"),
     80      bcr1 = tableCell1.getBoundingClientRect(),
     81      tableCell2 = document.getElementById("tableCell2"),
     82      bcr2 = tableCell2.getBoundingClientRect(),
     83      tableCell3 = document.getElementById("tableCell3"),
     84      bcr3 = tableCell3.getBoundingClientRect(),
     85      tableCell4 = document.getElementById("tableCell4"),
     86      bcr4 = tableCell4.getBoundingClientRect(),
     87      tableCell5 = document.getElementById("tableCell5"),
     88      bcr5 = tableCell5.getBoundingClientRect(),
     89      tableCell6 = document.getElementById("tableCell6"),
     90      bcr6 = tableCell6.getBoundingClientRect(),
     91      tableCell7 = document.getElementById("tableCell7"),
     92      bcr7 = tableCell7.getBoundingClientRect(),
     93      tableCell8 = document.getElementById("tableCell8"),
     94      bcr8 = tableCell8.getBoundingClientRect();
     95 
     96  is(bcr1.width, 50, "Width of bounding client rect of #tableCell1");
     97  is(tableCell1.scrollWidth, 100, "scrollWidth of #tableCell1");
     98  is(bcr1.height, 100, "Height of bounding client rect of #tableCell1");
     99  is(tableCell1.scrollHeight, 100, "scrollHeight of #tableCell1");
    100 
    101  is(bcr2.width, 50, "Width of bounding client rect of #tableCell2");
    102  is(tableCell2.scrollWidth, 107, "scrollWidth of #tableCell2");
    103  is(bcr2.height, 105, "Height of bounding client rect of #tableCell2");
    104  is(tableCell2.scrollHeight, 105, "scrollHeight of #tableCell2");
    105 
    106  is(bcr3.width, 50, "Width of bounding client rect of #tableCell3");
    107  is(tableCell3.scrollWidth, 108, "scrollWidth of #tableCell3");
    108  is(bcr3.height, 110, "Height of bounding client rect of #tableCell3");
    109  is(tableCell3.scrollHeight, 110, "scrollHeight of #tableCell3");
    110 
    111  is(bcr4.width, 50, "Width of bounding client rect of #tableCell4");
    112  is(tableCell4.scrollWidth, 104, "scrollWidth of #tableCell4");
    113  is(bcr4.height, 100, "Height of bounding client rect of #tableCell4");
    114  is(tableCell4.scrollHeight, 100, "scrollHeight of #tableCell4");
    115 
    116  is(bcr5.width, 50, "Width of bounding client rect of #tableCell5");
    117  is(tableCell5.scrollWidth, 109, "scrollWidth of #tableCell5");
    118  is(bcr5.height, 100, "Height of bounding client rect of #tableCell5");
    119  is(tableCell5.scrollHeight, 100, "scrollHeight of #tableCell5");
    120 
    121  is(bcr6.width, 50, "Width of bounding client rect of #tableCell6");
    122  is(tableCell6.scrollWidth, 100, "scrollWidth of #tableCell6");
    123  is(bcr6.height, 100, "Height of bounding client rect of #tableCell6");
    124  is(tableCell6.scrollHeight, 100, "scrollHeight of #tableCell6");
    125 
    126  is(bcr7.width, 50, "Width of bounding client rect of #tableCell7");
    127  is(tableCell7.scrollWidth, 115, "scrollWidth of #tableCell7");
    128  is(bcr7.height, 100, "Height of bounding client rect of #tableCell7");
    129  is(tableCell7.scrollHeight, 100, "scrollHeight of #tableCell7");
    130 
    131  is(bcr8.width, 50, "Width of bounding client rect of #tableCell8");
    132  is(tableCell8.scrollWidth, 122, "scrollWidth of #tableCell8");
    133  is(bcr8.height, 129, "Height of bounding client rect of #tableCell8");
    134  is(tableCell8.scrollHeight, 129, "scrollHeight of #tableCell8");
    135 
    136  SimpleTest.finish();
    137 }
    138 
    139 </script>
    140 </pre>
    141 </body>
    142 </html>