diff --git a/Tests/LibWeb/Text/expected/Editing/execCommand-is-a-noop.txt b/Tests/LibWeb/Text/expected/Editing/execCommand-is-a-noop.txt new file mode 100644 index 0000000000..c734c74327 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Editing/execCommand-is-a-noop.txt @@ -0,0 +1,7 @@ +Hello, world!I'm totally bold rn execCommand("bold") returned false +Hello, world!I'm totally bold rn +queryCommandEnabled("bold") returned false +queryCommandIndeterm("bold") returned false +queryCommandState("bold") returned false +queryCommandSupported("bold") returned false +queryCommandValue("bold") returned "" diff --git a/Tests/LibWeb/Text/input/Editing/execCommand-is-a-noop.html b/Tests/LibWeb/Text/input/Editing/execCommand-is-a-noop.html new file mode 100644 index 0000000000..7470d87848 --- /dev/null +++ b/Tests/LibWeb/Text/input/Editing/execCommand-is-a-noop.html @@ -0,0 +1,32 @@ + +
+ diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 748509dcb4..6c93dd3e08 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -2987,13 +2987,6 @@ void Document::did_stop_being_active_document_in_navigable() } } -// https://w3c.github.io/editing/docs/execCommand/#querycommandsupported() -bool Document::query_command_supported(String const& command) const -{ - dbgln("(STUBBED) Document::query_command_supported(command='{}')", command); - return false; -} - void Document::increment_throw_on_dynamic_markup_insertion_counter(Badge) { ++m_throw_on_dynamic_markup_insertion_counter; @@ -4076,4 +4069,40 @@ WebIDL::ExceptionOr Document::named_item_value(FlyString const& name) return collection; } +// https://w3c.github.io/editing/docs/execCommand/#execcommand() +bool Document::exec_command(String, bool, String) +{ + return false; +} + +// https://w3c.github.io/editing/docs/execCommand/#querycommandenabled() +bool Document::query_command_enabled(String) +{ + return false; +} + +// https://w3c.github.io/editing/docs/execCommand/#querycommandindeterm() +bool Document::query_command_indeterm(String) +{ + return false; +} + +// https://w3c.github.io/editing/docs/execCommand/#querycommandstate() +bool Document::query_command_state(String) +{ + return false; +} + +// https://w3c.github.io/editing/docs/execCommand/#querycommandsupported() +bool Document::query_command_supported(String) +{ + return false; +} + +// https://w3c.github.io/editing/docs/execCommand/#querycommandvalue() +String Document::query_command_value(String) +{ + return String {}; +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index cabb04f05f..02b9b8dd2c 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -500,12 +500,18 @@ public: DocumentUnloadTimingInfo const& previous_document_unload_timing() const { return m_previous_document_unload_timing; } void set_previous_document_unload_timing(DocumentUnloadTimingInfo const& previous_document_unload_timing) { m_previous_document_unload_timing = previous_document_unload_timing; } + // https://w3c.github.io/editing/docs/execCommand/ + bool exec_command(String command_id, bool show_ui, String value); + bool query_command_enabled(String command_id); + bool query_command_indeterm(String command_id); + bool query_command_state(String command_id); + bool query_command_supported(String command_id); + String query_command_value(String command_id); + bool is_allowed_to_use_feature(PolicyControlledFeature) const; void did_stop_being_active_document_in_navigable(); - bool query_command_supported(String const&) const; - String dump_accessibility_tree_as_json(); void make_active(); diff --git a/Userland/Libraries/LibWeb/DOM/Document.idl b/Userland/Libraries/LibWeb/DOM/Document.idl index a6782a3d15..a964941768 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.idl +++ b/Userland/Libraries/LibWeb/DOM/Document.idl @@ -106,7 +106,6 @@ interface Document : Node { [CEReactions] attribute DOMString title; - boolean queryCommandSupported(DOMString commandId); readonly attribute boolean hidden; readonly attribute DOMString visibilityState; @@ -124,6 +123,14 @@ interface Document : Node { Element? elementFromPoint(double x, double y); sequence elementsFromPoint(double x, double y); readonly attribute Element? scrollingElement; + + // https://w3c.github.io/editing/docs/execCommand/ + [CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = ""); + boolean queryCommandEnabled(DOMString commandId); + boolean queryCommandIndeterm(DOMString commandId); + boolean queryCommandState(DOMString commandId); + boolean queryCommandSupported(DOMString commandId); + DOMString queryCommandValue(DOMString commandId); }; dictionary ElementCreationOptions {