mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibJS: Don't set a prototype property on async functions
This is now as defined in the spec. However since we execute async functions in bytecode by transforming it to a generator function it must have a prototype for the GeneratorObject. We check whether it is an async function and in that case use the hardcoded generator object prototype. This also ensures that user code cannot override this property thus preventing exposing internal implementation details.
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 00:53:21 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/5d0f666f22d Pull-request: https://github.com/SerenityOS/serenity/pull/10926 Reviewed-by: https://github.com/linusg ✅
@@ -101,10 +101,11 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
|
||||
MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true }));
|
||||
break;
|
||||
case FunctionKind::Generator:
|
||||
case FunctionKind::Async:
|
||||
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
prototype = global_object.generator_object_prototype();
|
||||
break;
|
||||
case FunctionKind::Async:
|
||||
break;
|
||||
}
|
||||
define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user