haikuwebkit/LayoutTests/fast/forms/caps-lock-indicator-width.html

57 lines
1.2 KiB
HTML
Raw Permalink Normal View History

REGRESSION (r273072): Caps lock indicator in password field is too large https://bugs.webkit.org/show_bug.cgi?id=228970 rdar://81546781 Reviewed by Wenson Hsieh. Source/WebCore: r273072 made it so that flex items with an intrinsic size will honor their aspect ratio when computing their content size. Prior to the change, in taller password fields, the flex item representing the caps lock indicator would be tall and narrow. The height would stretch to fill the container, but the width would maintain its intrinsic width of 17px. Now that aspect ratio is accounted for, the width increases to match the height, resulting in a much larger indicator in taller password fields. However, while r273072 regressed the appearance of the caps lock indicator, it merely exposed an issue with the styling of the indicator. Consider the following test case, which is a reduced version how the caps lock indicator is styled: <div style="display: flex; height: 100px"> <div style="content: url(17_x_17_blue_square.svg); align-self: stretch;"></div> </div> Prior to r273072, this displayed a 17x17 blue square (inside a 17x100 flex item). However, in Chrome, Firefox, and WebKit after r273072, this shows a 100x100 blue square (inside a 100x100 flex item). This is the expected behavior now that aspect ratio is accounted for. Consequently, to fix the issue, the width of the indicator must be limited to a maximum value. 17px was chosen to be the max-width, as the indicator's width would not exceed 17px prior to r273072. Test: fast/forms/caps-lock-indicator-width.html * css/html.css: (input::-webkit-caps-lock-indicator): LayoutTests: Added a layout test to verify that the width of the caps lock indicator adapts to the height of the password field, but does not exceed a maximum width. The added test is skipped on WK1, since DumpRenderTree does not support toggling caps lock state. Implementing the testing hook in DRT is made difficult by the fact that, in WK1, the caps lock state is queried directly from the OS, using GetCurrentKeyModifiers. * fast/forms/caps-lock-indicator-width-expected.txt: Added. * fast/forms/caps-lock-indicator-width.html: Added. * platform/ios-wk1/TestExpectations: * platform/mac-wk1/TestExpectations: Canonical link: https://commits.webkit.org/240445@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280927 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-11 20:19:33 +00:00
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
<style>
#small {
height: 15px;
}
#large {
height: 100px;
}
</style>
</head>
<body>
<input type="password" id="small">
<br>
<input type="password" id="normal">
<br>
<input type="password" id="large">
</body>
<script>
jsTestIsAsync = true;
async function runTest(name, input, expectedWidth)
{
debug(name);
shadowRoot = window.internals.shadowRoot(input);
await UIHelper.activateElement(input);
await UIHelper.renderingUpdate();
capsLockIndicator = shadowRoot.querySelector("[pseudo='-webkit-caps-lock-indicator']");
capsLockIndicatorWidth = capsLockIndicator.getBoundingClientRect().width;
shouldBeEqualToNumber("capsLockIndicatorWidth", expectedWidth);
debug("");
}
addEventListener("load", async () => {
description("This test verifies that the width of the caps lock indicator in password fields adapts to the height of the field, but does not exceed a maximum value.");
await UIHelper.toggleCapsLock();
await runTest("Small height", small, 15);
await runTest("Default height", normal, 17);
await runTest("Large height", large, 17);
finishJSTest();
});
</script>
</html>