summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-fieldset-element/fieldset-intrinsic-size.html
blob: 5ff0d7db4124718bc0a134c1a057802270f907a3 (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
<!DOCTYPE html>
<meta charset="utf-8">
<title>Fieldset with intrinsic size</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-fieldset-element">
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic">
<meta name="assert" content="A fieldset with an intrinsic size should be as big as required by the contents.">
<style>
fieldset {
  height: min-content;
  padding: 7px;
  border: 3px solid cyan;
}
fieldset > div {
  border: 3px solid orange;
}
.auto {
  height: auto;
}
.min-content {
  height: min-content;
}
.max-content {
  height: max-content;
}
.content-box {
  box-sizing: content-box;
}
.border-box {
  box-sizing: border-box;
}
</style>

<div id="log"></div>

<fieldset class="auto content-box">
  <legend>Legend</legend>
  <div>Contents</div>
</fieldset>
<fieldset class="auto border-box">
  <legend>Legend</legend>
  <div>Contents</div>
</fieldset>
<fieldset class="min-content content-box">
  <legend>Legend</legend>
  <div>Contents</div>
</fieldset>
<fieldset class="min-content border-box">
  <legend>Legend</legend>
  <div>Contents</div>
</fieldset>
<fieldset class="max-content content-box">
  <legend>Legend</legend>
  <div>Contents</div>
</fieldset>
<fieldset class="max-content border-box">
  <legend>Legend</legend>
  <div>Contents</div>
</fieldset>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
for (let fieldset of document.querySelectorAll("fieldset")) {
  test(function() {
    const fieldsetRect = fieldset.getBoundingClientRect();
    const contentsRect = fieldset.querySelector("div").getBoundingClientRect();
    const fieldsetOuterEnd = fieldsetRect.y + fieldsetRect.height;
    const fieldsetInnerEnd = fieldsetOuterEnd - 10;
    const contentsOuterEnd = contentsRect.y + contentsRect.height;
    assert_equals(fieldsetInnerEnd, contentsOuterEnd);
  }, fieldset.className);
}
</script>