Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/forms/the-fieldset-element/fieldset-intrinsic-size.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Fieldset with intrinsic size</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<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>