mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 12:46:06 +00:00
LibJS: Implement console.dirxml
This function actually gets tested in WPT.
This commit is contained in:
parent
ad06ac0d58
commit
08284e0ef6
Notes:
github-actions[bot]
2025-08-17 11:29:56 +00:00
Author: https://github.com/tete17
Commit: 08284e0ef6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5861
Reviewed-by: https://github.com/trflynn89
5 changed files with 40 additions and 1 deletions
|
@ -398,6 +398,34 @@ ThrowCompletionOr<Value> Console::dir()
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1.1.11 dirxml(...data) https://console.spec.whatwg.org/#dirxml
|
||||||
|
ThrowCompletionOr<Value> Console::dirxml()
|
||||||
|
{
|
||||||
|
auto& vm = realm().vm();
|
||||||
|
|
||||||
|
// 1. Let finalList be a new list, initially empty.
|
||||||
|
GC::RootVector<Value> final_list(vm.heap());
|
||||||
|
|
||||||
|
// 2. For each item of data:
|
||||||
|
for (size_t i = 0; i < vm.argument_count(); ++i) {
|
||||||
|
auto item = vm.argument(i);
|
||||||
|
|
||||||
|
// 1. Let converted be a DOM tree representation of item if possible; otherwise let converted be item with
|
||||||
|
// optimally useful formatting applied.
|
||||||
|
// FIXME: "Optimally-useful formatting"
|
||||||
|
|
||||||
|
// 2. Append converted to finalList.
|
||||||
|
final_list.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Perform Logger("dirxml", finalList).
|
||||||
|
if (m_client) {
|
||||||
|
return m_client->logger(LogLevel::DirXML, final_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
return js_undefined();
|
||||||
|
}
|
||||||
|
|
||||||
static ThrowCompletionOr<String> label_or_fallback(VM& vm, StringView fallback)
|
static ThrowCompletionOr<String> label_or_fallback(VM& vm, StringView fallback)
|
||||||
{
|
{
|
||||||
return vm.argument_count() > 0 && !vm.argument(0).is_undefined()
|
return vm.argument_count() > 0 && !vm.argument(0).is_undefined()
|
||||||
|
@ -850,7 +878,7 @@ ThrowCompletionOr<GC::RootVector<Value>> ConsoleClient::formatter(GC::RootVector
|
||||||
}
|
}
|
||||||
// 4. If specifier is %o, optionally let converted be current with optimally useful formatting applied.
|
// 4. If specifier is %o, optionally let converted be current with optimally useful formatting applied.
|
||||||
else if (specifier == "%o"sv) {
|
else if (specifier == "%o"sv) {
|
||||||
// TODO: "Optimally-useful formatting"
|
// FIXME: "Optimally-useful formatting"
|
||||||
converted = current;
|
converted = current;
|
||||||
}
|
}
|
||||||
// 5. If specifier is %O, optionally let converted be current with generic JavaScript object formatting applied.
|
// 5. If specifier is %O, optionally let converted be current with generic JavaScript object formatting applied.
|
||||||
|
|
|
@ -79,6 +79,7 @@ public:
|
||||||
ThrowCompletionOr<Value> trace();
|
ThrowCompletionOr<Value> trace();
|
||||||
ThrowCompletionOr<Value> warn();
|
ThrowCompletionOr<Value> warn();
|
||||||
ThrowCompletionOr<Value> dir();
|
ThrowCompletionOr<Value> dir();
|
||||||
|
ThrowCompletionOr<Value> dirxml();
|
||||||
ThrowCompletionOr<Value> count();
|
ThrowCompletionOr<Value> count();
|
||||||
ThrowCompletionOr<Value> count_reset();
|
ThrowCompletionOr<Value> count_reset();
|
||||||
ThrowCompletionOr<Value> group();
|
ThrowCompletionOr<Value> group();
|
||||||
|
|
|
@ -124,6 +124,7 @@ namespace JS {
|
||||||
P(difference) \
|
P(difference) \
|
||||||
P(dir) \
|
P(dir) \
|
||||||
P(direction) \
|
P(direction) \
|
||||||
|
P(dirxml) \
|
||||||
P(disabledFeatures) \
|
P(disabledFeatures) \
|
||||||
P(disambiguation) \
|
P(disambiguation) \
|
||||||
P(disposeAsync) \
|
P(disposeAsync) \
|
||||||
|
|
|
@ -49,6 +49,7 @@ void ConsoleObject::initialize(Realm& realm)
|
||||||
define_native_function(realm, vm.names.trace, trace, 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.warn, warn, 0, attr);
|
||||||
define_native_function(realm, vm.names.dir, dir, 0, attr);
|
define_native_function(realm, vm.names.dir, dir, 0, attr);
|
||||||
|
define_native_function(realm, vm.names.dirxml, dir, 0, attr);
|
||||||
define_native_function(realm, vm.names.count, count, 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.countReset, count_reset, 0, attr);
|
||||||
define_native_function(realm, vm.names.group, group, 0, attr);
|
define_native_function(realm, vm.names.group, group, 0, attr);
|
||||||
|
@ -131,6 +132,13 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::dir)
|
||||||
return console_object.console().dir();
|
return console_object.console().dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1.1.11 dirxml(...data) https://console.spec.whatwg.org/#dirxml
|
||||||
|
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::dirxml)
|
||||||
|
{
|
||||||
|
auto& console_object = *vm.current_realm()->intrinsics().console_object();
|
||||||
|
return console_object.console().dirxml();
|
||||||
|
}
|
||||||
|
|
||||||
// 1.2.1. count(label), https://console.spec.whatwg.org/#count
|
// 1.2.1. count(label), https://console.spec.whatwg.org/#count
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::count)
|
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(warn);
|
JS_DECLARE_NATIVE_FUNCTION(warn);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(table);
|
JS_DECLARE_NATIVE_FUNCTION(table);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(dir);
|
JS_DECLARE_NATIVE_FUNCTION(dir);
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(dirxml);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(count);
|
JS_DECLARE_NATIVE_FUNCTION(count);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(count_reset);
|
JS_DECLARE_NATIVE_FUNCTION(count_reset);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(group);
|
JS_DECLARE_NATIVE_FUNCTION(group);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue