gecko-dev/layout/forms/test/test_unstyled_control_height.html
Emilio Cobos Álvarez 2714f19afd Bug 1698606 - Ensure baseline for text and date controls matches. r=jwatt
Ideally nsDateTimeControlFrame should / could inherit from
nsTextControlFrame, but this should do for now.

Test also covers the previous patch.

Differential Revision: https://phabricator.services.mozilla.com/D110076
2021-03-31 12:21:17 +00:00

51 lines
1.3 KiB
HTML

<!doctype html>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<style>
#container * {
white-space: nowrap;
appearance: none;
}
input[type=date] {
/* date by default uses a monospace font, which might have different metrics */
font: -moz-field;
}
.small-font * {
font-size: 8px !important; /* important to override rule above */
}
.no-padding * {
padding: 0;
}
</style>
<div id="container">
<input>
<input type=date>
<button>Foo</button>
<select><option>Foo</option></select>
</div>
<script>
function testHeightMatches(desc) {
let commonHeight = null;
let commonTop = null;
for (let element of document.querySelectorAll("#container > *")) {
let rect = element.getBoundingClientRect();
if (commonHeight === null) {
commonHeight = rect.height;
commonTop = rect.top;
}
is(rect.height, commonHeight, `Height of the controls should match for ${element.outerHTML}${desc}`);
is(rect.top, commonTop, `Top of the controls should match for ${element.outerHTML}${desc}`);
}
}
const container = document.getElementById("container");
testHeightMatches("");
container.className = "no-padding";
testHeightMatches(" without padding");
container.className = "small-font";
testHeightMatches(" with an small font");
</script>