diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp
index 20b2dd46cb..58e550c24c 100644
--- a/Libraries/LibWeb/Editing/Commands.cpp
+++ b/Libraries/LibWeb/Editing/Commands.cpp
@@ -35,9 +35,10 @@ bool command_back_color_action(DOM::Document& document, String const& value)
resulting_value = MUST(String::formatted("#{}", resulting_value));
// 2. If value is still not a valid CSS color, or if it is currentColor, return false.
+ // AD-HOC: No browser does this. They always return true.
if (!Color::from_string(resulting_value).has_value()) {
- // FIXME: Also return false in case of currentColor.
- return false;
+ // FIXME: Also return true in case of currentColor.
+ return true;
}
}
@@ -602,9 +603,10 @@ bool command_fore_color_action(DOM::Document& document, String const& value)
resulting_value = MUST(String::formatted("#{}", resulting_value));
// 2. If value is still not a valid CSS color, or if it is currentColor, return false.
+ // AD-HOC: No browser does this. They always return true.
if (!Color::from_string(resulting_value).has_value()) {
- // FIXME: Also return false in case of currentColor.
- return false;
+ // FIXME: Also return true in case of currentColor.
+ return true;
}
}
diff --git a/Tests/LibWeb/Text/expected/Editing/execCommand-backColor.txt b/Tests/LibWeb/Text/expected/Editing/execCommand-backColor.txt
index 738319e55c..fd51346af7 100644
--- a/Tests/LibWeb/Text/expected/Editing/execCommand-backColor.txt
+++ b/Tests/LibWeb/Text/expected/Editing/execCommand-backColor.txt
@@ -1,2 +1,3 @@
Div contents: "foobar"
Div contents: "foobar"
+Invalid color result: true
diff --git a/Tests/LibWeb/Text/input/Editing/execCommand-backColor.html b/Tests/LibWeb/Text/input/Editing/execCommand-backColor.html
index 7ec26de2ec..d485ec35c9 100644
--- a/Tests/LibWeb/Text/input/Editing/execCommand-backColor.html
+++ b/Tests/LibWeb/Text/input/Editing/execCommand-backColor.html
@@ -18,5 +18,8 @@
range.setEnd(divElm.childNodes[1], 3);
document.execCommand('hiliteColor', false, 'red');
println(`Div contents: "${divElm.innerHTML}"`);
+
+ // Invalid color
+ println(`Invalid color result: ${document.execCommand('backColor', false, '%*&')}`);
});