Bug 1151214 part 4 - [css-grid][css-align] Add reftests for the 'justify-content' and 'align-content' CSS properties on grid containers.

This commit is contained in:
Mats Palmgren 2015-11-03 17:52:40 +01:00
parent 7920856c17
commit 2999a4b4c2
9 changed files with 707 additions and 0 deletions

View File

@ -0,0 +1,91 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: align-content</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
separator { clear:both; display:block; height:6px; }
.grid {
display: grid;
float: left;
position: relative;
border: 1px solid;
border-block-start: 2px solid blue;
grid-template: 11px 7px 5px / 3px 5px 7px;
padding: 1px 1px 3px 2px;
margin-right: 4px;
width: 40px;
height: 40px;
}
item1,item2,item3 {
display: block;
position: relative;
background: grey;
justify-self: stretch;
align-self: stretch;
}
item1 { grid-area: 1 / 1; }
item2 { grid-area: 2 / 2; }
item3 { grid-area: 3 / 3; }
.hl { writing-mode: horizontal-tb; direction:ltr; }
.hr { writing-mode: horizontal-tb; direction:rtl; }
.vl { writing-mode: vertical-lr; }
.vr { writing-mode: vertical-rl; }
.vlr { writing-mode: vertical-lr; direction:rtl; }
.vrl { writing-mode: vertical-rl; direction:ltr; }
.aend *, .aflexend * { offset-block-start:25px; }
.acenter * { offset-block-start:12.5px; }
.aspace-between item2 { offset-block-start:12.5px; }
.aspace-between item3 { offset-block-start:25px; }
.aspace-around item1 { offset-block-start:4.1666px; }
.aspace-around item2 { offset-block-start:12.5px; }
.aspace-around item3 { offset-block-start:20.8333px; }
.aspace-evenly item1 { offset-block-start:6.25px; }
.aspace-evenly item2 { offset-block-start:12.5px; }
.aspace-evenly item3 { offset-block-start:18.75px; }
.astretch2 { grid-template-rows: 1fr 5px 7px; }
.astretch3 { grid-template-rows: 15.5px 17.5px 7px; }
.astretch4 { grid-template-rows: 11.33333px 13.33333px 15.33333px; }
</style>
</head>
<body>
<script>
var gridwm = [ "hl", "hr", "vl", "vr", "vlr", "vrl" ];
var test = [ "start", "end", "flexstart", "flexend", "center", "left", "right",
"space-between", "space-around", "space-evenly",
"stretch1", "stretch2", "stretch3", "stretch4" ];
for (var k = 0; k < test.length; ++k) {
for (var i = 0; i < gridwm.length; ++i) {
var div = document.createElement("div");
div.className = "grid a" + test[k] + " " + gridwm[i];
div.appendChild(document.createElement("item1"));
div.appendChild(document.createElement("item2"));
div.appendChild(document.createElement("item3"));
document.body.appendChild(div)
}
document.body.appendChild(document.createElement("separator"));
}
</script>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: align-content</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#propdef-align-content">
<link rel="match" href="grid-align-content-001-ref.html">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
separator { clear:both; display:block; height:6px; }
.grid {
display: grid;
float: left;
position: relative;
border: 1px solid;
border-block-start: 2px solid blue;
grid-template: 11px 7px 5px / 3px 5px 7px;
padding: 1px 1px 3px 2px;
margin-right: 4px;
width: 40px;
height: 40px;
}
item1,item2,item3 {
display: block;
background: grey;
justify-self: stretch;
align-self: stretch;
}
item1 { grid-area: 1 / 1; }
item2 { grid-area: 2 / 2; }
item3 { grid-area: 3 / 3; }
.hl { writing-mode: horizontal-tb; direction:ltr; }
.hr { writing-mode: horizontal-tb; direction:rtl; }
.vl { writing-mode: vertical-lr; }
.vr { writing-mode: vertical-rl; }
.vlr { writing-mode: vertical-lr; direction:rtl; }
.vrl { writing-mode: vertical-rl; direction:ltr; }
.astart { align-content:start; }
.aend { align-content:end; }
.aflexstart { align-content:flex-start; }
.aflexend { align-content:flex-end; }
.acenter { align-content:center; }
.aleft { align-content:left; }
.aright { align-content:right; }
.aspace-between{ align-content:space-between; }
.aspace-around { align-content:space-around; }
.aspace-evenly { align-content:space-evenly; }
.astretch1, .astretch2, .astretch3, .astretch4 { align-content:stretch; }
.astretch2 { grid-template-rows: minmax(3px,auto) 5px 7px; }
.astretch3 { grid-template-rows: minmax(3px,auto) minmax(5px,auto) 7px; }
.astretch4 { grid-template-rows: minmax(3px,auto) minmax(5px,auto) minmax(7px,auto); }
</style>
</head>
<body>
<script>
var gridwm = [ "hl", "hr", "vl", "vr", "vlr", "vrl" ];
var test = [ "start", "end", "flexstart", "flexend", "center", "left", "right",
"space-between", "space-around", "space-evenly",
"stretch1", "stretch2", "stretch3", "stretch4" ];
for (var k = 0; k < test.length; ++k) {
for (var i = 0; i < gridwm.length; ++i) {
var div = document.createElement("div");
div.className = "grid a" + test[k] + " " + gridwm[i];
div.appendChild(document.createElement("item1"));
div.appendChild(document.createElement("item2"));
div.appendChild(document.createElement("item3"));
document.body.appendChild(div)
}
document.body.appendChild(document.createElement("separator"));
}
</script>
</body>
</html>

