mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Throw when a setter is called with less than one argument
Some WPT tests expect that if you go out of your way to Object.getOwnPropertyDescriptor on an interface object and extract the setter out of it, that they throw when called with no arguments.
This commit is contained in:
parent
44e3817219
commit
67a6c9246c
Notes:
github-actions[bot]
2024-12-24 14:21:30 +00:00
Author: https://github.com/ADKaster
Commit: 67a6c9246c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3028
1 changed files with 8 additions and 0 deletions
|
@ -3906,6 +3906,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
WebIDL::log_trace(vm, "@class_name@::@attribute.setter_callback@");
|
||||
[[maybe_unused]] auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
if (vm.argument_count() < 1)
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "@namespaced_name@ setter");
|
||||
|
||||
auto value = vm.argument(0);
|
||||
)~~~");
|
||||
|
@ -4033,6 +4035,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
{
|
||||
WebIDL::log_trace(vm, "@class_name@::@attribute.setter_callback@");
|
||||
auto this_value = vm.this_value();
|
||||
if (vm.argument_count() < 1)
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "@namespaced_name@ setter");
|
||||
GC::Ptr<Window> window;
|
||||
if (this_value.is_object()) {
|
||||
if (is<WindowProxy>(this_value.as_object())) {
|
||||
|
@ -4060,6 +4064,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
auto this_value = vm.this_value();
|
||||
if (!this_value.is_object() || !is<@fully_qualified_name@>(this_value.as_object()))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@namespaced_name@");
|
||||
if (vm.argument_count() < 1)
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "@namespaced_name@ setter");
|
||||
TRY(this_value.as_object().internal_define_own_property("@attribute.name@", JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }));
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
@ -4074,6 +4080,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
{
|
||||
WebIDL::log_trace(vm, "@class_name@::@attribute.setter_callback@");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
if (vm.argument_count() < 1)
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "@namespaced_name@ setter");
|
||||
auto value = vm.argument(0);
|
||||
|
||||
auto receiver = TRY(throw_dom_exception_if_needed(vm, [&]() { return impl->@attribute.cpp_name@(); }));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue