summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/general/test_bug861217.html
blob: b758fe53e44e6cfbf44e54929da805bc25e01aa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=861217
-->
<head>
  <title>Test for Bug 861217</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body onload="runTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=861217">Mozilla Bug 861217</a>
<p id="display"></p>
<div id="content">
  <table border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed; width: 50px">
    <tbody>
      <tr>
        <td id="tableCell1" style="overflow: hidden"><div style="width: 100px; height: 100px; background-color: DodgerBlue">1</div></td>
      </tr>
      <tr>
        <td id="tableCell2" style="overflow: hidden"><div style="margin-top: 5px; margin-left: 7px; width: 100px; height: 100px; background-color: SkyBlue">2</div></td>
      </tr>
      <tr>
        <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>
      </tr>
      <tr>
        <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>
      </tr>
      <tr>
        <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>
      </tr>
      <tr>
        <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>
      </tr>
      <tr>
        <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>
      </tr>
      <tr>
        <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>
      </tr>
    </tbody>
  </table>
  <div id="status" style="display: none"></div>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

/** Test for Bug 861217 **/
async function runTest() {
  // This test needs to be run on environments where the zoom level == 1, but
  // there are a couple of cases it's not run on such kind of environments.
  // 1) run this test solely like mach mochitest dom/tests/mochitest/general/test_bug861217.html .
  //    In this case the zoom level is smaller than 1 since there's no meta viewport.
  // 2) run test test along with other tests in the same directory.
  //    In this case this test runs inside an iframe in the mochitest harness'
  //    top level document which doesn't have any meta viewport either.
  // To avoid these situations we forcibly set the zoom level 1 here.
  const resolution = await SpecialPowers.spawn(window.top, [], () => {
    return SpecialPowers.getDOMWindowUtils(content.window).getResolution();
  });

  SimpleTest.registerCleanupFunction(async () => {
    await SpecialPowers.spawn(window.top, [resolution], (aResolution) => {
      SpecialPowers.getDOMWindowUtils(content.window).setResolutionAndScaleTo(aResolution);
    });
  });
  await SpecialPowers.spawn(window.top, [], () => {
    SpecialPowers.getDOMWindowUtils(content.window).setResolutionAndScaleTo(1.0);
  });
  await SimpleTest.promiseWaitForCondition(async () => {
    const resolution = await SpecialPowers.spawn(window.top, [], () => {
      return SpecialPowers.getDOMWindowUtils(content.window).getResolution();
    });
    return resolution == 1.0;
  }, "Waiting for zoom level 1.0");

  var tableCell1 = document.getElementById("tableCell1"),
      bcr1 = tableCell1.getBoundingClientRect(),
      tableCell2 = document.getElementById("tableCell2"),
      bcr2 = tableCell2.getBoundingClientRect(),
      tableCell3 = document.getElementById("tableCell3"),
      bcr3 = tableCell3.getBoundingClientRect(),
      tableCell4 = document.getElementById("tableCell4"),
      bcr4 = tableCell4.getBoundingClientRect(),
      tableCell5 = document.getElementById("tableCell5"),
      bcr5 = tableCell5.getBoundingClientRect(),
      tableCell6 = document.getElementById("tableCell6"),
      bcr6 = tableCell6.getBoundingClientRect(),
      tableCell7 = document.getElementById("tableCell7"),
      bcr7 = tableCell7.getBoundingClientRect(),
      tableCell8 = document.getElementById("tableCell8"),
      bcr8 = tableCell8.getBoundingClientRect();

  is(bcr1.width, 50, "Width of bounding client rect of #tableCell1");
  is(tableCell1.scrollWidth, 100, "scrollWidth of #tableCell1");
  is(bcr1.height, 100, "Height of bounding client rect of #tableCell1");
  is(tableCell1.scrollHeight, 100, "scrollHeight of #tableCell1");

  is(bcr2.width, 50, "Width of bounding client rect of #tableCell2");
  is(tableCell2.scrollWidth, 107, "scrollWidth of #tableCell2");
  is(bcr2.height, 105, "Height of bounding client rect of #tableCell2");
  is(tableCell2.scrollHeight, 105, "scrollHeight of #tableCell2");

  is(bcr3.width, 50, "Width of bounding client rect of #tableCell3");
  is(tableCell3.scrollWidth, 108, "scrollWidth of #tableCell3");
  is(bcr3.height, 110, "Height of bounding client rect of #tableCell3");
  is(tableCell3.scrollHeight, 110, "scrollHeight of #tableCell3");

  is(bcr4.width, 50, "Width of bounding client rect of #tableCell4");
  is(tableCell4.scrollWidth, 104, "scrollWidth of #tableCell4");
  is(bcr4.height, 100, "Height of bounding client rect of #tableCell4");
  is(tableCell4.scrollHeight, 100, "scrollHeight of #tableCell4");

  is(bcr5.width, 50, "Width of bounding client rect of #tableCell5");
  is(tableCell5.scrollWidth, 109, "scrollWidth of #tableCell5");
  is(bcr5.height, 100, "Height of bounding client rect of #tableCell5");
  is(tableCell5.scrollHeight, 100, "scrollHeight of #tableCell5");

  is(bcr6.width, 50, "Width of bounding client rect of #tableCell6");
  is(tableCell6.scrollWidth, 100, "scrollWidth of #tableCell6");
  is(bcr6.height, 100, "Height of bounding client rect of #tableCell6");
  is(tableCell6.scrollHeight, 100, "scrollHeight of #tableCell6");

  is(bcr7.width, 50, "Width of bounding client rect of #tableCell7");
  is(tableCell7.scrollWidth, 115, "scrollWidth of #tableCell7");
  is(bcr7.height, 100, "Height of bounding client rect of #tableCell7");
  is(tableCell7.scrollHeight, 100, "scrollHeight of #tableCell7");

  is(bcr8.width, 50, "Width of bounding client rect of #tableCell8");
  is(tableCell8.scrollWidth, 122, "scrollWidth of #tableCell8");
  is(bcr8.height, 129, "Height of bounding client rect of #tableCell8");
  is(tableCell8.scrollHeight, 129, "scrollHeight of #tableCell8");

  SimpleTest.finish();
}

</script>
</pre>
</body>
</html>