View File

@ -0,0 +1,92 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: justify-content</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
separator { clear:both; display:block; height:6px; }
.grid {
display: grid;
float: left;
position: relative;
border: 1px solid;
border-block-start: 2px solid blue;
grid-template: 11px 7px 5px / 3px 5px 7px;
padding: 1px 1px 3px 2px;
margin-right: 4px;
width: 40px;
height: 40px;
}
item1,item2,item3 {
display: block;
position: relative;
background: grey;
align-self: stretch;
justify-self: stretch;
}
item1 { grid-area: 1 / 1; }
item2 { grid-area: 2 / 2; }
item3 { grid-area: 3 / 3; }
.hl { writing-mode: horizontal-tb; direction:ltr; }
.hr { writing-mode: horizontal-tb; direction:rtl; }
.vl { writing-mode: vertical-lr; }
.vr { writing-mode: vertical-rl; }
.vlr { writing-mode: vertical-lr; direction:rtl; }
.vrl { writing-mode: vertical-rl; direction:ltr; }
.jend * , .jflexend * { offset-inline-start:17px; }
.jcenter * { offset-inline-start:8.5px; }
.hr.jleft * , .vlr.jleft * { offset-inline-start:17px; }
.hl.jright * , .vrl.jright * , .vl.jright * , .vr.jright * { offset-inline-start:17px; }
.jspace-between item2 { offset-inline-start:8.5px; }
.jspace-between item3 { offset-inline-start:17px; }
.jspace-around item1 { offset-inline-start:2.85px; }
.jspace-around item2 { offset-inline-start:8.5px; }
.jspace-around item3 { offset-inline-start:14.16px; }
.jspace-evenly item1 { offset-inline-start:4.25px; }
.jspace-evenly item2 { offset-inline-start:8.5px; }
.jspace-evenly item3 { offset-inline-start:12.75px; }
.jstretch2 { grid-template-columns:1fr 7px 5px; }
.jstretch3 { grid-template-columns:19.5px 15.5px 5px; }
.jstretch4 { grid-template-columns:16.66666px 12.66666px 10.66666px; }
</style>
</head>
<body>
<script>
var gridwm = [ "hl", "hr", "vl", "vr", "vlr", "vrl" ];
var test = [ "start", "end", "flexstart", "flexend", "center", "left", "right",
"space-between", "space-around", "space-evenly",
"stretch1", "stretch2", "stretch3", "stretch4" ];
for (var k = 0; k < test.length; ++k) {
for (var i = 0; i < gridwm.length; ++i) {
var div = document.createElement("div");
div.className = "grid j" + test[k] + " " + gridwm[i];
div.appendChild(document.createElement("item1"));
div.appendChild(document.createElement("item2"));
div.appendChild(document.createElement("item3"));
document.body.appendChild(div)
}
document.body.appendChild(document.createElement("separator"));
}
</script>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: justify-content</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#propdef-justify-content">
<link rel="match" href="grid-justify-content-001-ref.html">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
separator { clear:both; display:block; height:6px; }
.grid {
display: grid;
float: left;
position: relative;
border: 1px solid;
border-block-start: 2px solid blue;
grid-template: 11px 7px 5px / 3px 5px 7px;
padding: 1px 1px 3px 2px;
margin-right: 4px;
width: 40px;
height: 40px;
}
item1,item2,item3 {
display: block;
background: grey;
align-self: stretch;
justify-self: stretch;
}
item1 { grid-area: 1 / 1; }
item2 { grid-area: 2 / 2; }
item3 { grid-area: 3 / 3; }
.hl { writing-mode: horizontal-tb; direction:ltr; }
.hr { writing-mode: horizontal-tb; direction:rtl; }
.vl { writing-mode: vertical-lr; }
.vr { writing-mode: vertical-rl; }
.vlr { writing-mode: vertical-lr; direction:rtl; }
.vrl { writing-mode: vertical-rl; direction:ltr; }
.jstart { justify-content:start; }
.jend { justify-content:end; }
.jflexstart { justify-content:flex-start; }
.jflexend { justify-content:flex-end; }
.jcenter { justify-content:center; }
.jleft { justify-content:left; }
.jright { justify-content:right; }
.jspace-between{ justify-content:space-between; }
.jspace-around { justify-content:space-around; }
.jspace-evenly { justify-content:space-evenly; }
.jstretch1, .jstretch2, .jstretch3, .jstretch4 { justify-content:stretch; }
.jstretch2 { grid-template-columns: minmax(11px,auto) 7px 5px; }
.jstretch3 { grid-template-columns: minmax(11px,auto) minmax(7px,auto) 5px; }
.jstretch4 { grid-template-columns: minmax(11px,auto) minmax(7px,auto) minmax(5px,auto); }
</style>
</head>
<body>
<script>
var gridwm = [ "hl", "hr", "vl", "vr", "vlr", "vrl" ];
var test = [ "start", "end", "flexstart", "flexend", "center", "left", "right",
"space-between", "space-around", "space-evenly",
"stretch1", "stretch2", "stretch3", "stretch4" ];
for (var k = 0; k < test.length; ++k) {
for (var i = 0; i < gridwm.length; ++i) {
var div = document.createElement("div");
div.className = "grid j" + test[k] + " " + gridwm[i];
div.appendChild(document.createElement("item1"));
div.appendChild(document.createElement("item2"));
div.appendChild(document.createElement("item3"));
document.body.appendChild(div)
}
document.body.appendChild(document.createElement("separator"));
}
</script>
</body>
</html>

