From 98d8a858cddb3b7c5f37a0044b5df4654374cfa6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 21 Aug 2021 17:15:08 -0400 Subject: [PATCH] LibJS: Set the function names for the resolve, reject, and executor These should all have a name with an empty string. Not only does test262 verify this, but it also verifies that (for the executor) the name property is defined after the length property. --- Userland/Libraries/LibJS/Runtime/Promise.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp index bc512462866..126acfb3f06 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.cpp +++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp @@ -94,7 +94,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions() vm.enqueue_promise_job(*job); return js_undefined(); }); - resolve_function->define_direct_property(vm.names.name, js_string(vm, vm.names.resolve.as_string()), Attribute::Configurable); + resolve_function->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); // 27.2.1.3.1 Promise Reject Functions, https://tc39.es/ecma262/#sec-promise-reject-functions auto* reject_function = PromiseResolvingFunction::create(global_object(), *this, *already_resolved, [](auto& vm, auto&, auto& promise, auto& already_resolved) { @@ -105,7 +105,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions() auto reason = vm.argument(0); return promise.reject(reason); }); - reject_function->define_direct_property(vm.names.name, js_string(vm, vm.names.reject.as_string()), Attribute::Configurable); + reject_function->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); return { *resolve_function, *reject_function }; } diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp index ecc7a5e7cb1..ac5729011de 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp @@ -43,6 +43,7 @@ PromiseCapability new_promise_capability(GlobalObject& global_object, Value cons return js_undefined(); }); executor->define_direct_property(vm.names.length, Value(2), Attribute::Configurable); + executor->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); MarkedValueList arguments(vm.heap()); arguments.append(executor);