Skip to content

Commit

Permalink
html: Tests for field-sizing (#44346)
Browse files Browse the repository at this point in the history
This includes tests to confirm size/cols/rows are not presentational hints.

Issue: whatwg/html#6807
  • Loading branch information
tkent-google authored and marcoscaceres committed Feb 23, 2024
1 parent 5ed137d commit 9b06312
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion html/rendering/widgets/input-text-size.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<input id="size20" size="20">
<input id="size21" size="21">
<input id="computed" style="border:none; padding:0;" size="19">
<input id="computedNone" style="display:none" size="17">

<script>
test(() => {
Expand All @@ -34,6 +35,11 @@
const computedString = getComputedStyle(computed).width;
assert_equals(computed.offsetWidth,
parseInt(computedString.substring(0, computedString.length - 2)));
}, 'Size attribute value affects computed style');
}, 'Size attribute value affects layout-dependent computed style');

test(() => {
const computedString = getComputedStyle(computedNone).width;
assert_equals(computedString, 'auto');
}, 'Size attribute value is not a presentational hint');
</script>

9 changes: 8 additions & 1 deletion html/rendering/widgets/textarea-cols-rows.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<textarea id="missing"></textarea>
<textarea id="invalid" cols="-1" rows="-1"></textarea>
<textarea id="computed" style="border:none; padding:0;" cols="19" rows="5"></textarea>
<textarea id="computedNone" style="display:none" cols="17" rows="7"></textarea>

<textarea id="cols0" cols="0"></textarea>
<textarea id="cols1" cols="1"></textarea>
Expand Down Expand Up @@ -52,6 +53,12 @@
const computedHeight = getComputedStyle(computed).height;
assert_equals(computed.offsetHeight,
parseInt(computedHeight.substring(0, computedHeight.length - 2)));
}, 'Cols/rows attribute values affect computed style');
}, 'Cols/rows attribute values affect layout-dependent computed style');

test(() => {
const computedNoneStyle = getComputedStyle(computedNone);
assert_equals(computedNoneStyle.width, 'auto');
assert_equals(computedNoneStyle.height, 'auto');
}, 'Cols/rows attribute values are not presentational hints');
</script>

0 comments on commit 9b06312

Please sign in to comment.