summaryrefslogtreecommitdiffstats
path: root/dom/grid/test/chrome/test_grid_lines.html
blob: 3f98f3ca0023c54a8b8d07f5d0256b5602ce68c2 (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
<!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;
	width: 400px;
	grid-gap: 10px;
	grid-template-columns: 50px [first] repeat(3, [divider] 100px) [last];
	grid-template-rows: [top1] repeat(1, [top2] 50px) [bot];
	background-color: #f00;
}
.box {
	background-color: #444;
	color: #fff;
}
</style>

<script>
'use strict';

SimpleTest.waitForExplicitFinish();

function runTests() {
	var wrapper = document.getElementById("wrapper");
	var grid = wrapper.getGridFragments()[0];
	
	// test property existence
	isnot(typeof(grid.cols.lines), "undefined", "Grid.cols.lines property exists.");
	
	if (typeof(grid.cols.lines) != "undefined") {
		// test column line count
		is(grid.cols.lines.length, 5,
			"Grid.cols.lines property has length that matches grid-template-columns."
		);
	
		if (grid.cols.lines.length == 5) {
			// test column line position
			is(grid.cols.lines[1].start, 50, "Grid column line 2 position is as expected.");

			// test column line width
			is(grid.cols.lines[1].breadth, 10, "Grid column line 2 width is as expected.");

			// test column line number
			is(grid.cols.lines[3].number, 4, "Grid column line 4 number is as expected.");

			// test column line names
			is(grid.cols.lines[0].names.length, 0, "Grid column line 1 has no names.");
			
			is(grid.cols.lines[1].names.length, 2, "Grid column line 2 has 2 names.");
			isnot(grid.cols.lines[1].names.indexOf("first"), -1,
				"Grid column line 2 has the name 'first'."
			);
			isnot(grid.cols.lines[1].names.indexOf("divider"), -1,
				"Grid column line 2 has the name 'divider'."
			);
			
			is(grid.cols.lines[4].names.length, 1, "Grid column line 5 has 1 name.");
			isnot(grid.cols.lines[4].names.indexOf("last"), -1,
				"Grid column line 5 has the name 'last'."
			);
		}
	}
	
	// test property existence
	isnot(typeof(grid.rows.lines), "undefined", "Grid.rows.lines property exists.");
	
	if (typeof(grid.rows.lines) != "undefined") {
		// test column line count
		is(grid.rows.lines.length, 3,
			"Grid.rows.lines property has length that matches grid-template-rows."
		);
	
		if (grid.rows.lines.length == 3) {
			// test row line names
			is(grid.rows.lines[0].names.length, 2, "Grid row line 1 has 2 names.");
			isnot(grid.rows.lines[0].names.indexOf("top1"), -1,
				"Grid row line 1 has the name 'top1'."
			);
			isnot(grid.rows.lines[0].names.indexOf("top2"), -1,
				"Grid row line 1 has the name 'top2'."
			);
			
			is(grid.rows.lines[1].names.length, 1, "Grid row line 2 has 1 name.");
			isnot(grid.rows.lines[1].names.indexOf("bot"), -1,
				"Grid row line 2 has the name 'bot'."
			);
			
			is(grid.rows.lines[2].names.length, 0, "Grid row line 3 has no names.");
		}
	}
	
	SimpleTest.finish();
}
</script>
</head>
<body onLoad="runTests();">

	<div id="wrapper" class="wrapper">
		<div id="boxA" class="box a">A</div>
		<div id="boxB" class="box b">B</div>
		<div id="boxC" class="box c">C</div>
		<div class="box d">D</div>
		<div class="box e">E</div>
		<div class="box f">F</div>
		<div class="box g">G</div>
		<div class="box h">H</div>
	</div>
	
</body>
</html>