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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Test: Grid Layout - Properties exist</title>
<link rel="author" title="贺师俊" href="mailto:johnhax@gmail.com">
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com" />
<link rel="reviewer" title="Dayang Shen" href="mailto:shendayang@baidu.com"> <!-- 2013-09-30 -->
<link rel="help" href="http://www.w3.org/TR/css-grid-1/#property-index">
<meta name="flags" content="ahem dom">
<meta name="assert" content="Test checks that css properties of grid layout exist.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
#container {
width: 800px;
height: 600px;
}
#myDiv {
font: 50px/1 Ahem;
justify-content: start;
align-content: start;
}
</style>
</head>
<body>
<div id="log"></div>
<div id="container">
<div id="myDiv">
<div>I T</div>
<div>IT</div>
<div>I</div>
</div>
</div>
<script>
setup({explicit_done: true});
document.fonts.ready.then(()=> {
var myDiv = document.getElementById('myDiv')
test(function(){
myDiv.style.display = 'grid'
assert_equals(myDiv.style.display, 'grid',
'display should be "grid"')
}, 'display: grid')
test(function(){
myDiv.style.display = 'inline-grid'
assert_equals(myDiv.style.display, 'inline-grid',
'display should be "inline-grid"')
}, 'display: inline-grid')
void function(data){
myDiv.style.display = 'grid'
Object.keys(data).forEach(function(prop){
test(function(){
assert_true(prop in myDiv.style)
}, prop)
if ('initial' in data[prop]) test(function(){
var initial = data[prop].initial
delete data[prop].initial
assert_equals(getComputedStyle(myDiv)[prop], initial, 'initial value of ' + prop + ' should be ' + initial)
}, prop + '.initial')
var syntaxTests = data[prop]
Object.keys(syntaxTests).forEach(function(testcase){
test(function(){
assert_true(prop in myDiv.style)
myDiv.style[prop] = syntaxTests[testcase][0]
assert_equals(myDiv.style[prop], syntaxTests[testcase][0], testcase)
assert_equals(getComputedStyle(myDiv)[prop], syntaxTests[testcase][1], testcase)
}, prop + '.' + testcase)
})
})
}({
'grid-template-columns': { // named 'grid-definition-columns' in last draft
initial: '150px',
'none': ['none', '150px'],
'<line-names>': ['[a] auto [b] auto [c]', '[a] 150px [b] 100px [c]'],
'<track-size>.auto': ['auto', '150px'],
'<track-size>.<track-breadth>.<length>': ['100px', '100px'],
'<track-size>.<track-breadth>.<percentage>': ['100%', '800px'],
'<track-size>.<track-breadth>.<flex>': ['1fr', '800px'],
'<track-size>.<track-breadth>.min-content': ['min-content', '100px'],
'<track-size>.<track-breadth>.max-content': ['max-content', '150px'],
'<track-size>.<track-breadth>.minmax()': ['minmax(100px, 200px)', '200px'],
'reset': ['none', '150px'],
},
'grid-template-rows': { // named 'grid-definition-rows' in last draft
initial: '50px 50px 50px',
'none': ['none', '50px 50px 50px'],
'<line-names>': ['[a] auto [b] auto [c]', '[a] 50px [b] 50px [c] 50px'],
'<track-size>.auto': ['auto', '50px 50px 50px'],
'<track-size>.<track-breadth>.<length>': ['100px', '100px 50px 50px'],
'<track-size>.<track-breadth>.<percentage>': ['100%', '150px 50px 50px'],
'<track-size>.<track-breadth>.<flex>': ['1fr', '50px 50px 50px'],
'<track-size>.<track-breadth>.min-content': ['min-content', '50px 50px 50px'],
'<track-size>.<track-breadth>.max-content': ['max-content', '50px 50px 50px'],
'<track-size>.<track-breadth>.minmax()': ['minmax(100px, 200px)', '200px 50px 50px'],
'reset': ['none', '50px 50px 50px'],
},
'grid-template-areas': {
initial: 'none',
'none': ['none', 'none'],
'<string>+': ['"a"', '"a"'],
'reset': ['none', 'none'],
},
'grid-template': {
initial: '50px 50px 50px / 150px',
'none': ['', '50px 50px 50px / 150px'],
'<grid-template-rows> / <grid-template-columns>': ['100px 100px / 200px 200px', '100px 100px / 200px 200px'],
'<line-names>': ['[a] auto [b] auto [c] / [d] auto [e] auto [f]', '[a] auto [b] auto [c] / [d] auto [e] auto [f]'],
'<string>+': ['"a b" "a b"', '"a b" "a b"'],
'<string><track-size>+': ['100px / "a b" 50px', '100px / "a b" 50px'],
'reset': ['', '50px 50px 50px / 150px'],
},
'grid-auto-columns': {
initial: 'auto',
'<track-size>.auto': ['auto', 'auto'],
'<track-size>.<track-breadth>.<length>': ['100px', '100px'],
'<track-size>.<track-breadth>.<percentage>': ['100%', '100%'],
'<track-size>.<track-breadth>.<flex>': ['1fr', '1fr'],
'<track-size>.<track-breadth>.min-content': ['min-content', 'min-content'],
'<track-size>.<track-breadth>.max-content': ['max-content', 'max-content'],
'<track-size>.<track-breadth>.minmax()': ['minmax(100px, 200px)', 'minmax(100px, 200px)'],
'reset': ['auto', 'auto'],
},
'grid-auto-rows': {
initial: 'auto',
'<track-size>.auto': ['auto', 'auto'],
'<track-size>.<track-breadth>.<length>': ['100px', '100px'],
'<track-size>.<track-breadth>.<percentage>': ['100%', '100%'],
'<track-size>.<track-breadth>.<flex>': ['1fr', '1fr'],
'<track-size>.<track-breadth>.min-content': ['min-content', 'min-content'],
'<track-size>.<track-breadth>.max-content': ['max-content', 'max-content'],
'<track-size>.<track-breadth>.minmax()': ['minmax(100px, 200px)', 'minmax(100px, 200px)'],
'reset': ['auto', 'auto'],
},
'grid-auto-flow': {
initial: 'row',
'row': ['row', 'row'],
'column': ['column', 'column'],
'dense': ['dense', 'dense'],
'row dense': ['dense', 'dense'],
'column dense': ['column dense', 'column dense'],
'reset': ['row', 'row'],
},
'grid-row-start': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a', 'a'],
'<integer>': ['1', '1'],
'<integer> <ident>': ['1 a', '1 a'],
'span <integer>': ['span 1', 'span 1'],
'span <custom-ident>': ['span a', 'span a'],
'span <integer> <custom-ident>': ['span 2 a', 'span 2 a'],
'reset': ['auto', 'auto'],
},
'grid-column-start': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a', 'a'],
'<integer>': ['1', '1'],
'<integer> <ident>': ['1 a', '1 a'],
'span <integer>': ['span 1', 'span 1'],
'span <custom-ident>': ['span a', 'span a'],
'span <integer> <custom-ident>': ['span 2 a', 'span 2 a'],
'reset': ['auto', 'auto'],
},
'grid-row-end': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a', 'a'],
'<integer>': ['1', '1'],
'<integer> <ident>': ['1 a', '1 a'],
'span <integer>': ['span 1', 'span 1'],
'span <custom-ident>': ['span a', 'span a'],
'span <integer> <custom-ident>': ['span 2 a', 'span 2 a'],
'reset': ['auto', 'auto'],
},
'grid-column-end': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a', 'a'],
'<integer>': ['1', '1'],
'<integer> <ident>': ['1 a', '1 a'],
'span <integer>': ['span 1', 'span 1'],
'span <custom-ident>': ['span a', 'span a'],
'span <integer> <custom-ident>': ['span 2 a', 'span 2 a'],
'reset': ['auto', 'auto'],
},
'grid-column': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a / b', 'a / b'],
'<integer> start': ['1', '1'],
'<integer>': ['1 / 3', '1 / 3'],
'<integer> <ident>': ['1 a / 2 b', '1 a / 2 b'],
'span <integer>': ['span 1 / span 2', 'span 1 / span 2'],
'span <custom-ident>': ['span a / span b', 'span a / span b'],
'span <integer> <custom-ident>': ['span 2 a / span 3 b', 'span 2 a / span 3 b'],
'reset': ['auto', 'auto'],
},
'grid-row': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a / b', 'a / b'],
'<integer> start': ['1', '1'],
'<integer>': ['1 / 3', '1 / 3'],
'<integer> <ident>': ['1 a / 2 b', '1 a / 2 b'],
'span <integer>': ['span 1 / span 2', 'span 1 / span 2'],
'span <custom-ident>': ['span a / span b', 'span a / span b'],
'span <integer> <custom-ident>': ['span 2 a / span 3 b', 'span 2 a / span 3 b'],
'reset': ['auto', 'auto'],
},
'grid-area': {
initial: 'auto',
'auto': ['auto', 'auto'],
'<custom-ident>': ['a / b / c / d', 'a / b / c / d'],
'<integer> start': ['1 / 2', '1 / 2'],
'<integer>': ['1 / 2 / 3 / 4', '1 / 2 / 3 / 4'],
'<integer> <ident>': ['1 a / 2 b / 3 c / 4 d', '1 a / 2 b / 3 c / 4 d'],
'span <integer>': ['span 1 / span 2 / span 3 / span 4', 'span 1 / span 2 / span 3 / span 4'],
'span <custom-ident>': ['span a / span b / span c / span d', 'span a / span b / span c / span d'],
'span <integer> <custom-ident>': ['span 2 a / span 3 b / span 4 c / span 5 d', 'span 2 a / span 3 b / span 4 c / span 5 d'],
'reset': ['auto', 'auto'],
},
})
done();
});
</script>
</body>
</html>
|