From 6f39652b25908a4815126aeb875094e0898e8107 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Tue, 16 Jun 2026 10:35:32 +0200 Subject: [PATCH] LibWeb/Editing: Correct checking the command's specified value We were always checking whether the `createLink` command had a non-empty value, which was a misinterpretation of the spec text. WPT's reference implementation of this algorithm explicitly checks whether a value definition was set for a command, so we do the same. --- Libraries/LibWeb/Editing/Internal/Algorithms.cpp | 2 +- .../expected/wpt-import/editing/run/backcolor.txt | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp index afecb55c55..fbe913585f 100644 --- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp +++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp @@ -3720,7 +3720,7 @@ void set_the_selections_value(DOM::Document& document, FlyString const& command, } // 5. Otherwise, if command is "createLink" or it has a value specified, set the value override to new value. - else if (command == CommandNames::createLink || !MUST(document.query_command_value(CommandNames::createLink)).is_empty()) { + else if (command == CommandNames::createLink || command_definition->value) { document.set_command_value_override(command, *new_value); } diff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/run/backcolor.txt b/Tests/LibWeb/Text/expected/wpt-import/editing/run/backcolor.txt index 47f4669e91..d7f2344cdc 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/editing/run/backcolor.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/editing/run/backcolor.txt @@ -2,8 +2,8 @@ Harness status: OK Found 1026 tests -1017 Pass -9 Fail +1022 Pass +4 Fail Pass [["backcolor","#00FFFF"]] "foo[]bar": execCommand("backcolor", false, "#00FFFF") return value Pass [["backcolor","#00FFFF"]] "foo[]bar" checks for modifications to non-editable content Pass [["backcolor","#00FFFF"]] "foo[]bar" compare innerHTML @@ -12,7 +12,7 @@ Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") before Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") before Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandIndeterm("backcolor") after Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") after -Fail [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after +Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after Pass [["stylewithcss","true"],["backcolor","#00FFFF"]] "

[foo

bar]

": execCommand("stylewithcss", false, "true") return value Pass [["stylewithcss","true"],["backcolor","#00FFFF"]] "

[foo

bar]

": execCommand("backcolor", false, "#00FFFF") return value Pass [["stylewithcss","true"],["backcolor","#00FFFF"]] "

[foo

bar]

" checks for modifications to non-editable content @@ -149,7 +149,7 @@ Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") before Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandIndeterm("backcolor") after Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") after -Fail [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after +Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after Pass [["backcolor","#00FFFF"]] "foo[]bar": execCommand("backcolor", false, "#00FFFF") return value Pass [["backcolor","#00FFFF"]] "foo[]bar" checks for modifications to non-editable content Pass [["backcolor","#00FFFF"]] "foo[]bar" compare innerHTML @@ -158,7 +158,7 @@ Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") before Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandIndeterm("backcolor") after Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") after -Fail [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after +Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after Pass [["backcolor","#00FFFF"]] "foo{}bar": execCommand("backcolor", false, "#00FFFF") return value Pass [["backcolor","#00FFFF"]] "foo{}bar" checks for modifications to non-editable content Pass [["backcolor","#00FFFF"]] "foo{}bar" compare innerHTML @@ -167,7 +167,7 @@ Pass [["backcolor","#00FFFF"]] "foo{}bar" queryCommand Pass [["backcolor","#00FFFF"]] "foo{}bar" queryCommandValue("backcolor") before Pass [["backcolor","#00FFFF"]] "foo{}bar" queryCommandIndeterm("backcolor") after Pass [["backcolor","#00FFFF"]] "foo{}bar" queryCommandState("backcolor") after -Fail [["backcolor","#00FFFF"]] "foo{}bar" queryCommandValue("backcolor") after +Pass [["backcolor","#00FFFF"]] "foo{}bar" queryCommandValue("backcolor") after Pass [["backcolor","#00FFFF"]] "foo[]bar": execCommand("backcolor", false, "#00FFFF") return value Pass [["backcolor","#00FFFF"]] "foo[]bar" checks for modifications to non-editable content Pass [["backcolor","#00FFFF"]] "foo[]bar" compare innerHTML @@ -176,7 +176,7 @@ Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommand Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") before Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandIndeterm("backcolor") after Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandState("backcolor") after -Fail [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after +Pass [["backcolor","#00FFFF"]] "foo[]bar" queryCommandValue("backcolor") after Pass [["stylewithcss","true"],["backcolor","#00FFFF"]] "foo[bar]baz": execCommand("stylewithcss", false, "true") return value Pass [["stylewithcss","true"],["backcolor","#00FFFF"]] "foo[bar]baz": execCommand("backcolor", false, "#00FFFF") return value Pass [["stylewithcss","true"],["backcolor","#00FFFF"]] "foo[bar]baz" checks for modifications to non-editable content