ladybird/Tests/LibWeb/Text/input/DOM/disconnected-input-shadow-tree-elements.html
Callum Law f28e7120ea LibWeb: Ensure that shadow roots have hosts before appending children
This change gives each shadow root its host before appending its
children, and asserts that a root has no children when it's assigned to
a host. This ensures the children inherit the correct connectedness.

Otherwise, without this change, the user-agent shadow trees for color
and file inputs append their children before the shadow root is given
a host which, if the input element has already been inserted, means the
children stay marked disconnected despite being present in the rendered
tree. Disconnected nodes then skip layout invalidations they should
trigger.

Fixes a crash when submitting a prompt on https://chatgpt.com
2026-06-05 18:08:21 +09:00

20 lines
589 B
HTML

<!doctype html>
<html>
<input id="fileInput" />
<input id="colorInput" />
<script src="../include.js"></script>
<script>
promiseTest(async () => {
await animationFrame();
await animationFrame();
// Rebuild the shadow tree so
fileInput.setAttribute("type", "file");
println(internals.getShadowRoot(fileInput).firstChild.isConnected);
colorInput.setAttribute("type", "color");
println(internals.getShadowRoot(colorInput).firstChild.isConnected);
});
</script>
</html>