mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-13 22:52:52 +00: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:
parent
de46a2cff1
commit
5d0f666f22
Notes:
sideshowbarker
2024-07-18 00:53:21 +09:00
Author: https://github.com/davidot
Commit: 5d0f666f22
Pull-request: https://github.com/SerenityOS/serenity/pull/10926
Reviewed-by: https://github.com/linusg ✅
3 changed files with 13 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue