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

LibJS: Implement console.assert()

This commit is contained in:
Linus Groh 2021-04-18 17:08:14 +02:00
parent e37421bddc
commit 8d490aba76
12 changed files with 89 additions and 9 deletions

View file

@ -168,4 +168,25 @@ JS::Value WebContentConsoleClient::count_reset()
return JS::js_undefined();
}
JS::Value WebContentConsoleClient::assert_()
{
auto& vm = this->vm();
if (!vm.argument(0).to_boolean()) {
StringBuilder html;
if (vm.argument_count() > 1) {
html.append("<span class=\"error\">");
html.append("Assertion failed:");
html.append("</span>");
html.append(" ");
html.append(escape_html_entities(vm.join_arguments(1)));
} else {
html.append("<span class=\"error\">");
html.append("Assertion failed");
html.append("</span>");
}
print_html(html.string_view());
}
return JS::js_undefined();
}
}