Truly independent web browser
LibWeb: Support the cut and copy commands in execCommand()
Andreas Kling0f52003de3a1
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.hindex f4b246d3653..d5e1942671c 100644--- a/Libraries/LibWeb/DOM/Document.h+++ b/Libraries/LibWeb/DOM/Document.h@@ -2383,6 +2383,7 @@ private:GC::Ptr<Editing::EditingHistory> m_editing_history;bool m_inside_exec_command { false };+ bool m_inside_clipboard_exec_command { false };bool m_running_editing_command_action { false };bool m_preserve_selection_offsets_during_identical_character_data_replacement { false };diff --git a/Libraries/LibWeb/Editing/ExecCommand.cpp b/Libraries/LibWeb/Editing/ExecCommand.cppindex 0d6af6ea52c..1a069c0375c 100644--- a/Libraries/LibWeb/Editing/ExecCommand.cpp+++ b/Libraries/LibWeb/Editing/ExecCommand.cpp@@ -24,9 +24,11 @@#include <LibWeb/HTML/HTMLInputElement.h>#include <LibWeb/HTML/HTMLLIElement.h>#include <LibWeb/HTML/HTMLTextAreaElement.h>+#include <LibWeb/HTML/LocalNavigable.h>#include <LibWeb/HTML/Parser/HTMLParser.h>#include <LibWeb/HTML/Scripting/Environments.h>#include <LibWeb/HighResolutionTime/TimeOrigin.h>+#include <LibWeb/Page/EventHandler.h>#include <LibWeb/Selection/Selection.h>#include <LibWeb/UIEvents/InputEvent.h>#include <LibWeb/UIEvents/InputTypes.h>@@ -122,9 +124,58 @@ static bool exec_command_in_text_control(HTML::FormAssociatedTextControlElement&return true;}+static bool is_clipboard_command(Utf16FlyString const& command)+{+ return command.is_one_of_ignoring_ascii_case(Editing::CommandNames::copy, Editing::CommandNames::cut);+}++// Whether the copy or cut command has selected content to act on.+static bool clipboard_command_is_enabled(Document& document, Utf16FlyString const& command)+{+ if (auto* control = focused_text_control(document)) {+ if (auto* input = as_if<HTML::HTMLInputElement>(control->text_control_to_html_element());+ input && input->type_state() == HTML::HTMLInputElement::TypeAttributeState::Password)+ return false;+ if (control->selection_start() == control->selection_end())+ return false;+ return !command.equals_ignoring_ascii_case(Editing::CommandNames::cut)+ || as<HTML::FormAssociatedElement>(control->text_control_to_html_element()).is_mutable();+ }+ auto range = Editing::active_range(document);+ if (!range || range->collapsed())+ return false;+ return !command.equals_ignoring_ascii_case(Editing::CommandNames::cut)+ || (range->start_container()->is_editable_or_editing_host() && range->end_container()->is_editable_or_editing_host());+}+// https://w3c.github.io/editing/docs/execCommand/#execcommand()WebIDL::ExceptionOr<bool> Document::exec_command(Utf16FlyString const& command, [[maybe_unused]] bool show_ui, Utf16View value){+ // NB: Clipboard actions can delete through the internal editing entry point, but their script callbacks must+ // not recursively execute public commands, including input listeners on text controls.+ if (m_inside_clipboard_exec_command)+ return false;++ // https://w3c.github.io/clipboard-apis/#integration-with-rich-text-editing+ // These are the steps to follow when triggering copy, cut or paste actions through a scripting API:+ // 1. Execute the corresponding action synchronously.+ // 2. Use the action's return value as the return value for the API call.+ // NB: The actions also run when the command is not enabled, since they fire their clipboard event in any case.+ if (is_clipboard_command(command) && is_html_document()) {+ // NB: See the AD-HOC note about recursive calls in exec_command_internal().+ if (m_inside_exec_command)+ return false;+ TemporaryChange guard_recursion { m_inside_clipboard_exec_command, true };++ auto navigable = this->navigable();+ if (!navigable || navigable->active_document().ptr() != this)+ return false;+ auto trigger = Web::EventHandler::ClipboardActionTrigger::Script;+ if (command.equals_ignoring_ascii_case(Editing::CommandNames::copy))+ return navigable->event_handler().perform_copy_action(trigger);+ return navigable->event_handler().perform_cut_action(trigger);+ }+// NB: See the INTEROP note at focused_text_control(). exec_command_internal() checks whether the command is// enabled for the active range only, so check whether it is enabled for the text control here.if (auto* control = focused_text_control(*this); control && is_html_document() && !m_inside_exec_command) {@@ -159,8 +210,9 @@ WebIDL::ExceptionOr<bool> Document::exec_command_internal(Utf16FlyString const&// 3. If command is not supported or not enabled, return false.// NB: This does not use query_command_enabled(), which reports whether a command is enabled in a focused text- // control. The commands below act on the active range, and rely on it being checked here.- if (!MUST(query_command_supported(command)) || !command_is_enabled(*this, command))+ // control. The commands below act on the active range, and rely on it being checked here. The clipboard+ // commands are handled by exec_command().+ if (is_clipboard_command(command) || !MUST(query_command_supported(command)) || !command_is_enabled(*this, command))return false;// 4. If command is not in the Miscellaneous commands section:@@ -417,6 +469,9 @@ WebIDL::ExceptionOr<bool> Document::query_command_enabled(Utf16FlyString const&if (!MUST(query_command_supported(command)))return false;+ if (is_clipboard_command(command))+ return clipboard_command_is_enabled(*this, command);+// NB: See the INTEROP note at focused_text_control().if (auto command_definition = Editing::find_command_definition(command); command_definition.has_value()) {if (auto enabled = query_command_enabled_in_text_control(*this, command_definition->command); enabled.has_value())@@ -632,7 +687,8 @@ WebIDL::ExceptionOr<bool> Document::query_command_supported(Utf16FlyString const// When the queryCommandSupported(command) method on the Document interface is invoked, the user agent must return// true if command is supported and available within the current script on the current site, and false otherwise.- return Editing::find_command_definition(command).has_value();+ // NB: The copy and cut commands are defined by the clipboard API, and execCommand() triggers their actions.+ return Editing::find_command_definition(command).has_value() || is_clipboard_command(command);}// https://w3c.github.io/editing/docs/execCommand/#querycommandvalue()diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cppindex d3d6b7e183c..3f87b0b53cd 100644--- a/Libraries/LibWeb/Page/EventHandler.cpp+++ b/Libraries/LibWeb/Page/EventHandler.cpp@@ -2513,12 +2513,47 @@ static void write_data_transfer_to_clipboard(DOM::Document& document, HTML::Dragdocument.page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv);}-// https://w3c.github.io/clipboard-apis/#the-copy-actionEventResult EventHandler::perform_copy_action(){auto document = m_navigable->active_document();if (!document || !document->is_fully_active())return EventResult::Dropped;+ perform_copy_action(ClipboardActionTrigger::User);+ return EventResult::Handled;+}++// Whether script may write to the clipboard, which it may do while its window has transient activation.+static bool script_may_access_clipboard(DOM::Document& document)+{+ auto window = document.window();+ return window && window->has_transient_activation();+}++static bool has_selected_password_input(DOM::Document& document)+{+ auto focused_area = document.focused_area();+ auto const* input = focused_area ? as_if<HTML::HTMLInputElement>(*focused_area) : nullptr;+ return input && input->type_state() == HTML::HTMLInputElement::TypeAttributeState::Password+ && input->selection_start() != input->selection_end();+}++// https://w3c.github.io/clipboard-apis/#the-copy-action+bool EventHandler::perform_copy_action(ClipboardActionTrigger trigger)+{+ auto document = m_navigable->active_document();+ if (!document || !document->is_fully_active())+ return false;++ // 1. If the script-triggered flag is set, then+ // 1. If the script-may-access-clipboard flag is unset, then+ // 1. Return false from the copy action, terminate this algorithm+ // INTEROP: Browsers fire the copy event before they check whether script may access the clipboard, so that web+ // apps can implement their own editor. They do not change the clipboard in that case.+ auto may_access_clipboard = trigger == ClipboardActionTrigger::User || script_may_access_clipboard(*document);++ // INTEROP: With clipboard access, a script clipboard command on a selected password input is a successful no-op.+ if (trigger == ClipboardActionTrigger::Script && may_access_clipboard && has_selected_password_input(*document))+ return true;auto data_store = HTML::DragDataStore::create();data_store->set_mode(HTML::DragDataStore::Mode::ReadWrite);@@ -2528,12 +2563,21 @@ EventResult EventHandler::perform_copy_action()bool event_was_not_canceled = fire_clipboard_event(*document, HTML::EventNames::copy, data_transfer);data_store->set_mode(HTML::DragDataStore::Mode::Protected);+ // NB: The event listeners can make the document inactive, for example by removing its iframe.+ if (!may_access_clipboard || !document->is_fully_active())+ return false;+// 3. If the event was not canceled, then:if (event_was_not_canceled) {// 1. Copy the selected contents, if any, to the clipboard. Implementations should create alternate text/html// and text/plain clipboard formats when content in a web page is selected.auto text = m_navigable->selected_text();auto html = m_navigable->selected_html_for_clipboard();++ // INTEROP: Browsers return false from a script-triggered copy if nothing is selected.+ if (trigger == ClipboardActionTrigger::Script && text.is_empty() && html.is_empty())+ return false;+Vector<Clipboard::SystemClipboardRepresentation> representations;if (!html.is_empty())representations.empend("text/html"_string, html.to_byte_string());@@ -2552,15 +2596,35 @@ EventResult EventHandler::perform_copy_action()}// 5. Return true from the copy action.- return EventResult::Handled;+ return true;}-// https://w3c.github.io/clipboard-apis/#the-cut-actionEventResult EventHandler::perform_cut_action(){auto document = m_navigable->active_document();if (!document || !document->is_fully_active())return EventResult::Dropped;+ perform_cut_action(ClipboardActionTrigger::User);+ return EventResult::Handled;+}++// https://w3c.github.io/clipboard-apis/#the-cut-action+bool EventHandler::perform_cut_action(ClipboardActionTrigger trigger)+{+ auto document = m_navigable->active_document();+ if (!document || !document->is_fully_active())+ return false;++ // 1. If the script-triggered flag is set, then+ // 1. If the script-may-access-clipboard flag is unset, then+ // 1. Return false from the cut action, terminate this algorithm+ // INTEROP: Browsers fire the cut event before they check whether script may access the clipboard, so that web+ // apps can implement their own editor. They do not change the clipboard or the document in that case.+ auto may_access_clipboard = trigger == ClipboardActionTrigger::User || script_may_access_clipboard(*document);++ // INTEROP: With clipboard access, a script clipboard command on a selected password input is a successful no-op.+ if (trigger == ClipboardActionTrigger::Script && may_access_clipboard && has_selected_password_input(*document))+ return true;auto data_store = HTML::DragDataStore::create();data_store->set_mode(HTML::DragDataStore::Mode::ReadWrite);@@ -2570,31 +2634,61 @@ EventResult EventHandler::perform_cut_action()bool event_was_not_canceled = fire_clipboard_event(*document, HTML::EventNames::cut, data_transfer);data_store->set_mode(HTML::DragDataStore::Mode::Protected);+ // NB: The event listeners can make the document inactive, for example by removing its iframe.+ if (!may_access_clipboard || !document->is_fully_active())+ return false;+// 3. If the event was not canceled, then:if (event_was_not_canceled) {// 1. If there is a selection in an editable context where cutting is enabled, then:- if (auto* target = document->active_input_events_target()) {- auto text = m_navigable->selected_text();- auto html = m_navigable->selected_html_for_clipboard();- if (!text.is_empty() || !html.is_empty()) {- // 1. Copy the selected contents, if any, to the clipboard. Implementations should create alternate- // text/html and text/plain clipboard formats when content in a web page is selected.- Vector<Clipboard::SystemClipboardRepresentation> representations;- if (!html.is_empty())- representations.empend("text/html"_string, html.to_byte_string());- if (!text.is_empty())- representations.empend("text/plain"_string, text.to_byte_string());+ auto* target = document->active_input_events_target();+ if (!target)+ return false;+ auto text = m_navigable->selected_text();+ auto html = m_navigable->selected_html_for_clipboard();+ if (!text.is_empty() || !html.is_empty()) {+ if (auto focused_area = document->focused_area()) {+ if (auto* control = as_if<HTML::FormAssociatedTextControlElement>(*focused_area);+ control && !as<HTML::FormAssociatedElement>(control->text_control_to_html_element()).is_mutable())+ return true;+ }+ auto target_cell = target->as_cell();+ auto scope = target->mouse_selection_scope();+ if (trigger == ClipboardActionTrigger::User && (!scope || !scope->is_connected()))+ return false;+ // 1. Copy the selected contents, if any, to the clipboard. Implementations should create alternate+ // text/html and text/plain clipboard formats when content in a web page is selected.+ Vector<Clipboard::SystemClipboardRepresentation> representations;+ if (!html.is_empty())+ representations.empend("text/html"_string, html.to_byte_string());+ if (!text.is_empty())+ representations.empend("text/plain"_string, text.to_byte_string());+ if (!representations.is_empty())document->page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv);- // 2. Remove the contents of the selection from the document and collapse the selection.- // 4. Queue tasks to fire any events that should fire due to the modification.- FIRE(input_event(UIEvents::EventNames::beforeinput, UIEvents::InputTypes::deleteByCut, m_navigable, 0));- target->handle_delete(UIEvents::InputTypes::deleteByCut);-- // FIXME: 3. Fire a clipboard event named clipboardchange.+ // 2. Remove the contents of the selection from the document and collapse the selection.+ // 4. Queue tasks to fire any events that should fire due to the modification.+ // INTEROP: Browsers do not fire a beforeinput event for a script-triggered cut.+ if (trigger == ClipboardActionTrigger::User) {+ if (input_event(UIEvents::EventNames::beforeinput, UIEvents::InputTypes::deleteByCut, m_navigable, 0) == EventResult::Cancelled)+ return true;+ if (m_navigable->active_document() != document || !document->is_fully_active())+ return false;+ auto* current_target = document->active_input_events_target();+ if (!current_target || current_target->as_cell() != target_cell || !scope->is_connected()+ || current_target->mouse_selection_scope() != scope)+ return false;+ target = current_target;}+ target->handle_delete(UIEvents::InputTypes::deleteByCut);++ // FIXME: 3. Fire a clipboard event named clipboardchange.+ }+ // 2. Else, if there is no selection or the context is not editable, then:+ else {+ // 1. Return false+ return false;}- // 2. Else, there is no selection or the context is not editable; do nothing.}// 4. Else, if the event was canceled, then:else {@@ -2606,7 +2700,7 @@ EventResult EventHandler::perform_cut_action()}// 5. Return true from the cut action.- return EventResult::Handled;+ return true;}// https://w3c.github.io/clipboard-apis/#paste-actiondiff --git a/Libraries/LibWeb/Page/EventHandler.h b/Libraries/LibWeb/Page/EventHandler.hindex 8f8d2661bd2..9c6558a1ae2 100644--- a/Libraries/LibWeb/Page/EventHandler.h+++ b/Libraries/LibWeb/Page/EventHandler.h@@ -112,6 +112,13 @@ public:[[nodiscard]] EventResult perform_paste_action();EventResult perform_paste_action(NonnullRefPtr<HTML::DragDataStore> const&);+ enum class ClipboardActionTrigger {+ User,+ Script,+ };+ bool perform_copy_action(ClipboardActionTrigger);+ bool perform_cut_action(ClipboardActionTrigger);+void handle_gamepad_connected(Gamepad::GamepadDescription const&);void handle_gamepad_updated(Gamepad::GamepadState const&);void handle_gamepad_disconnected(Gamepad::GamepadHandle);diff --git a/Tests/LibWeb/Text/expected/Editing/clipboard-cut-beforeinput-target.txt b/Tests/LibWeb/Text/expected/Editing/clipboard-cut-beforeinput-target.txtnew file mode 100644index 00000000000..967ff9d14eb--- /dev/null+++ b/Tests/LibWeb/Text/expected/Editing/clipboard-cut-beforeinput-target.txt@@ -0,0 +1,6 @@+focus change: PASS+removed control: PASS+same control selection change: PASS+editing host scope change: PASS+same host selection change: PASS+detached document: PASSdiff --git a/Tests/LibWeb/Text/expected/Editing/clipboard-text-control-actions.txt b/Tests/LibWeb/Text/expected/Editing/clipboard-text-control-actions.txtnew file mode 100644index 00000000000..108e39457fa--- /dev/null+++ b/Tests/LibWeb/Text/expected/Editing/clipboard-text-control-actions.txt@@ -0,0 +1,14 @@+text readonly script cut: PASS+text readonly user cut: PASS+textarea readonly script cut: PASS+textarea readonly user cut: PASS+password commands disabled: PASS+selected password copy: PASS+selected password cut: PASS+native password cut unchanged: PASS+text readonly canceled cut: PASS+textarea readonly canceled cut: PASS+cut listener disables editing: PASS+cut listener enables editing: PASS+fresh password document has no activation: PASS+password without activation unchanged: PASSdiff --git a/Tests/LibWeb/Text/expected/Editing/execcommand-cut-contenteditable-recursion.txt b/Tests/LibWeb/Text/expected/Editing/execcommand-cut-contenteditable-recursion.txtnew file mode 100644index 00000000000..6a02bd81dc4--- /dev/null+++ b/Tests/LibWeb/Text/expected/Editing/execcommand-cut-contenteditable-recursion.txt@@ -0,0 +1,13 @@+rich script cut deletes and copies: PASS+rich script cut event order: PASS+rich cut undo: PASS+rich cut redo: PASS+cut callback recursive commands blocked: PASS+rich input callback recursive commands blocked: PASS+guarded rich cut completes: PASS+text control input recursion remains blocked: PASS+guarded text control cut completes: PASS+canceled cut recursion remains blocked: PASS+canceled cut writes custom data only: PASS+copy callback recursive commands blocked: PASS+guarded copy leaves content intact: PASSdiff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=password.txt b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=password.txtindex 134d685f17c..bd01dde6638 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=password.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=password.txt@@ -1,9 +1,9 @@Harness status: OK-Found 648 tests+Found 688 tests-628 Pass-20 Fail+670 Pass+18 FailPass In <input type="password">, execCommand("getHTML", false, null), a[b]c): The command should not be supportedPass In <input type="password">, execCommand("getHTML", false, null), a[b]c): The command should not be enabledPass In <input type="password">, execCommand("bold", false, bold), a[b]c): The command should be supported@@ -41,14 +41,34 @@ Pass In <input type="password">, execCommand("superscript", false, null), a[b]c)Pass In <input type="password">, execCommand("superscript", false, null), a[b]c): should not fire beforeinput eventPass In <input type="password">, execCommand("superscript", false, null), a[b]c): input.inputType should be undefinedPass In <input type="password">, execCommand("superscript", false, null), a[b]c): input.target should be undefined-Fail In <input type="password">, execCommand("cut", false, null), ab[]c): The command should be supported+Pass In <input type="password">, execCommand("cut", false, null), ab[]c): The command should be supportedPass In <input type="password">, execCommand("cut", false, null), ab[]c): The command should not be enabled-Fail In <input type="password">, execCommand("cut", false, null), a[b]c): The command should be supported+Pass In <input type="password">, execCommand("cut", false, null), ab[]c): execCommand() should return false+Pass In <input type="password">, execCommand("cut", false, null), ab[]c): <input>.value should be "ab[]c"+Pass In <input type="password">, execCommand("cut", false, null), ab[]c): should not fire beforeinput event+Pass In <input type="password">, execCommand("cut", false, null), ab[]c): input.inputType should be undefined+Pass In <input type="password">, execCommand("cut", false, null), ab[]c): input.target should be undefined+Pass In <input type="password">, execCommand("cut", false, null), a[b]c): The command should be supportedFail In <input type="password">, execCommand("cut", false, null), a[b]c): The command should be enabled-Fail In <input type="password">, execCommand("copy", false, null), abc[]d): The command should be supported+Pass In <input type="password">, execCommand("cut", false, null), a[b]c): execCommand() should return true+Fail In <input type="password">, execCommand("cut", false, null), a[b]c): <input>.value should be "a[]c"+Pass In <input type="password">, execCommand("cut", false, null), a[b]c): should not fire beforeinput event+Fail In <input type="password">, execCommand("cut", false, null), a[b]c): input.inputType should be deleteByCut+Fail In <input type="password">, execCommand("cut", false, null), a[b]c): input.target should be [object HTMLInputElement]+Pass In <input type="password">, execCommand("copy", false, null), abc[]d): The command should be supportedPass In <input type="password">, execCommand("copy", false, null), abc[]d): The command should not be enabled-Fail In <input type="password">, execCommand("copy", false, null), a[bc]d): The command should be supported+Pass In <input type="password">, execCommand("copy", false, null), abc[]d): execCommand() should return false+Pass In <input type="password">, execCommand("copy", false, null), abc[]d): <input>.value should be "abc[]d"+Pass In <input type="password">, execCommand("copy", false, null), abc[]d): should not fire beforeinput event+Pass In <input type="password">, execCommand("copy", false, null), abc[]d): input.inputType should be undefined+Pass In <input type="password">, execCommand("copy", false, null), abc[]d): input.target should be undefined+Pass In <input type="password">, execCommand("copy", false, null), a[bc]d): The command should be supportedFail In <input type="password">, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <input type="password">, execCommand("copy", false, null), a[bc]d): execCommand() should return true+Pass In <input type="password">, execCommand("copy", false, null), a[bc]d): <input>.value should be "a[bc]d"+Pass In <input type="password">, execCommand("copy", false, null), a[bc]d): should not fire beforeinput event+Pass In <input type="password">, execCommand("copy", false, null), a[bc]d): input.inputType should be undefined+Pass In <input type="password">, execCommand("copy", false, null), a[bc]d): input.target should be undefinedFail In <input type="password">, execCommand("paste", false, null), a[]c): The command should be supportedFail In <input type="password">, execCommand("paste", false, null), a[]c): The command should be enabledPass In <input type="password">, execCommand("delete", false, null), ab[]c): The command should be supported@@ -365,14 +385,34 @@ Pass In <input type="password"> in contenteditable, execCommand("superscript", fPass In <input type="password"> in contenteditable, execCommand("superscript", false, null), a[b]c): should not fire beforeinput eventPass In <input type="password"> in contenteditable, execCommand("superscript", false, null), a[b]c): input.inputType should be undefinedPass In <input type="password"> in contenteditable, execCommand("superscript", false, null), a[b]c): input.target should be undefined-Fail In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): The command should be supported+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): The command should be supportedPass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): The command should not be enabled-Fail In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be supported+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): execCommand() should return false+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): <input>.value should be "ab[]c"+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): should not fire beforeinput event+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): input.inputType should be undefined+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), ab[]c): input.target should be undefined+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be supportedFail In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be enabled-Fail In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): The command should be supported+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): execCommand() should return true+Fail In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): <input>.value should be "a[]c"+Pass In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): should not fire beforeinput event+Fail In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): input.inputType should be deleteByCut+Fail In <input type="password"> in contenteditable, execCommand("cut", false, null), a[b]c): input.target should be [object HTMLInputElement]+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): The command should be supportedPass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): The command should not be enabled-Fail In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be supported+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): execCommand() should return false+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): <input>.value should be "abc[]d"+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): should not fire beforeinput event+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): input.inputType should be undefined+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), abc[]d): input.target should be undefined+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be supportedFail In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): execCommand() should return true+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): <input>.value should be "a[bc]d"+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): should not fire beforeinput event+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): input.inputType should be undefined+Pass In <input type="password"> in contenteditable, execCommand("copy", false, null), a[bc]d): input.target should be undefinedFail In <input type="password"> in contenteditable, execCommand("paste", false, null), a[]c): The command should be supportedFail In <input type="password"> in contenteditable, execCommand("paste", false, null), a[]c): The command should be enabledPass In <input type="password"> in contenteditable, execCommand("delete", false, null), ab[]c): The command should be supporteddiff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=text.txt b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=text.txtindex b3247cffc9d..c12b0a4f5ae 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=text.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=text.txt@@ -1,9 +1,9 @@Harness status: OK-Found 648 tests+Found 688 tests-628 Pass-20 Fail+677 Pass+11 FailPass In <input type="text">, execCommand("getHTML", false, null), a[b]c): The command should not be supportedPass In <input type="text">, execCommand("getHTML", false, null), a[b]c): The command should not be enabledPass In <input type="text">, execCommand("bold", false, bold), a[b]c): The command should be supported@@ -41,14 +41,34 @@ Pass In <input type="text">, execCommand("superscript", false, null), a[b]c): <iPass In <input type="text">, execCommand("superscript", false, null), a[b]c): should not fire beforeinput eventPass In <input type="text">, execCommand("superscript", false, null), a[b]c): input.inputType should be undefinedPass In <input type="text">, execCommand("superscript", false, null), a[b]c): input.target should be undefined-Fail In <input type="text">, execCommand("cut", false, null), ab[]c): The command should be supported+Pass In <input type="text">, execCommand("cut", false, null), ab[]c): The command should be supportedPass In <input type="text">, execCommand("cut", false, null), ab[]c): The command should not be enabled-Fail In <input type="text">, execCommand("cut", false, null), a[b]c): The command should be supported-Fail In <input type="text">, execCommand("cut", false, null), a[b]c): The command should be enabled-Fail In <input type="text">, execCommand("copy", false, null), abc[]d): The command should be supported+Pass In <input type="text">, execCommand("cut", false, null), ab[]c): execCommand() should return false+Pass In <input type="text">, execCommand("cut", false, null), ab[]c): <input>.value should be "ab[]c"+Pass In <input type="text">, execCommand("cut", false, null), ab[]c): should not fire beforeinput event+Pass In <input type="text">, execCommand("cut", false, null), ab[]c): input.inputType should be undefined+Pass In <input type="text">, execCommand("cut", false, null), ab[]c): input.target should be undefined+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): The command should be supported+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): The command should be enabled+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): execCommand() should return true+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): <input>.value should be "a[]c"+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): should not fire beforeinput event+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): input.inputType should be deleteByCut+Pass In <input type="text">, execCommand("cut", false, null), a[b]c): input.target should be [object HTMLInputElement]+Pass In <input type="text">, execCommand("copy", false, null), abc[]d): The command should be supportedPass In <input type="text">, execCommand("copy", false, null), abc[]d): The command should not be enabled-Fail In <input type="text">, execCommand("copy", false, null), a[bc]d): The command should be supported-Fail In <input type="text">, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <input type="text">, execCommand("copy", false, null), abc[]d): execCommand() should return false+Pass In <input type="text">, execCommand("copy", false, null), abc[]d): <input>.value should be "abc[]d"+Pass In <input type="text">, execCommand("copy", false, null), abc[]d): should not fire beforeinput event+Pass In <input type="text">, execCommand("copy", false, null), abc[]d): input.inputType should be undefined+Pass In <input type="text">, execCommand("copy", false, null), abc[]d): input.target should be undefined+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): The command should be supported+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): execCommand() should return true+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): <input>.value should be "a[bc]d"+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): should not fire beforeinput event+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): input.inputType should be undefined+Pass In <input type="text">, execCommand("copy", false, null), a[bc]d): input.target should be undefinedFail In <input type="text">, execCommand("paste", false, null), a[]c): The command should be supportedFail In <input type="text">, execCommand("paste", false, null), a[]c): The command should be enabledPass In <input type="text">, execCommand("delete", false, null), ab[]c): The command should be supported@@ -365,14 +385,34 @@ Pass In <input type="text"> in contenteditable, execCommand("superscript", falsePass In <input type="text"> in contenteditable, execCommand("superscript", false, null), a[b]c): should not fire beforeinput eventPass In <input type="text"> in contenteditable, execCommand("superscript", false, null), a[b]c): input.inputType should be undefinedPass In <input type="text"> in contenteditable, execCommand("superscript", false, null), a[b]c): input.target should be undefined-Fail In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): The command should be supported+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): The command should be supportedPass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): The command should not be enabled-Fail In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be supported-Fail In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be enabled-Fail In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): The command should be supported+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): execCommand() should return false+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): <input>.value should be "ab[]c"+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): should not fire beforeinput event+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): input.inputType should be undefined+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), ab[]c): input.target should be undefined+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be supported+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be enabled+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): execCommand() should return true+Fail In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): <input>.value should be "a[]c"+Pass In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): should not fire beforeinput event+Fail In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): input.inputType should be deleteByCut+Fail In <input type="text"> in contenteditable, execCommand("cut", false, null), a[b]c): input.target should be [object HTMLInputElement]+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): The command should be supportedPass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): The command should not be enabled-Fail In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be supported-Fail In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): execCommand() should return false+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): <input>.value should be "abc[]d"+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): should not fire beforeinput event+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): input.inputType should be undefined+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), abc[]d): input.target should be undefined+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be supported+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): execCommand() should return true+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): <input>.value should be "a[bc]d"+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): should not fire beforeinput event+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): input.inputType should be undefined+Pass In <input type="text"> in contenteditable, execCommand("copy", false, null), a[bc]d): input.target should be undefinedFail In <input type="text"> in contenteditable, execCommand("paste", false, null), a[]c): The command should be supportedFail In <input type="text"> in contenteditable, execCommand("paste", false, null), a[]c): The command should be enabledPass In <input type="text"> in contenteditable, execCommand("delete", false, null), ab[]c): The command should be supporteddiff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=textarea.txt b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=textarea.txtindex f8f061a166a..f837b2767ea 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=textarea.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-with-text-editor.tentative@type=textarea.txt@@ -1,9 +1,9 @@Harness status: OK-Found 648 tests+Found 688 tests-628 Pass-20 Fail+677 Pass+11 FailPass In <textarea>, execCommand("getHTML", false, null), a[b]c): The command should not be supportedPass In <textarea>, execCommand("getHTML", false, null), a[b]c): The command should not be enabledPass In <textarea>, execCommand("bold", false, bold), a[b]c): The command should be supported@@ -41,14 +41,34 @@ Pass In <textarea>, execCommand("superscript", false, null), a[b]c): <textarea>.Pass In <textarea>, execCommand("superscript", false, null), a[b]c): should not fire beforeinput eventPass In <textarea>, execCommand("superscript", false, null), a[b]c): input.inputType should be undefinedPass In <textarea>, execCommand("superscript", false, null), a[b]c): input.target should be undefined-Fail In <textarea>, execCommand("cut", false, null), ab[]c): The command should be supported+Pass In <textarea>, execCommand("cut", false, null), ab[]c): The command should be supportedPass In <textarea>, execCommand("cut", false, null), ab[]c): The command should not be enabled-Fail In <textarea>, execCommand("cut", false, null), a[b]c): The command should be supported-Fail In <textarea>, execCommand("cut", false, null), a[b]c): The command should be enabled-Fail In <textarea>, execCommand("copy", false, null), abc[]d): The command should be supported+Pass In <textarea>, execCommand("cut", false, null), ab[]c): execCommand() should return false+Pass In <textarea>, execCommand("cut", false, null), ab[]c): <textarea>.value should be "ab[]c"+Pass In <textarea>, execCommand("cut", false, null), ab[]c): should not fire beforeinput event+Pass In <textarea>, execCommand("cut", false, null), ab[]c): input.inputType should be undefined+Pass In <textarea>, execCommand("cut", false, null), ab[]c): input.target should be undefined+Pass In <textarea>, execCommand("cut", false, null), a[b]c): The command should be supported+Pass In <textarea>, execCommand("cut", false, null), a[b]c): The command should be enabled+Pass In <textarea>, execCommand("cut", false, null), a[b]c): execCommand() should return true+Pass In <textarea>, execCommand("cut", false, null), a[b]c): <textarea>.value should be "a[]c"+Pass In <textarea>, execCommand("cut", false, null), a[b]c): should not fire beforeinput event+Pass In <textarea>, execCommand("cut", false, null), a[b]c): input.inputType should be deleteByCut+Pass In <textarea>, execCommand("cut", false, null), a[b]c): input.target should be [object HTMLTextAreaElement]+Pass In <textarea>, execCommand("copy", false, null), abc[]d): The command should be supportedPass In <textarea>, execCommand("copy", false, null), abc[]d): The command should not be enabled-Fail In <textarea>, execCommand("copy", false, null), a[bc]d): The command should be supported-Fail In <textarea>, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <textarea>, execCommand("copy", false, null), abc[]d): execCommand() should return false+Pass In <textarea>, execCommand("copy", false, null), abc[]d): <textarea>.value should be "abc[]d"+Pass In <textarea>, execCommand("copy", false, null), abc[]d): should not fire beforeinput event+Pass In <textarea>, execCommand("copy", false, null), abc[]d): input.inputType should be undefined+Pass In <textarea>, execCommand("copy", false, null), abc[]d): input.target should be undefined+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): The command should be supported+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): execCommand() should return true+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): <textarea>.value should be "a[bc]d"+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): should not fire beforeinput event+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): input.inputType should be undefined+Pass In <textarea>, execCommand("copy", false, null), a[bc]d): input.target should be undefinedFail In <textarea>, execCommand("paste", false, null), a[]c): The command should be supportedFail In <textarea>, execCommand("paste", false, null), a[]c): The command should be enabledPass In <textarea>, execCommand("delete", false, null), ab[]c): The command should be supported@@ -367,14 +387,34 @@ Pass In <textarea> in contenteditable, execCommand("superscript", false, null),Pass In <textarea> in contenteditable, execCommand("superscript", false, null), a[b]c): should not fire beforeinput eventPass In <textarea> in contenteditable, execCommand("superscript", false, null), a[b]c): input.inputType should be undefinedPass In <textarea> in contenteditable, execCommand("superscript", false, null), a[b]c): input.target should be undefined-Fail In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): The command should be supported+Pass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): The command should be supportedPass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): The command should not be enabled-Fail In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be supported-Fail In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be enabled-Fail In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): The command should be supported+Pass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): execCommand() should return false+Pass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): <textarea>.value should be "ab[]c"+Pass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): should not fire beforeinput event+Pass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): input.inputType should be undefined+Pass In <textarea> in contenteditable, execCommand("cut", false, null), ab[]c): input.target should be undefined+Pass In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be supported+Pass In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): The command should be enabled+Pass In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): execCommand() should return true+Fail In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): <textarea>.value should be "a[]c"+Pass In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): should not fire beforeinput event+Fail In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): input.inputType should be deleteByCut+Fail In <textarea> in contenteditable, execCommand("cut", false, null), a[b]c): input.target should be [object HTMLTextAreaElement]+Pass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): The command should be supportedPass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): The command should not be enabled-Fail In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be supported-Fail In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): execCommand() should return false+Pass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): <textarea>.value should be "abc[]d"+Pass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): should not fire beforeinput event+Pass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): input.inputType should be undefined+Pass In <textarea> in contenteditable, execCommand("copy", false, null), abc[]d): input.target should be undefined+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be supported+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): The command should be enabled+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): execCommand() should return true+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): <textarea>.value should be "a[bc]d"+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): should not fire beforeinput event+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): input.inputType should be undefined+Pass In <textarea> in contenteditable, execCommand("copy", false, null), a[bc]d): input.target should be undefinedFail In <textarea> in contenteditable, execCommand("paste", false, null), a[]c): The command should be supportedFail In <textarea> in contenteditable, execCommand("paste", false, null), a[]c): The command should be enabledPass In <textarea> in contenteditable, execCommand("delete", false, null), ab[]c): The command should be supporteddiff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-without-editable-element.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-without-editable-element.tentative.txtindex c49c9dc06c7..57f12671b19 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-without-editable-element.tentative.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/other/exec-command-without-editable-element.tentative.txt@@ -1,8 +1,8 @@Harness status: OK-Found 382 tests+Found 422 tests-378 Pass+418 Pass4 FailPass ChildDocument.execCommand(bold, false, bold) with a[b]c: calling execCommandPass ChildDocument.execCommand(bold, false, bold) with a[b]c: checking event on focused document@@ -34,6 +34,26 @@ Pass ChildDocument.execCommand(superscript, false, null) with a[b]c: checking evPass ChildDocument.execCommand(superscript, false, null) with a[b]c: checking event on executed documentPass ChildDocument.execCommand(superscript, false, null) with a[b]c: checking result content in focused documentPass ChildDocument.execCommand(superscript, false, null) with a[b]c: checking result content in executed document+Pass ChildDocument.execCommand(cut, false, null) with ab[]c: calling execCommand+Pass ChildDocument.execCommand(cut, false, null) with ab[]c: checking event on focused document+Pass ChildDocument.execCommand(cut, false, null) with ab[]c: checking event on executed document+Pass ChildDocument.execCommand(cut, false, null) with ab[]c: checking result content in focused document+Pass ChildDocument.execCommand(cut, false, null) with ab[]c: checking result content in executed document+Pass ChildDocument.execCommand(cut, false, null) with a[b]c: calling execCommand+Pass ChildDocument.execCommand(cut, false, null) with a[b]c: checking event on focused document+Pass ChildDocument.execCommand(cut, false, null) with a[b]c: checking event on executed document+Pass ChildDocument.execCommand(cut, false, null) with a[b]c: checking result content in focused document+Pass ChildDocument.execCommand(cut, false, null) with a[b]c: checking result content in executed document+Pass ChildDocument.execCommand(copy, false, null) with ab[]c: calling execCommand+Pass ChildDocument.execCommand(copy, false, null) with ab[]c: checking event on focused document+Pass ChildDocument.execCommand(copy, false, null) with ab[]c: checking event on executed document+Pass ChildDocument.execCommand(copy, false, null) with ab[]c: checking result content in focused document+Pass ChildDocument.execCommand(copy, false, null) with ab[]c: checking result content in executed document+Pass ChildDocument.execCommand(copy, false, null) with a[b]c: calling execCommand+Pass ChildDocument.execCommand(copy, false, null) with a[b]c: checking event on focused document+Pass ChildDocument.execCommand(copy, false, null) with a[b]c: checking event on executed document+Pass ChildDocument.execCommand(copy, false, null) with a[b]c: checking result content in focused document+Pass ChildDocument.execCommand(copy, false, null) with a[b]c: checking result content in executed documentPass ChildDocument.execCommand(delete, false, null) with a[b]c: calling execCommandPass ChildDocument.execCommand(delete, false, null) with a[b]c: checking event on focused documentPass ChildDocument.execCommand(delete, false, null) with a[b]c: checking event on executed document@@ -225,6 +245,26 @@ Pass ParentDocument.execCommand(superscript, false, null) with a[b]c: checking ePass ParentDocument.execCommand(superscript, false, null) with a[b]c: checking event on executed documentPass ParentDocument.execCommand(superscript, false, null) with a[b]c: checking result content in focused documentPass ParentDocument.execCommand(superscript, false, null) with a[b]c: checking result content in executed document+Pass ParentDocument.execCommand(cut, false, null) with ab[]c: calling execCommand+Pass ParentDocument.execCommand(cut, false, null) with ab[]c: checking event on focused document+Pass ParentDocument.execCommand(cut, false, null) with ab[]c: checking event on executed document+Pass ParentDocument.execCommand(cut, false, null) with ab[]c: checking result content in focused document+Pass ParentDocument.execCommand(cut, false, null) with ab[]c: checking result content in executed document+Pass ParentDocument.execCommand(cut, false, null) with a[b]c: calling execCommand+Pass ParentDocument.execCommand(cut, false, null) with a[b]c: checking event on focused document+Pass ParentDocument.execCommand(cut, false, null) with a[b]c: checking event on executed document+Pass ParentDocument.execCommand(cut, false, null) with a[b]c: checking result content in focused document+Pass ParentDocument.execCommand(cut, false, null) with a[b]c: checking result content in executed document+Pass ParentDocument.execCommand(copy, false, null) with ab[]c: calling execCommand+Pass ParentDocument.execCommand(copy, false, null) with ab[]c: checking event on focused document+Pass ParentDocument.execCommand(copy, false, null) with ab[]c: checking event on executed document+Pass ParentDocument.execCommand(copy, false, null) with ab[]c: checking result content in focused document+Pass ParentDocument.execCommand(copy, false, null) with ab[]c: checking result content in executed document+Pass ParentDocument.execCommand(copy, false, null) with a[b]c: calling execCommand+Pass ParentDocument.execCommand(copy, false, null) with a[b]c: checking event on focused document+Pass ParentDocument.execCommand(copy, false, null) with a[b]c: checking event on executed document+Pass ParentDocument.execCommand(copy, false, null) with a[b]c: checking result content in focused document+Pass ParentDocument.execCommand(copy, false, null) with a[b]c: checking result content in executed documentPass ParentDocument.execCommand(delete, false, null) with a[b]c: calling execCommandPass ParentDocument.execCommand(delete, false, null) with a[b]c: checking event on focused documentPass ParentDocument.execCommand(delete, false, null) with a[b]c: checking event on executed documentdiff --git a/Tests/LibWeb/Text/input/Editing/clipboard-cut-beforeinput-target.html b/Tests/LibWeb/Text/input/Editing/clipboard-cut-beforeinput-target.htmlnew file mode 100644index 00000000000..ff1de66b78c--- /dev/null+++ b/Tests/LibWeb/Text/input/Editing/clipboard-cut-beforeinput-target.html@@ -0,0 +1,102 @@+<!doctype html>+<meta charset="utf-8" />+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ const modifiers = internals.MOD_CTRL | internals.MOD_SUPER;+ function check(label, actual, expected) {+ println(+ `${label}: ${JSON.stringify(actual) === JSON.stringify(expected) ? "PASS" : `FAIL ${JSON.stringify(actual)} expected ${JSON.stringify(expected)}`}`+ );+ }+ function control(value = "abcdef") {+ const element = document.body.appendChild(document.createElement("textarea"));+ element.value = value;+ element.focus();+ element.setSelectionRange(1, 3);+ return element;+ }+ function cut(element) {+ internals.sendKey(element, "X", modifiers);+ }+ let target = control();+ const other = control("other");+ target.focus();+ let inputEvents = 0;+ target.oninput = () => ++inputEvents;+ target.onbeforeinput = () => {+ other.focus();+ internals.gc();+ };+ cut(target);+ check("focus change", [target.value, other.value, inputEvents], ["abcdef", "other", 0]);+ target.remove();+ other.remove();+ target = control();+ inputEvents = 0;+ target.oninput = () => ++inputEvents;+ target.onbeforeinput = () => {+ target.remove();+ internals.gc();+ };+ cut(target);+ check("removed control", [target.isConnected, target.value, inputEvents], [false, "abcdef", 0]);+ target = control();+ inputEvents = 0;+ target.oninput = () => ++inputEvents;+ target.onbeforeinput = () => target.setSelectionRange(3, 5);+ cut(target);+ check("same control selection change", [target.value, inputEvents], ["abcf", 1]);+ target.remove();+ const host = document.body.appendChild(document.createElement("div"));+ host.contentEditable = "true";+ host.textContent = "abcdef";+ host.focus();+ getSelection().setBaseAndExtent(host.firstChild, 1, host.firstChild, 3);+ const replacement = document.createElement("div");+ replacement.contentEditable = "true";+ replacement.textContent = "replacement";+ inputEvents = 0;+ replacement.oninput = () => ++inputEvents;+ host.onbeforeinput = () => {+ host.replaceWith(replacement);+ replacement.focus();+ getSelection().setBaseAndExtent(replacement.firstChild, 1, replacement.firstChild, 3);+ internals.gc();+ };+ cut(host);+ check(+ "editing host scope change",+ [host.isConnected, host.textContent, replacement.textContent, inputEvents],+ [false, "abcdef", "replacement", 0]+ );+ replacement.remove();+ const sameHost = document.body.appendChild(document.createElement("div"));+ sameHost.contentEditable = "true";+ sameHost.textContent = "abcdef";+ sameHost.focus();+ getSelection().setBaseAndExtent(sameHost.firstChild, 1, sameHost.firstChild, 3);+ inputEvents = 0;+ sameHost.oninput = () => ++inputEvents;+ sameHost.onbeforeinput = () => getSelection().setBaseAndExtent(sameHost.firstChild, 3, sameHost.firstChild, 5);+ cut(sameHost);+ check("same host selection change", [sameHost.textContent, inputEvents], ["abcf", 1]);+ sameHost.remove();+ const iframe = document.createElement("iframe");+ const loaded = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));+ iframe.srcdoc = "<textarea>abcdef</textarea>";+ document.body.append(iframe);+ await loaded;+ const frameTarget = iframe.contentDocument.querySelector("textarea");+ frameTarget.focus();+ frameTarget.setSelectionRange(1, 3);+ inputEvents = 0;+ frameTarget.oninput = () => ++inputEvents;+ frameTarget.onbeforeinput = () => {+ iframe.remove();+ internals.gc();+ };+ cut(frameTarget);+ check("detached document", [iframe.isConnected, frameTarget.value, inputEvents], [false, "abcdef", 0]);+ });+</script>diff --git a/Tests/LibWeb/Text/input/Editing/clipboard-text-control-actions.html b/Tests/LibWeb/Text/input/Editing/clipboard-text-control-actions.htmlnew file mode 100644index 00000000000..b3fe0c4a087--- /dev/null+++ b/Tests/LibWeb/Text/input/Editing/clipboard-text-control-actions.html@@ -0,0 +1,138 @@+<!doctype html>+<meta charset="utf-8" />+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ const modifiers = internals.MOD_CTRL | internals.MOD_SUPER;+ function check(label, actual, expected) {+ println(+ `${label}: ${JSON.stringify(actual) === JSON.stringify(expected) ? "PASS" : `FAIL ${JSON.stringify(actual)} expected ${JSON.stringify(expected)}`}`+ );+ }+ function control(type, readOnly = false) {+ const element = document.createElement(type === "textarea" ? "textarea" : "input");+ if (type !== "textarea") element.type = type;+ element.value = "abcd";+ element.readOnly = readOnly;+ document.body.append(element);+ element.focus();+ element.setSelectionRange(1, 3);+ return element;+ }+ function activate() {+ internals.dispatchUserActivatedEvent(document.body, new Event("mousedown"));+ }+ async function seed() {+ activate();+ await navigator.clipboard.writeText("seed");+ }+ async function clipboard() {+ activate();+ return navigator.clipboard.readText();+ }+ function events(element) {+ const result = [];+ for (const type of ["copy", "cut", "beforeinput", "input"]) {+ element.addEventListener(type, event =>+ result.push(event.inputType ? `${type}:${event.inputType}` : type)+ );+ }+ return result;+ }+ for (const type of ["text", "textarea"]) {+ const element = control(type, true);+ const recorded = events(element);+ await seed();+ const result = document.execCommand("cut");+ check(+ `${type} readonly script cut`,+ [result, element.value, await clipboard(), recorded],+ [true, "abcd", "seed", ["cut"]]+ );+ recorded.length = 0;+ internals.sendKey(element, "X", modifiers);+ check(`${type} readonly user cut`, [element.value, await clipboard(), recorded], ["abcd", "seed", ["cut"]]);+ element.remove();+ }+ const password = control("password");+ const recorded = events(password);+ await seed();+ check(+ "password commands disabled",+ [document.queryCommandEnabled("copy"), document.queryCommandEnabled("cut")],+ [false, false]+ );+ const copied = document.execCommand("copy");+ check(+ "selected password copy",+ [copied, password.value, await clipboard(), recorded],+ [true, "abcd", "seed", []]+ );+ const cut = document.execCommand("cut");+ check(+ "selected password cut",+ [cut, password.value, password.selectionStart, password.selectionEnd, await clipboard(), recorded],+ [true, "abcd", 1, 3, "seed", []]+ );+ recorded.length = 0;+ internals.sendKey(password, "X", modifiers);+ check(+ "native password cut unchanged",+ [password.value, password.selectionStart, password.selectionEnd, await clipboard(), recorded],+ ["abcd", 1, 3, "seed", ["cut"]]+ );+ password.remove();+ for (const type of ["text", "textarea"]) {+ const element = control(type, true);+ const recorded = events(element);+ element.addEventListener("cut", event => {+ event.clipboardData.setData("text/plain", "custom");+ event.preventDefault();+ });+ await seed();+ const result = document.execCommand("cut");+ check(+ `${type} readonly canceled cut`,+ [result, element.value, await clipboard(), recorded],+ [true, "abcd", "custom", ["cut"]]+ );+ element.remove();+ }+ for (const readOnly of [false, true]) {+ const element = control("text", readOnly);+ const recorded = events(element);+ element.addEventListener("cut", () => {+ element.readOnly = !readOnly;+ });+ await seed();+ const result = document.execCommand("cut");+ check(+ `cut listener ${readOnly ? "enables" : "disables"} editing`,+ [result, element.value, await clipboard(), recorded],+ readOnly ? [true, "ad", "bc", ["cut", "input:deleteByCut"]] : [true, "abcd", "seed", ["cut"]]+ );+ element.remove();+ }+ const iframe = document.createElement("iframe");+ const loaded = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));+ iframe.srcdoc = '<input type="password" value="abcd">';+ document.body.append(iframe);+ await loaded;+ const frameDocument = iframe.contentDocument;+ const framePassword = frameDocument.querySelector("input");+ framePassword.focus();+ framePassword.setSelectionRange(1, 3);+ const frameEvents = events(framePassword);+ check(+ "fresh password document has no activation",+ iframe.contentWindow.navigator.userActivation.isActive,+ false+ );+ check(+ "password without activation unchanged",+ [frameDocument.execCommand("copy"), frameDocument.execCommand("cut"), framePassword.value, frameEvents],+ [false, false, "abcd", ["copy", "cut"]]+ );+ iframe.remove();+ });+</script>diff --git a/Tests/LibWeb/Text/input/Editing/execcommand-cut-contenteditable-recursion.html b/Tests/LibWeb/Text/input/Editing/execcommand-cut-contenteditable-recursion.htmlnew file mode 100644index 00000000000..6a9a6ef2fb2--- /dev/null+++ b/Tests/LibWeb/Text/input/Editing/execcommand-cut-contenteditable-recursion.html@@ -0,0 +1,137 @@+<!doctype html>+<meta charset="utf-8" />+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ function check(label, actual, expected) {+ println(+ `${label}: ${JSON.stringify(actual) === JSON.stringify(expected) ? "PASS" : `FAIL ${JSON.stringify(actual)} expected ${JSON.stringify(expected)}`}`+ );+ }+ function activate() {+ internals.dispatchUserActivatedEvent(document.body, new Event("mousedown"));+ }+ async function seed() {+ activate();+ await navigator.clipboard.writeText("seed");+ }+ async function clipboard() {+ activate();+ return navigator.clipboard.readText();+ }+ function makeEditor() {+ const editor = document.body.appendChild(document.createElement("div"));+ editor.contentEditable = "true";+ editor.innerHTML = "a<b>bc</b>d";+ editor.focus();+ const text = editor.querySelector("b").firstChild;+ getSelection().setBaseAndExtent(text, 0, text, 2);+ return editor;+ }+ function nestedCommands() {+ return [+ document.execCommand("copy"),+ document.execCommand("cut"),+ document.execCommand("insertText", false, "nested"),+ ];+ }+ let editor = makeEditor();+ let recorded = [];+ editor.oncut = () => recorded.push("cut");+ editor.onbeforeinput = event => recorded.push(`beforeinput:${event.inputType}`);+ editor.oninput = event => recorded.push(`input:${event.inputType}`);+ await seed();+ const cut = document.execCommand("cut");+ check(+ "rich script cut deletes and copies",+ [cut, editor.textContent, getSelection().isCollapsed, await clipboard()],+ [true, "ad", true, "bc"]+ );+ check("rich script cut event order", recorded, ["cut", "input:deleteByCut"]);+ editor.oncut = editor.onbeforeinput = editor.oninput = null;+ check("rich cut undo", [document.execCommand("undo"), editor.textContent], [true, "abcd"]);+ check("rich cut redo", [document.execCommand("redo"), editor.textContent], [true, "ad"]);+ editor.remove();+ editor = makeEditor();+ let cutNested = [];+ let inputNested = [];+ recorded = [];+ editor.oncut = () => {+ recorded.push("cut");+ cutNested = nestedCommands();+ };+ editor.oncopy = () => recorded.push("copy");+ editor.oninput = () => {+ recorded.push("input");+ inputNested = nestedCommands();+ };+ await seed();+ const guardedCut = document.execCommand("cut");+ check("cut callback recursive commands blocked", cutNested, [false, false, false]);+ check("rich input callback recursive commands blocked", inputNested, [false, false, false]);+ check(+ "guarded rich cut completes",+ [guardedCut, editor.textContent, await clipboard(), recorded],+ [true, "ad", "bc", ["cut", "input"]]+ );+ editor.remove();+ const control = document.body.appendChild(document.createElement("textarea"));+ control.value = "abcd";+ control.focus();+ control.setSelectionRange(1, 3);+ let controlNested = [];+ recorded = [];+ control.oncut = () => recorded.push("cut");+ control.oncopy = () => recorded.push("copy");+ control.oninput = () => {+ recorded.push("input");+ controlNested = nestedCommands();+ };+ await seed();+ const controlCut = document.execCommand("cut");+ check("text control input recursion remains blocked", controlNested, [false, false, false]);+ check(+ "guarded text control cut completes",+ [controlCut, control.value, await clipboard(), recorded],+ [true, "ad", "bc", ["cut", "input"]]+ );+ control.remove();+ editor = makeEditor();+ let canceledNested = [];+ recorded = [];+ editor.oncut = event => {+ recorded.push("cut");+ canceledNested = nestedCommands();+ event.clipboardData.setData("text/plain", "custom");+ event.preventDefault();+ };+ editor.oninput = () => recorded.push("input");+ await seed();+ const canceledCut = document.execCommand("cut");+ check("canceled cut recursion remains blocked", canceledNested, [false, false, false]);+ check(+ "canceled cut writes custom data only",+ [canceledCut, editor.textContent, await clipboard(), recorded],+ [true, "abcd", "custom", ["cut"]]+ );+ editor.remove();+ editor = makeEditor();+ let copyNested = [];+ recorded = [];+ editor.oncopy = () => {+ recorded.push("copy");+ copyNested = nestedCommands();+ };+ editor.oncut = () => recorded.push("cut");+ editor.oninput = () => recorded.push("input");+ await seed();+ const copied = document.execCommand("copy");+ check("copy callback recursive commands blocked", copyNested, [false, false, false]);+ check(+ "guarded copy leaves content intact",+ [copied, editor.textContent, await clipboard(), recorded],+ [true, "abcd", "bc", ["copy"]]+ );+ editor.remove();+ });+</script>