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

LibJS: Implement console.time/timeLog/timeEnd() methods

This commit is contained in:
Sam Atkins 2021-12-22 16:40:57 +00:00 committed by Andreas Kling
parent 2f3e24d71e
commit 1fba221b46
5 changed files with 152 additions and 1 deletions

View file

@ -35,6 +35,9 @@ void ConsoleObject::initialize(GlobalObject& global_object)
define_native_function(vm.names.group, group, 0, attr);
define_native_function(vm.names.groupCollapsed, group_collapsed, 0, attr);
define_native_function(vm.names.groupEnd, group_end, 0, attr);
define_native_function(vm.names.time, time, 0, attr);
define_native_function(vm.names.timeLog, time_log, 0, attr);
define_native_function(vm.names.timeEnd, time_end, 0, attr);
}
ConsoleObject::~ConsoleObject()
@ -119,4 +122,22 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::group_end)
return global_object.console().group_end();
}
// 1.4.1. time(label), https://console.spec.whatwg.org/#time
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::time)
{
return global_object.console().time();
}
// 1.4.2. timeLog(label, ...data), https://console.spec.whatwg.org/#timelog
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::time_log)
{
return global_object.console().time_log();
}
// 1.4.3. timeEnd(label), https://console.spec.whatwg.org/#timeend
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::time_end)
{
return global_object.console().time_end();
}
}