View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: Testing track distribution rounding errors</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.grid {
display: grid;
grid-template-rows: 0 7px;
border: 1px solid blue;
background: black;
}
x { background: lime; height:7px; }
</style>
</head>
<body>
<script>
var justify = [ "" ];
var cols = [ "151", "1" ];
var widths = [ "151", "152", "153", "154", "155", "156", "157", "158", "159",
"160", "161", "301", "302", "303", "304", "305", "306", "307",
"308", "309", "310", "311" ];
for (var c = 0; c < cols.length; ++c) {
var chunk = document.createElement('div');
chunk.setAttribute("style", "float:left; margin:1px;");
for (var j = 0; j < justify.length; ++j) {
for (var w = 0; w < widths.length; ++w) {
var grid = document.createElement('div');
grid.style.width = widths[w]+"px";
if (widths[w] > 300) {
grid.style.gridTemplateColumns = "2px " + (widths[w]-4) + "px 2px";
} else {
grid.style.gridTemplateColumns = "1px " + (widths[w]-2) + "px 1px";
}
grid.className = "grid " + justify[j];
if (cols[c] > 1) {
var x = document.createElement('x');
x.style.gridColumn = "2 / 3";
x.setAttribute('col', cols[c])
grid.appendChild(x);
}
chunk.appendChild(grid);
}
}
document.body.appendChild(chunk);
}
document.body.style.display = "";
</script>
</body>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: Testing track distribution rounding errors</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#propdef-justify-content">
<link rel="match" href="grid-justify-content-002-ref.html">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.grid {
display: grid;
grid-auto-columns: minmax(1px,auto);
grid-template-rows: 0px 7px;
border: 1px solid blue;
}
.stretch { justify-content: stretch; }
/* I don't know how to make a reference for these so they are only included to
trigger possible assertions: */
.space-between { justify-content: space-between; visibility:hidden; }
.space-around { justify-content: space-around; visibility:hidden; }
.space-evenly { justify-content: space-evenly; visibility:hidden; }
.grid :last-child, .grid :nth-child(2) { background:black; }
x { background: lime; height:7px; }
</style>
</head>
<body>
<script>
var justify = [ "stretch", "space-between", "space-around", "space-evenly" ];
var cols = [ "151", "1" ];
var widths = [ "151", "152", "153", "154", "155", "156", "157", "158", "159",
"160", "161", "301", "302", "303", "304", "305", "306", "307",
"308", "309", "310", "311" ];
for (var c = 0; c < cols.length; ++c) {
var chunk = document.createElement('div');
chunk.setAttribute("style", "float:left; margin:1px");
for (var j = 0; j < justify.length; ++j) {
for (var w = 0; w < widths.length; ++w) {
var grid = document.createElement('div');
grid.style.width = widths[w]+"px";
grid.className = "grid " + justify[j];
var span = document.createElement('span');
span.style.gridColumn = "1 / span " + cols[c];
grid.appendChild(span);
for (var x = 0; x < cols[c]; ++x) {
grid.appendChild(document.createElement('x'));
}
chunk.appendChild(grid);
}
}
document.body.appendChild(chunk);
}
document.body.style.display = "";
</script>
</body>
</html>

