summaryrefslogtreecommitdiffstats
path: root/dom/grid/test/chrome/test_grid_subtree_dirty.html
blob: 4baa94872e03856bc12109050720bb617b223c83 (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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
  #grid {
    display: grid;
    width: 100px;
    height: 100px;
  }

  #initiallyHidden {
    display: none;
    width: 100px;
    height: 100px;
    background: lime;
  }
</style>
<script>
"use strict";

SimpleTest.waitForExplicitFinish();

function runTests() {
  const grid = document.getElementById("grid");
  const initiallyHidden = document.getElementById("initiallyHidden");
  document.documentElement.offsetHeight; // Flush layout to be sure we have grid-item sizes cached

  grid.getGridFragments(); // This marks the grid and its descendants as dirty

  document.documentElement.offsetHeight; // Flush layout again. In buggy builds, this layout will fail to reflow/clear-dirty-bits on the grid item.

  initiallyHidden.style.display = "block"; // This should trigger a reflow.
  let height = getComputedStyle(initiallyHidden).height;
  is(height, "100px", "initiallyHidden element should get a reflow and arrive at the expected height after we toggle its display");

  SimpleTest.finish();
}
</script>
</head>
<body onLoad="runTests();">
  <div id="grid">
    <div>
      <div>
        <div>
          <div id="initiallyHidden">
            PASS
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>