mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
LibJS: Implement console.assert()
This commit is contained in:
parent
e37421bddc
commit
8d490aba76
Notes:
sideshowbarker
2024-07-18 19:26:17 +09:00
Author: https://github.com/linusg
Commit: 8d490aba76
Pull-request: https://github.com/SerenityOS/serenity/pull/6454
Reviewed-by: https://github.com/alimpfard
12 changed files with 89 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue