summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-flexbox/abspos/position-absolute-012.html
blob: 4660674012b0f0ae542e02cdb0d1e3b5256fed01 (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
<!DOCTYPE html>
<html>
<title>CSS Test: Absolutely positioned children of flexboxes</title>
<link rel="author" title="Google Inc." href="http://www.google.com/">
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#abspos-items">
<meta name="assert" content="Checks that we correctly position abspos children in a number of writing modes and alignments when containing block is grid.">
<style>

.abspos {
  height: 50px;
  width: 50px;
  background: lightblue;
  position: absolute;
  flex: none;
}

.grid {
  display: grid;
  position: relative;
}

.title {
    margin-top: 1em;
}

.flexbox {
    display: flex;
    background-color: #aaa;
    height: 100px;
    width: 100px;
}

.horizontal-tb {
    writing-mode: horizontal-tb;
}
.vertical-rl {
    writing-mode: vertical-rl;
}
.vertical-lr {
    writing-mode: vertical-lr;
}

.rtl {
    direction: rtl;
}
.ltr {
    direction: ltr;
}

.align-items-flex-start {
    align-items: flex-start;
}
.align-items-flex-end {
    align-items: flex-end;
}
.justify-content-flex-start {
    justify-content: flex-start;
}
.justify-content-flex-end {
    justify-content: flex-end;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<body onload="checkLayout('.flexbox')">
<div id=log></div>
<script>

var writingModes = ['horizontal-tb', 'vertical-rl', 'vertical-lr'];
var directions = ['ltr', 'rtl'];
var justifyContents = ['flex-start', 'flex-end'];
var alignItems = ['flex-start', 'flex-end'];
var flexDirections = ['row', 'column', 'row-reverse', 'column-reverse'];

// These were harvested from Firefox 76.0b4.
var x = [0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50];

var y = [0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 0, 50, 50, 50, 50, 0, 0];

var test_number = 1;

writingModes.forEach(function(flexWritingMode) {
    flexDirections.forEach(function(flexDirection) {
      directions.forEach(function(direction) {
        justifyContents.forEach(function(justifyContent) {
          alignItems.forEach(function(alignment) {
            var flexboxClassName = flexWritingMode + ' ' + direction + ' ' + flexDirection + ' justify-content-' + justifyContent + ' align-items-' + alignment;
            var title = document.createElement('div');
            title.className = 'title';
            title.innerHTML = flexboxClassName + " .flexbox " + (test_number++);
            document.body.appendChild(title);

            var flexbox = document.createElement('div');
            flexbox.className = 'flexbox ' + flexboxClassName;

            var child = document.createElement('div');
            child.setAttribute('class', 'abspos');
            child.setAttribute("data-offset-x", x.shift());
            child.setAttribute("data-offset-y", y.shift());
            flexbox.appendChild(child);

            var relpos = document.createElement('div');
            relpos.className = 'grid';
            relpos.appendChild(flexbox);

            document.body.appendChild(relpos);
          })
        })
      })
  })
})

</script>

</body>