View File

@ -0,0 +1,115 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>Reference: Testing track fallback values</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.grid {
display: grid;
grid-auto-columns: minmax(1px,auto);
grid-template-rows: 0px 7px;
border: 2px solid black;
float: left;
margin-right: 20px;
}
.grid :last-child { background:grey; }
.grid :nth-child(2) { background:pink; }
x { background: lime; height:7px; }
</style>
</head>
<body>
<script>
document.body.style.display = "none";
var justify = [
"start",
"end",
"center",
"start",
"end",
"start",
"start",
"start",
"start",
"end",
"center",
"start",
"end",
"start",
"end safe",
"end",
"center",
"center",
"end",
"end safe",
"start",
"center",
"end",
"end safe",
"left",
"end",
];
var cols = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ];
var widths = [ "0", "1", "2", "3", "4", "5", "6" ];
for (var j = 0; j < justify.length; ++j) {
// document.body.appendChild(document.createTextNode(justify[j])); // for debugging
var chunk = document.createElement('div');
chunk.setAttribute("style", "border:1px solid; padding:2px 10px; overflow:hidden");
for (var c = 0; c < cols.length; ++c) {
for (var w = 0; w < widths.length; ++w) {
// set this to true if you want to see all tests
var run_test = widths[w] < cols[c] || cols[c] == 0 || cols[c] == 1;
if (run_test) {
var grid = document.createElement('div');
grid.style.width = widths[w]+"px";
grid.className = "grid";
grid.style.justifyContent = justify[j];
var span = document.createElement('span');
span.style.gridColumn = "1 / span " + cols[c];
grid.appendChild(span);
for (var x = 0; x < cols[c]; ++x) {
grid.appendChild(document.createElement('x'));
}
if (j < 5) { // The stretch tests.
if (c == 1)
grid.style.background = 'pink'
}
if (j == 6 && cols[c] == 1) { // The 'end safe' tests.
if (widths[w] != 0) grid.style.justifyContent = 'end';
}
if (j == 7 && cols[c] == 1) { // The 'center safe' tests.
if (widths[w] != 0) grid.style.justifyContent = 'center';
}
if (j > 15) { // The space-around and space-evenly tests.
if (cols[c] == 1) {
if (widths[w] == 0) {
if (grid.style.justifyContent != 'end') {
grid.style.justifyContent = 'start';
}
} else {
grid.style.justifyContent = 'center';
}
}
}
chunk.appendChild(grid);
}
}
}
document.body.appendChild(chunk);
}
document.body.style.display = "";
</script>
</body>
</html>

