Truly independent web browser
LibJS: Skip the %c styling of a Symbol in console format strings
Shannon Boothba647ee0e654
diff --git a/Libraries/LibJS/Rust/src/console.rs b/Libraries/LibJS/Rust/src/console.rsindex 3de1437c48c..46c245b4553 100644--- a/Libraries/LibJS/Rust/src/console.rs+++ b/Libraries/LibJS/Rust/src/console.rs@@ -1195,8 +1195,11 @@ impl ConsoleClient {// 6. TODO: process %celse {// NOTE: This has no spec yet. `%c` specifiers treat the argument as CSS styling for the log message.- let css_style = current.to_utf16_string(vm)?;- self.add_css_style_to_current_message(Utf16View::of_string(&css_style));+ // NB: A Symbol has no string conversion, so it adds no styling, as in other engines.+ if !current.is_symbol() {+ let css_style = current.to_utf16_string(vm)?;+ self.add_css_style_to_current_message(Utf16View::of_string(&css_style));+ }converted = Some(Value::from_string(PrimitiveString::create(vm, Utf16String::default())));}diff --git a/Tests/LibWeb/Text/expected/console/console-log-c-specifier-symbol.txt b/Tests/LibWeb/Text/expected/console/console-log-c-specifier-symbol.txtnew file mode 100644index 00000000000..7ef22e9a431--- /dev/null+++ b/Tests/LibWeb/Text/expected/console/console-log-c-specifier-symbol.txt@@ -0,0 +1 @@+PASSdiff --git a/Tests/LibWeb/Text/input/console/console-log-c-specifier-symbol.html b/Tests/LibWeb/Text/input/console/console-log-c-specifier-symbol.htmlnew file mode 100644index 00000000000..a804d431811--- /dev/null+++ b/Tests/LibWeb/Text/input/console/console-log-c-specifier-symbol.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<script>+ test(() => {+ console.log("%c", Symbol());+ println("PASS");+ });+</script>