mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibJS: Don't coerce this value to object in Promise.resolve()
This commit is contained in:
parent
cd391aa8ef
commit
53ec432e8d
Notes:
sideshowbarker
2024-07-18 01:09:52 +09:00
Author: https://github.com/linusg
Commit: 53ec432e8d
Pull-request: https://github.com/SerenityOS/serenity/pull/10913
Reviewed-by: https://github.com/IdanHo ✅
2 changed files with 13 additions and 3 deletions
|
@ -519,12 +519,14 @@ JS_DEFINE_NATIVE_FUNCTION(PromiseConstructor::resolve)
|
|||
auto value = vm.argument(0);
|
||||
|
||||
// 1. Let C be the this value.
|
||||
auto constructor = vm.this_value(global_object);
|
||||
|
||||
// 2. If Type(C) is not Object, throw a TypeError exception.
|
||||
// FIXME: Don't coerce to object!
|
||||
auto* constructor = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
if (!constructor.is_object())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, constructor.to_string_without_side_effects());
|
||||
|
||||
// 3. Return ? PromiseResolve(C, x).
|
||||
return TRY(promise_resolve(global_object, *constructor, value));
|
||||
return TRY(promise_resolve(global_object, constructor.as_object(), value));
|
||||
}
|
||||
|
||||
// 27.2.4.8 get Promise [ @@species ], https://tc39.es/ecma262/#sec-get-promise-@@species
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue