Skip to content

Lightpanda: the headless browser designed for AI and automation

input: add scripted label.click() focus test and clean up empty branch

Adrià Arrufatf24adec81402
diff --git a/src/browser/frame/user_input.zig b/src/browser/frame/user_input.zig
index c1ed0e1df..284b358ba 100644
--- a/src/browser/frame/user_input.zig
+++ b/src/browser/frame/user_input.zig
@@ -713,7 +713,6 @@ pub fn handleClick(frame: *Frame, target: *Node, event_target: *Node) !void {
return frame.submitForm(element, button.getForm(frame), .{});
}
},
- .select, .textarea => {},
.label => {
const label = html_element.subtype(Element.Html.Label);
// Per HTML §4.10.4 "The label element", a label's activation
diff --git a/src/browser/tests/document/focus.html b/src/browser/tests/document/focus.html
index 5f077ff3c..0b2221a47 100644
--- a/src/browser/tests/document/focus.html
+++ b/src/browser/tests/document/focus.html
@@ -4,6 +4,7 @@
<input id="input1" type="text">
<input id="input2" type="text">
<button id="btn1">Button</button>
+ <label id="lbl1" for="input1">Label 1</label>
</body>
<script id="activeElement_default">
@@ -286,6 +287,25 @@
}
</script>
+<script id="label_click_focuses_control">
+{
+ const input1 = $('#input1');
+ const lbl = $('#lbl1');
+
+ if (document.activeElement) {
+ document.activeElement.blur();
+ }
+
+ let focusCount = 0;
+ input1.addEventListener('focus', () => focusCount++);
+
+ // Unlike other elements, label.click() explicitly focuses its control
+ lbl.click();
+ testing.expectEqual(input1, document.activeElement);
+ testing.expectEqual(1, focusCount);
+}
+</script>
+
<script id="focus_disconnected_no_blur">
{
const input1 = $('#input1');