View File

@ -0,0 +1,96 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: Testing 'justify-content' fallback values</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#propdef-justify-content">
<link rel="match" href="grid-justify-content-003-ref.html">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.grid {
display: grid;
grid-auto-columns: minmax(1px,auto);
grid-template-rows: 0px 7px;
border: 2px solid black;
float: left;
margin-right: 20px;
}
.grid :last-child { background:grey; }
.grid :nth-child(2) { background:pink; }
x { background: lime; height:7px; }
</style>
</head>
<body>
<script>
document.body.style.display = "none";
var justify = [
"stretch",
"stretch end",
"stretch center",
"stretch end safe",
"stretch end true",
"start safe",
"end safe",
"center safe",
"start true",
"end true",
"center true",
"space-between",
"space-between end",
"space-between start",
"space-between end safe",
"space-between end true",
"space-around",
"space-around center",
"space-around right",
"space-around right safe",
"space-around left",
"space-evenly",
"space-evenly flex-end",
"space-evenly flex-end safe",
"space-evenly flex-start true",
"space-evenly right",
];
var cols = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ];
var widths = [ "0", "1", "2", "3", "4", "5", "6" ];
for (var j = 0; j < justify.length; ++j) {
// document.body.appendChild(document.createTextNode(justify[j])); // for debugging
var chunk = document.createElement('div');
chunk.setAttribute("style", "border:1px solid; padding:2px 10px; overflow:hidden");
for (var c = 0; c < cols.length; ++c) {
for (var w = 0; w < widths.length; ++w) {
// set this to true if you want to see all tests
var run_test = widths[w] < cols[c] || cols[c] == 0 || cols[c] == 1;
if (run_test) {
var grid = document.createElement('div');
grid.style.width = widths[w]+"px";
grid.className = "grid";
grid.style.justifyContent = justify[j];
var span = document.createElement('span');
span.style.gridColumn = "1 / span " + cols[c];
grid.appendChild(span);
for (var x = 0; x < cols[c]; ++x) {
grid.appendChild(document.createElement('x'));
}
chunk.appendChild(grid);
}
}
}
document.body.appendChild(chunk);
}
document.body.style.display = "";
</script>
</body>
</html>

View File

@ -56,3 +56,7 @@ fuzzy-if(winWidget,70,130) fuzzy-if(cocoaWidget,85,180) == grid-col-max-sizing-m
== grid-item-justify-001.html grid-item-justify-001-ref.html
== grid-item-justify-002.html grid-item-justify-002-ref.html
== grid-item-stretch-001.html grid-item-stretch-001-ref.html
== grid-align-content-001.html grid-align-content-001-ref.html
== grid-justify-content-001.html grid-justify-content-001-ref.html
== grid-justify-content-002.html grid-justify-content-002-ref.html
== grid-justify-content-003.html grid-justify-content-003-ref.html