-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathgrid-extrinsically-sized-mutations.html
More file actions
125 lines (110 loc) · 3.31 KB
/
grid-extrinsically-sized-mutations.html
File metadata and controls
125 lines (110 loc) · 3.31 KB
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
<!DOCTYPE html>
<html>
<head>
<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-2/#layout-algorithm">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<meta name="assert" content="Tests that an extrinsically sized grid responds to various changes to both the grid and its constraints.">
<style>
.container {
width: 50px;
}
.grid {
display: grid;
grid-template-columns: 100%;
grid-template-rows: 50px;
height: 50px;
outline: 1px solid blue;
font: 10px/1 Ahem;
}
.alignStart {
align-items: start;
}
.fixedHeight {
height: 100px;
}
.percentHeight {
height: 100%;
}
.percentRow {
grid-template-rows: 100%;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function mutateContent() {
document.getElementById("one").style.width = "10px";
document.getElementById("two").style.alignItems = "stretch";
document.getElementById("three").style.gridTemplateRows = "30px";
document.getElementById("four").style.height = "10px";
document.getElementById("five").innerHTML += " x x x x x x";
document.getElementById("six").style.height = "50px";
document.getElementById("seven").style.gridTemplateColumns = "20%";
document.getElementById("eight").innerHTML += "<div class='test' data-expected-height='40'>x x x x</div>";
}
</script>
</head>
<body>
<!-- Inline constraint on the grid changes -->
<div class="container" id="one">
<div class="grid alignStart">
<div class="test" data-expected-height="40">x x x x</div>
</div>
</div>
<!-- Alignment of grid items changes -->
<div class="container">
<div id="two" class="grid alignStart">
<div class="test" data-expected-height="50">x x x</div>
</div>
</div>
<!-- grid-template-rows changes to different fixed size. -->
<div id="three" class="grid">
<div class="test" data-expected-height="30">xx</div>
</div>
<!-- Grid block size changes with % based rows -->
<div id="four" class="grid percentRow">
<div class="test" data-expected-height="10">xx</div>
</div>
<!-- Grid item content changes -->
<div class="container">
<div class="grid alignStart">
<div id="five" class="test" data-expected-height="30">x x x</div>
</div>
</div>
<!-- Grid with % height and rows has fixed block constraint changed -->
<div class="container fixedHeight" id="six">
<div class="grid percentRow percentHeight">
<div class="test" data-expected-height="50">xx</div>
</div>
</div>
<!-- grid-template-columns changes to different % value -->
<div class="container">
<div id="seven" class="grid alignStart">
<div class="test" data-expected-height="30">x x x</div>
</div>
</div>
<!-- Grid has new item added -->
<div class="container">
<div id="eight" class="grid alignStart" style="grid-template-columns: 50% 50%;">
<div>xx xx</div>
</div>
</div>
</body>
<script>
setup({ explicit_done: true });
document.fonts.ready.then(() => {
document.body.offsetHeight;
mutateContent();
document.body.offsetHeight;
let tests = document.querySelectorAll(".test");
tests.forEach((element) => {
test(function() {
let expectedHeight = element.getAttribute("data-expected-height");
assert_equals(element.offsetHeight, Number(expectedHeight), "height");
});
});
done();
})
</script>
</html>