mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibJS: Remove the name prefix for wrapped functions
This is a normative change in the ShadowRealm spec.
See: 4ca634a
This commit is contained in:
parent
16aeb8b51d
commit
c08a52dd97
4 changed files with 8 additions and 8 deletions
|
@ -32,8 +32,8 @@ void ShadowRealm::visit_edges(Visitor& visitor)
|
|||
visitor.visit(&m_shadow_realm);
|
||||
}
|
||||
|
||||
// 3.1.2 CopyNameAndLength ( F: a function object, Target: a function object, prefix: a String, optional argCount: a Number, ), https://tc39.es/proposal-shadowrealm/#sec-copynameandlength
|
||||
ThrowCompletionOr<void> copy_name_and_length(GlobalObject& global_object, FunctionObject& function, FunctionObject& target, StringView prefix, Optional<unsigned> arg_count)
|
||||
// 3.1.2 CopyNameAndLength ( F: a function object, Target: a function object, optional prefix: a String, optional argCount: a Number, ), https://tc39.es/proposal-shadowrealm/#sec-copynameandlength
|
||||
ThrowCompletionOr<void> copy_name_and_length(GlobalObject& global_object, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix, Optional<unsigned> arg_count)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
|
@ -87,7 +87,7 @@ ThrowCompletionOr<void> copy_name_and_length(GlobalObject& global_object, Functi
|
|||
target_name = js_string(vm, String::empty());
|
||||
|
||||
// 8. Perform ! SetFunctionName(F, targetName, prefix).
|
||||
function.set_function_name({ target_name.as_string().string() }, prefix);
|
||||
function.set_function_name({ target_name.as_string().string() }, move(prefix));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ private:
|
|||
ExecutionContext m_execution_context; // [[ExecutionContext]]
|
||||
};
|
||||
|
||||
ThrowCompletionOr<void> copy_name_and_length(GlobalObject&, FunctionObject& function, FunctionObject& target, StringView prefix, Optional<unsigned> arg_count = {});
|
||||
ThrowCompletionOr<void> copy_name_and_length(GlobalObject&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
|
||||
ThrowCompletionOr<Value> perform_shadow_realm_eval(GlobalObject&, StringView source_text, Realm& caller_realm, Realm& eval_realm);
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(GlobalObject&, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
|
||||
ThrowCompletionOr<Value> get_wrapped_value(GlobalObject&, Realm& caller_realm, Value);
|
||||
|
|
|
@ -24,8 +24,8 @@ ThrowCompletionOr<WrappedFunction*> WrappedFunction::create(GlobalObject& global
|
|||
auto& prototype = *caller_realm.global_object().function_prototype();
|
||||
auto* wrapped = global_object.heap().allocate<WrappedFunction>(global_object, caller_realm, target, prototype);
|
||||
|
||||
// 7. Let result be CopyNameAndLength(wrapped, Target, "wrapped").
|
||||
auto result = copy_name_and_length(global_object, *wrapped, target, "wrapped"sv);
|
||||
// 7. Let result be CopyNameAndLength(wrapped, Target).
|
||||
auto result = copy_name_and_length(global_object, *wrapped, target);
|
||||
|
||||
// 8. If result is an Abrupt Completion, throw a TypeError exception.
|
||||
if (result.is_throw_completion())
|
||||
|
|
|
@ -46,8 +46,8 @@ describe("normal behavior", () => {
|
|||
expect(typeof wrappedFunction).toBe("function");
|
||||
expect(Object.getPrototypeOf(wrappedFunction)).toBe(Function.prototype);
|
||||
|
||||
expect(shadowRealm.evaluate("(function () {})").name).toBe("wrapped ");
|
||||
expect(shadowRealm.evaluate("(function foo() {})").name).toBe("wrapped foo");
|
||||
expect(shadowRealm.evaluate("(function () {})").name).toBe("");
|
||||
expect(shadowRealm.evaluate("(function foo() {})").name).toBe("foo");
|
||||
expect(shadowRealm.evaluate("(function () {})")).toHaveLength(0);
|
||||
expect(shadowRealm.evaluate("(function (foo, bar) {})")).toHaveLength(2);
|
||||
expect(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue