summaryrefslogtreecommitdiffstats
path: root/dom/grid/test/chrome/test_grid_line_numbers.html
blob: c8e5226b6056a74046d57c70d5f2103e35924a26 (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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
body {
  margin: 40px;
}
.wrapper {
  display: grid;
  grid-gap: 0px;
  background-color: #f00;
}
.wrapper > div {
  background-color: #444;
  color: #fff;
}
.repeatColumns {
  width: 600px;
  grid-auto-columns: 50px;
  grid-template-columns: repeat(auto-fit, 100px);
}
.repeatRows {
  height: 600px;
  grid-auto-rows: 50px;
  grid-template-rows: repeat(auto-fit, 100px);
}
</style>

<script>
'use strict';

SimpleTest.waitForExplicitFinish();

function testLines(elementName, lines, expectedValues) {
  is(lines.count, expectedValues.count, elementName + " has expected number of lines.");
  for (let i = 0; i < lines.length; i++) {
    is(lines[i].number, expectedValues[i].number, elementName + " line index " + i + " has expected number.");
  }
}

function runTests() {
  let grid;
  let lines;
  let expectedValues;

  grid = document.getElementById("gridWithColumns").getGridFragments()[0];
  lines = grid.cols.lines;
  expectedValues = [
    { "number": 0 },
    { "number": 0 },
    { "number": 1 },
    { "number": 2 },
    { "number": 3 },
    { "number": 4 },
    { "number": 5 },
    { "number": 6 },
    { "number": 7 },
    { "number": 8 },
  ];
  testLines("gridWithColumns", lines, expectedValues);

  grid = document.getElementById("gridWithRows").getGridFragments()[0];
  lines = grid.rows.lines;
  expectedValues = [
    { "number": 0 },
    { "number": 0 },
    { "number": 1 },
    { "number": 2 },
    { "number": 3 },
    { "number": 4 },
    { "number": 5 },
    { "number": 6 },
    { "number": 7 },
    { "number": 8 },
  ];
  testLines("gridWithRows", lines, expectedValues);

  SimpleTest.finish();
}
</script>
</head>
<body onLoad="runTests();">

<div id="gridWithColumns" class="wrapper repeatColumns">
<div style="grid-column: -9">A</div>
<div style="grid-column: 4">B</div>
<div style="grid-column: 7">C</div>
</div>

<div id="gridWithRows" class="wrapper repeatRows">
<div style="grid-row: span 3 / 2">A</div>
<div style="grid-row: 4">B</div>
<div style="grid-row: 5">C</div>
<div style="grid-row: span 2 / 8">D</div>
</div>

</body>
</html>