1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibJS: Begin implementing console.dir

The intent of the spec is that the output of console.dir is interactable
within the console. Our Printer implementation currently just prints the
provided object as a string, and doesn't check the provided `options`
argument. But having console.dir defined prevents exceptions from being
thrown on real websites.
This commit is contained in:
Timothy Flynn 2023-06-21 21:29:24 -04:00 committed by Andreas Kling
parent 9f8e5f0b1c
commit 396655d145
Notes: sideshowbarker 2024-07-17 08:59:18 +09:00
5 changed files with 31 additions and 0 deletions

View file

@ -31,6 +31,7 @@ ThrowCompletionOr<void> ConsoleObject::initialize(Realm& realm)
define_native_function(realm, vm.names.log, log, 0, attr);
define_native_function(realm, vm.names.trace, trace, 0, attr);
define_native_function(realm, vm.names.warn, warn, 0, attr);
define_native_function(realm, vm.names.dir, dir, 0, attr);
define_native_function(realm, vm.names.count, count, 0, attr);
define_native_function(realm, vm.names.countReset, count_reset, 0, attr);
define_native_function(realm, vm.names.group, group, 0, attr);
@ -99,6 +100,13 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::warn)
return console_object.console().warn();
}
// 1.1.10. dir(item, options), https://console.spec.whatwg.org/#warn
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::dir)
{
auto& console_object = *vm.current_realm()->intrinsics().console_object();
return console_object.console().dir();
}
// 1.2.1. count(label), https://console.spec.whatwg.org/#count
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::count)
{