haikuwebkit/LayoutTests/fast/forms/validation-bubble-disappear...

33 lines
1.2 KiB
HTML
Raw Permalink Normal View History

Protect this object in ValidationMessage::buildBubbleTree https://bugs.webkit.org/show_bug.cgi?id=211832 Reviewed by Ryosuke Niwa. Source/WebCore: ValidationMessage::buildBubbleTree is doing layout which can run a script detaching the owner form element, and this ValidationMessage object can be destroyed. Don't do layout in buildBubbleTree. Call adjustBubblePosition by using queuePostLayoutCallback and a weak pointer of ValidationMessage. ValidationMessage::deleteBubbleTree was causing ASSERT_WITH_SECURITY_IMPLICATION failures in ContainerNode::removeNodeWithScriptAssertion due to re-entrant of removeNodeWithScriptAssertion. UA shadow roots are never exposed to author scripts so this is safe. Use ScriptDisallowedScope::EventAllowedScope in it. Test: fast/forms/validation-bubble-disappears-during-layout.html * html/ValidationMessage.cpp: (WebCore::ValidationMessage::adjustBubblePosition): (WebCore::ValidationMessage::buildBubbleTree): (WebCore::ValidationMessage::deleteBubbleTree): Use ScriptDisallowedScope::EventAllowedScope. (WebCore::adjustBubblePosition): Changed to a member function. * html/ValidationMessage.h: Inherit CanMakeWeakPtr. LayoutTests: * fast/forms/validation-bubble-disappears-during-layout-expected.txt: Added. * fast/forms/validation-bubble-disappears-during-layout.html: Added. * platform/ios-wk1/TestExpectations: Marked validation-bubble-disappears-during-layout.html as Skip. * platform/win/TestExpectations: Ditto. Canonical link: https://commits.webkit.org/229233@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266913 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-11 06:58:18 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
description("Tests that the HTML form validation bubble disappears while layout. https://webkit.org/b/211832");
jsTestIsAsync = true;
onload = () => {
const button = document.querySelector('button');
button.setCustomValidity("Hello"); // Instanciate ValidationMessage
button.reportValidity(); // Instanciate timer. Focus the button
button.blur(); // Blur the focus
button.autofocus = true;
button.onfocus = () => {
// onfocus is called for the autofocus element during layout
document.body.appendChild(button); // Delete ValidationMessage
setTimeout(() => {
finishJSTest();
}, 0);
};
setTimeout(() => {
// Cocoa port doesn't dispatch onfocus event.
button.focus();
}, 1000);
}
</script>
</head>
<body>
<button></button>
</body>
</html>