[css-grid] Import additional grid layout tests and update TestExpectations
[WebKit-https.git] / LayoutTests / fast / css-grid-layout / grid-align-baseline.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link href="resources/grid.css" rel="stylesheet">
5 <link href="resources/grid-alignment.css" rel="stylesheet">
6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script>
8 <script src="../../resources/check-layout-th.js"></script>
9 <style>
10 body {
11     margin: 0;
12 }
13
14 .grid {
15     width: 600px;
16     grid-auto-columns: 1fr;
17     position: relative;
18     margin-bottom: 20px;
19     font: 20px/1 Ahem;
20 }
21
22 .grid :nth-child(1) { background-color: blue; }
23 .grid :nth-child(2) { background-color: green; }
24 .grid :nth-child(3) { background-color: red; }
25 .grid :nth-child(4) { background-color: yellow; }
26 .grid :nth-child(5) { background-color: purple; }
27 .grid :nth-child(6) { background-color: orange; }
28 .grid :nth-child(7) { background-color: lime; }
29 .grid :nth-child(8) { background-color: lightblue; }
30 .grid :nth-child(9) { background-color: darkred; }
31 .grid :nth-child(10) { background-color: gold; }
32 .grid :nth-child(11) { background-color: salmon; }
33
34 .firstRowThirdColumn {
35     grid-row: 1;
36     grid-column: 3;
37 }
38 .firstRowFourthColumn {
39     grid-row: 1;
40     grid-column: 4;
41 }
42 .firstRowFifthColumn {
43     grid-row: 1;
44     grid-column: 5;
45 }
46 </style>
47 </head>
48 <body onload="checkLayout('.grid')">
49
50 <div class="grid alignItemsBaseline">
51     <div style="margin: 40px 0px;" class="firstRowFirstColumn" data-offset-x="0" data-offset-y="40" data-expected-width="200" data-expected-height="20"><div style="display:inline-block;"></div></div>
52     <div style="margin: auto 0px 0px;" class="firstRowSecondColumn" data-offset-x="200" data-offset-y="80" data-expected-width="200" data-expected-height="20"><div style="display:inline-block;"></div></div>
53     <div style="margin: 20px 0px;" class="firstRowThirdColumn" data-offset-x="400" data-offset-y="40" data-expected-width="200" data-expected-height="20"><div style="display:inline-block;"></div></div>
54 </div>
55
56 <div class="grid">
57     <div data-expected-height="20" data-offset-y="20" class="firstRowFirstColumn alignSelfBaseline" style="height: 20px;"></div>
58     <div data-expected-height="10" data-offset-y="30" class="firstRowSecondColumn alignSelfBaseline" style="height: 10px; margin: 30px 0 10px;"></div>
59     <div data-expected-height="10" data-offset-y="30" class="firstRowThirdColumn alignSelfBaseline" style="height: 10px; margin: 20px 0 0;"></div>
60     <div data-expected-height="100" data-offset-y="0" class="firstRowFourthColumn" style="height: 100px;"></div>
61 </div>
62
63 <div class="grid">
64     <div id="baseline1" class="firstRowFirstColumn" style="align-self: baseline;">ahem</div>
65     <div id="baseline2" data-offset-y="0" class="firstRowSecondColumn alignSelfBaseline"><img src="../../fast/replaced/resources/1x1-blue.png" style="height: 50px;"></div>
66     <div data-expected-height="50" data-offset-y="25" class="firstRowThirdColumn alignSelfCenter"><img src="../../fast/replaced/resources/1x1-blue.png" style="height: 50px; vertical-align: middle"></div>
67     <div id="baseline3" data-expected-height="50" class="firstRowFourthColumn alignSelfBaseline"><img src="../../fast/replaced/resources/1x1-blue.png" style="height: 50px; vertical-align: middle"></div>
68     <div data-expected-height="100" data-offset-y="0" class="firstRowFifthColumn" style="height: 100px;"></div>
69 </div>
70
71 <div class="grid">
72     <div id="baseline4" class="firstRowFirstColumn alignSelfBaseline">ahem</div>
73     <div id="baseline5" class="firstRowSecondColumn alignSelfBaseline"><br><img src="../../fast/replaced/resources/1x1-blue.png" style="height: 50px;"></div>
74     <div data-expected-height="50" data-offset-y="0" class="firstRowThirdColumn alignSelfBaseline"><img src="../../fast/replaced/resources/1x1-blue.png" style="height: 50px; vertical-align: middle"></div>
75     <div data-expected-height="100" data-offset-y="0" class="firstRowFourthColumn" style="height: 100px;"></div>
76 </div>
77
78 <div id="results"></div>
79
80 <script>
81 function additionalBaselineChecks()
82 {
83     var baseline1 = document.getElementById("baseline1");
84     var baseline2 = document.getElementById("baseline2");
85     var baseline3 = document.getElementById("baseline3");
86     logIfFalse(baseline1.offsetTop + baseline1.offsetHeight == baseline2.offsetTop + baseline2.offsetHeight,
87                "baseline1 and baseline2 should have the same baseline.");
88     logIfFalse(baseline3.offsetTop < 25,
89                "baseline3 should be above the center align-selfed item.");
90
91     var baseline4 = document.getElementById("baseline4");
92     var baseline5 = document.getElementById("baseline5");
93     logIfFalse(baseline4.offsetTop == baseline5.offsetTop,
94                "baseline4 and baseline5 should be top aligned with each other.");
95     logIfFalse(baseline4.offsetTop > 0,
96                "baseline4 and baseline5 should be below baseline6.");
97 }
98
99 function logIfFalse(condition, msg)
100 {
101     if (!condition)
102         document.getElementById("results").innerText += msg;
103 }
104
105 additionalBaselineChecks();
106 </script>
107
108 </body>
109 </html>