1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibJS+WebContent+js: Bring console.count[Reset]() to spec

The `CountReset` log level is displayed as a warning, since the message
is always to warn that the counter doesn't exist. This is also in line
with the table at https://console.spec.whatwg.org/#loglevel-severity
This commit is contained in:
Sam Atkins 2021-12-08 19:12:06 +00:00 committed by Andreas Kling
parent 260836135a
commit 834ced82d4
5 changed files with 50 additions and 73 deletions

View file

@ -135,25 +135,6 @@ JS::Value WebContentConsoleClient::trace()
return JS::js_undefined();
}
JS::Value WebContentConsoleClient::count()
{
auto label = vm().argument_count() ? vm().argument(0).to_string_without_side_effects() : "default";
auto counter_value = m_console.counter_increment(label);
print_html(String::formatted("{}: {}", label, counter_value));
return JS::js_undefined();
}
JS::Value WebContentConsoleClient::count_reset()
{
auto label = vm().argument_count() ? vm().argument(0).to_string_without_side_effects() : "default";
if (m_console.counter_reset(label)) {
print_html(String::formatted("{}: 0", label));
} else {
print_html(String::formatted("\"{}\" doesn't have a count", label));
}
return JS::js_undefined();
}
JS::Value WebContentConsoleClient::assert_()
{
auto& vm = this->vm();
@ -196,6 +177,7 @@ JS::ThrowCompletionOr<JS::Value> WebContentConsoleClient::printer(JS::Console::L
html.append("<span class=\"log\"> ");
break;
case JS::Console::LogLevel::Warn:
case JS::Console::LogLevel::CountReset:
html.append("<span class=\"warn\">(w) ");
break;
default: