haikuwebkit/LayoutTests/fast/forms/programmatic-focus-after-di...

51 lines
1.6 KiB
HTML
Raw Permalink Normal View History

REGRESSION (r257839): Can't add a memo when transferring funds in First Tech Credit Union App https://bugs.webkit.org/show_bug.cgi?id=216754 <rdar://problem/67045862> Reviewed by Antti Koivisto. Source/WebCore: After r257839, attempting to add a memo by tapping on a text box in the First Tech Credit Union app on iOS fails to cause the text box (a `textarea` element) to be focused. This is because the `textarea` is initially hidden away in a `display: none;` parent container, which becomes `display: block;` immediately before `focus()` is called from the page's script. Augment the mechanism added in r266887, so that we avoid consulting stale computed styles when checking for hidden ancestors in `Element::isVisibleWithoutResolvingFullStyle()`. To do this, we pull logic to get or compute the `RenderStyle` for the current element or one of its composed ancestors (which respects `IsComputedStyleInvalidFlag`) into a lambda function, and use this lambda function below, when we walk up the ancestor chain in search of a hidden element. Note that in Speedometer 2.0, this change does not have any significant impact on the number of partial (i.e. `RenderedOnly`) style resolutions we attempt to perform underneath `Element::resolveComputedStyle` (a little over 3000 before and after this change). Test: fast/forms/programmatic-focus-after-displaying-parent.html * dom/Element.cpp: (WebCore::Element::isVisibleWithoutResolvingFullStyle const): LayoutTests: Add a new layout test to exercise the bug by programmatically focusing a textarea element that was just shown by setting `display: block;` on a parent container that was previously `display: none;`. * fast/forms/programmatic-focus-after-displaying-parent-expected.txt: Added. * fast/forms/programmatic-focus-after-displaying-parent.html: Added. Canonical link: https://commits.webkit.org/229564@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-21 15:11:43 +00:00
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<script src="../../resources/ui-helper.js"></script>
<script src="../../resources/js-test.js"></script>
<style>
input {
font-size: 20px;
}
#container {
display: none;
}
</style>
</head>
<body>
<input type="text" value="Click me">
<div id="container">
<textarea></textarea>
</div>
<script>
jsTestIsAsync = true;
didFinishActivatingElement = false;
input = document.querySelector("input[type='text']");
textarea = document.querySelector("textarea");
container = document.getElementById("container");
input.addEventListener("focus", async () => {
getComputedStyle(container).display; // This is necessary in order to reproduce the bug.
container.style.display = "block";
textarea.focus();
shouldBe("document.activeElement", "textarea");
container.remove();
input.remove();
await new Promise(resolve => shouldBecomeEqual("didFinishActivatingElement", "true", resolve));
finishJSTest();
});
addEventListener("load", async () => {
description("This test verifies that programmatically focusing a textarea in a newly displayed container changes the active element. To test manually, tap or click below.");
if (window.testRunner)
await UIHelper.activateElement(input);
didFinishActivatingElement = true;
});
</script>
</body>
</html>