blob: f9fca976544f1aaac8d84e9acd918c7538b7e86d (
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
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests that getComputedStyle() returns used position fallback style</title>
<link rel="help" href="https://drafts4.csswg.org/css-anchor-position-1">
<link rel="help" href="https://drafts.csswg.org/cssom/#resolved-value">
<link rel="author" href="mailto:xiaochengh@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
body {
margin: 0;
}
.cb {
position: relative;
width: 400px;
height: 400px;
background: lightgray;
}
.anchor {
position: absolute;
width: 100px;
height: 100px;
background: orange;
}
.target {
position: absolute;
width: 100px;
height: 100px;
background: lime;
position-fallback: --pf;
}
@position-fallback --pf {
@try {
top: anchor(top);
left: anchor(right);
}
@try {
top: anchor(top);
right: anchor(left);
}
}
#anchor1 {
top: 0;
left: 0;
anchor-name: --a1;
}
#target1 {
anchor-default: --a1;
}
#anchor2 {
top: 200px;
right: 0;
anchor-name: --a2;
}
#target2 {
anchor-default: --a2;
}
</style>
<div class="cb">
<div id="anchor1" class="anchor">anchor1</div>
<div id="anchor2" class="anchor">anchor2</div>
<div id="target1" class="target">target1</div>
<div id="target2" class="target">target2</div>
</div>
<script>
test(() => {
const style1 = getComputedStyle(target1);
assert_equals(style1.top, '0px');
assert_equals(style1.left, '100px');
assert_equals(style1.right, '200px');
}, 'getComputedStyle() should return and absolutize the first @try rule style for target1');
test(() => {
const style2 = getComputedStyle(target2);
assert_equals(style2.top, '200px');
assert_equals(style2.left, '200px');
assert_equals(style2.right, '100px');
}, 'getComputedStyle() should return and absolutize the second @try rule style for target2');
</script>
|