From ffe0b05abddfb8a9219dc42ac5b9dd40e4fe552e Mon Sep 17 00:00:00 2001 From: Glenn Skrzypczak Date: Fri, 4 Apr 2025 01:27:55 +0200 Subject: [PATCH] LibWeb/HTML: Add the commandForElement attribute to the button element This commit adds the commandForElement attribute to the button element. Executing commands is not implemented yet. --- Libraries/LibWeb/HTML/HTMLButtonElement.cpp | 1 + Libraries/LibWeb/HTML/HTMLButtonElement.h | 7 +- Libraries/LibWeb/HTML/HTMLButtonElement.idl | 1 + .../command-and-commandfor/interface.txt | 16 ++++ .../tentative/property-reflection.txt | 34 ++++++- .../command-and-commandfor/interface.html | 88 +++++++++++++++++++ 6 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.html diff --git a/Libraries/LibWeb/HTML/HTMLButtonElement.cpp b/Libraries/LibWeb/HTML/HTMLButtonElement.cpp index 4ea99239cf5..6a89afa9d87 100644 --- a/Libraries/LibWeb/HTML/HTMLButtonElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLButtonElement.cpp @@ -87,6 +87,7 @@ void HTMLButtonElement::visit_edges(Visitor& visitor) { Base::visit_edges(visitor); PopoverInvokerElement::visit_edges(visitor); + visitor.visit(m_command_for_element); } // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex diff --git a/Libraries/LibWeb/HTML/HTMLButtonElement.h b/Libraries/LibWeb/HTML/HTMLButtonElement.h index d30d0fe3d52..a4d5e8ff456 100644 --- a/Libraries/LibWeb/HTML/HTMLButtonElement.h +++ b/Libraries/LibWeb/HTML/HTMLButtonElement.h @@ -81,7 +81,10 @@ public: virtual void activation_behavior(DOM::Event const&) override; String command() const; - WebIDL::ExceptionOr set_command(String const& command); + WebIDL::ExceptionOr set_command(String const&); + + GC::Ptr command_for_element() { return m_command_for_element; } + void set_command_for_element(GC::Ptr value) { m_command_for_element = value; } private: virtual void visit_edges(Visitor&) override; @@ -92,6 +95,8 @@ private: // ^DOM::Element virtual i32 default_tab_index_value() const override; + + GC::Ptr m_command_for_element; }; } diff --git a/Libraries/LibWeb/HTML/HTMLButtonElement.idl b/Libraries/LibWeb/HTML/HTMLButtonElement.idl index 9746bae0635..3fa1ab1ae9f 100644 --- a/Libraries/LibWeb/HTML/HTMLButtonElement.idl +++ b/Libraries/LibWeb/HTML/HTMLButtonElement.idl @@ -16,6 +16,7 @@ interface HTMLButtonElement : HTMLElement { [HTMLConstructor] constructor(); [CEReactions] attribute DOMString command; + [CEReactions, Reflect=commandfor] attribute Element? commandForElement; [CEReactions, Reflect] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute USVString formAction; diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.txt new file mode 100644 index 00000000000..6173a5c7e1f --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.txt @@ -0,0 +1,16 @@ +Harness status: OK + +Found 11 tests + +11 Pass +Pass commandForElement reflects invokee HTML element +Pass commandForElement reflects set value +Pass commandForElement reflects set value across shadow root into light dom +Pass commandForElement does not reflect set value inside shadowroot +Pass commandForElement throws error on assignment of non Element +Pass command reflects '' when attribute empty, setAttribute version +Pass command reflects correctly for invalid +Pass command reflects '' when attribute empty, IDL version +Pass command reflects correctly for invalid when array +Pass command reflects '' when attribute set to [] +Pass command reflects correctly for invalid when object \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/reference-target/tentative/property-reflection.txt b/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/reference-target/tentative/property-reflection.txt index 64fe4c0661b..169c4450af0 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/reference-target/tentative/property-reflection.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/reference-target/tentative/property-reflection.txt @@ -1,52 +1,67 @@ Harness status: OK -Found 1111 tests +Found 1141 tests -1080 Pass +1110 Pass 31 Fail Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to button with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to button with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to button with reference target Pass button.form has reflection behavior IsNull when pointing to button with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to input with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to input with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to input with reference target Pass button.form has reflection behavior IsNull when pointing to input with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to meter with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to meter with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to meter with reference target Pass button.form has reflection behavior IsNull when pointing to meter with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to output with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to output with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to output with reference target Pass button.form has reflection behavior IsNull when pointing to output with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to progress with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to progress with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to progress with reference target Pass button.form has reflection behavior IsNull when pointing to progress with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to select with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to select with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to select with reference target Pass button.form has reflection behavior IsNull when pointing to select with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to textarea with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to textarea with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to textarea with reference target Pass button.form has reflection behavior IsNull when pointing to textarea with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to div with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to div with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to div with reference target Pass button.form has reflection behavior IsNull when pointing to div with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to object with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to object with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to object with reference target Pass button.form has reflection behavior IsNull when pointing to object with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to label with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to label with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to label with reference target Pass button.form has reflection behavior IsNull when pointing to label with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to fieldset with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to fieldset with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to fieldset with reference target Pass button.form has reflection behavior IsNull when pointing to fieldset with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to legend with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to legend with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to legend with reference target Pass button.form has reflection behavior IsNull when pointing to legend with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to option with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to option with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to option with reference target Pass button.form has reflection behavior IsNull when pointing to option with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to datalist with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to datalist with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to datalist with reference target Pass button.form has reflection behavior IsNull when pointing to datalist with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to form with reference target +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to form with reference target Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to form with reference target Fail button.form has reflection behavior ReflectsHost when pointing to form with reference target Pass input.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to button with reference target @@ -470,48 +485,63 @@ Pass form.ariaActiveDescendantElement has reflection behavior ReflectsHost when Pass form.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to datalist with reference target Pass form.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to form with reference target Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to button with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to button with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to button with reference target via options Pass button.form has reflection behavior IsNull when pointing to button with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to input with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to input with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to input with reference target via options Pass button.form has reflection behavior IsNull when pointing to input with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to meter with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to meter with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to meter with reference target via options Pass button.form has reflection behavior IsNull when pointing to meter with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to output with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to output with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to output with reference target via options Pass button.form has reflection behavior IsNull when pointing to output with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to progress with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to progress with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to progress with reference target via options Pass button.form has reflection behavior IsNull when pointing to progress with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to select with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to select with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to select with reference target via options Pass button.form has reflection behavior IsNull when pointing to select with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to textarea with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to textarea with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to textarea with reference target via options Pass button.form has reflection behavior IsNull when pointing to textarea with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to div with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to div with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to div with reference target via options Pass button.form has reflection behavior IsNull when pointing to div with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to object with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to object with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to object with reference target via options Pass button.form has reflection behavior IsNull when pointing to object with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to label with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to label with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to label with reference target via options Pass button.form has reflection behavior IsNull when pointing to label with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to fieldset with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to fieldset with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to fieldset with reference target via options Pass button.form has reflection behavior IsNull when pointing to fieldset with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to legend with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to legend with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to legend with reference target via options Pass button.form has reflection behavior IsNull when pointing to legend with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to option with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to option with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to option with reference target via options Pass button.form has reflection behavior IsNull when pointing to option with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to datalist with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to datalist with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to datalist with reference target via options Pass button.form has reflection behavior IsNull when pointing to datalist with reference target via options Pass button.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to form with reference target via options +Pass button.commandForElement has reflection behavior ReflectsHost when pointing to form with reference target via options Pass button.popoverTargetElement has reflection behavior ReflectsHost when pointing to form with reference target via options Fail button.form has reflection behavior ReflectsHost when pointing to form with reference target via options Pass input.ariaActiveDescendantElement has reflection behavior ReflectsHost when pointing to button with reference target via options diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.html new file mode 100644 index 00000000000..b54d2040a24 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/the-button-element/command-and-commandfor/interface.html @@ -0,0 +1,88 @@ + + + + + + + + +
+ +