Skip to content

Commit

Permalink
Bug 1753542 [wpt PR 32684] - Test how line-height works on <input typ…
Browse files Browse the repository at this point in the history
…e=text> and friends, a=testonly

Automatic update from web-platform-tests
Test how line-height works on <input type=text> and friends

See whatwg/html#5462
--

wpt-commits: ac55bfa0f0acb4155db0ac0b4e3245d10b03c48e
wpt-pr: 32684
  • Loading branch information
zcorpan authored and moz-wptsync-bot committed Feb 26, 2022
1 parent eaf6bc4 commit ef3a81b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>used value and computed value of 'line-height' on input elements as text entry widgets</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#the-input-element-as-a-text-entry-widget">
<link rel="help" href="https://drafts.csswg.org/cssom/#resolved-values">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om/#computed-stylepropertymapreadonly-objects">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
input { line-height: 1px; }
</style>
<p><input type=text value=text>
<p><input type=tel value=tel>
<p><input type=search value=search>
<p><input type=url value=url>
<p><input type=email value=email>
<p><input type=password value=password></p>
<script>
const inputs = document.querySelectorAll('input');
for (const input of inputs) {
test(() => {
const usedLineHeight = getComputedStyle(input).lineHeight;
assert_not_equals(usedLineHeight, '1px', 'usedLineHeight');
assert_not_equals(usedLineHeight, 'normal', 'usedLineHeight');
}, `getComputedStyle(<input type=${input.type}>).lineHeight should return a used value that is no smaller than 'normal' (but should not literally be 'normal')`);
test(() => {
const computedLineHeight = input.computedStyleMap().get('line-height');
assert_equals(computedLineHeight.value, 1, 'computedLineHeight.value');
assert_equals(computedLineHeight.unit, 'px', 'computedLineHeight.unit');
}, `<input type=${input.type}>.computedStyleMap().get('line-height') should not be affected by the used value clamping`);
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<title>Reference for 'line-height' smaller than 'normal' on input elements as text entry widgets</title>
<style>
input { font-size: 60px; width: 240px; }
.appearance-none { appearance: none; }
</style>
<p><input type=text value=text> <input type=text value=text class=appearance-none>
<p><input type=tel value=tel> <input type=tel value=tel class=appearance-none>
<p><input type=search value=search> <input type=search value=search class=appearance-none>
<p><input type=url value=url> <input type=url value=url class=appearance-none>
<p><input type=email value=email> <input type=email value=email class=appearance-none>
<p><input type=password value=password> <input type=password value=password class=appearance-none>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<title>'line-height' smaller than 'normal' on input elements as text entry widgets</title>
<link rel="match" href="input-line-height-ref.html">
<style>
input { font-size: 60px; line-height: 40px; width: 240px; }
.appearance-none { appearance: none; }
</style>
<p><input type=text value=text> <input type=text value=text class=appearance-none>
<p><input type=tel value=tel> <input type=tel value=tel class=appearance-none>
<p><input type=search value=search> <input type=search value=search class=appearance-none>
<p><input type=url value=url> <input type=url value=url class=appearance-none>
<p><input type=email value=email> <input type=email value=email class=appearance-none>
<p><input type=password value=password> <input type=password value=password class=appearance-none>

0 comments on commit ef3a81b

Please sign in to comment.