blob: a4eda6e3ef41961759154ec6131d44ac0e4aeb01 (
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
|
<!DOCTYPE html>
<link rel="help" href="https://html.spec.whatwg.org/C/#the-fieldset-and-legend-elements">
<!-- A test for the following paragraph:
The element is expected to be positioned in the block-flow direction such that
its border box is centered over the border on the block-start side of the
fieldset element.
-->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
fieldset {
margin: 0;
padding: 0;
border: 100px solid black;
}
legend {
height: 0px;
border-color: yellow;
border-style: solid;
}
</style>
<fieldset>
<legend style="border-width:50px"></legend>
<br>
</fieldset>
<br>
<fieldset>
<legend style="border-width:25px 50px"></legend>
<br>
</fieldset>
<br>
<fieldset>
<legend style="border-width:10px 50px 40px 50px"></legend>
<br>
</fieldset>
<br>
<fieldset>
<legend style="border-width:40px 50px 10px 50px"></legend>
<br>
</fieldset>
<script>
function legendBlockOffset(fieldset) {
let legend = fieldset.querySelector('legend');
return legend.getBoundingClientRect().y - fieldset.getBoundingClientRect().y;
}
test(() => {
let fieldsets = document.querySelectorAll('fieldset');
assert_equals(legendBlockOffset(fieldsets[0]), 0);
assert_equals(legendBlockOffset(fieldsets[1]), 25);
assert_equals(legendBlockOffset(fieldsets[2]), 25);
assert_equals(legendBlockOffset(fieldsets[3]), 25);
}, 'Legend\'s border-box should be centere on the fieldset border');
</script>
|