mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
LibWeb: Add special handling for WindowProxy in [Replaceable] setters
Setters for Window object should consider WindowProxy wrapper by: - Verifying `this_value` is `WindowProxy` (not `HTML::Window`) - Defining properties on the underlying Window object instead of on the WindowProxy itself.
This commit is contained in:
parent
9b1b8828b4
commit
1528e9109c
3 changed files with 24 additions and 1 deletions
|
@ -3186,6 +3186,20 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
||||||
}
|
}
|
||||||
)~~~");
|
)~~~");
|
||||||
} else if (attribute.extended_attributes.contains("Replaceable"sv)) {
|
} else if (attribute.extended_attributes.contains("Replaceable"sv)) {
|
||||||
|
if (interface.name.is_one_of("Window")) {
|
||||||
|
attribute_generator.append(R"~~~(
|
||||||
|
JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
||||||
|
{
|
||||||
|
auto this_value = vm.this_value();
|
||||||
|
if (!this_value.is_object() || !is<WindowProxy>(this_value.as_object()))
|
||||||
|
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@namespaced_name@");
|
||||||
|
auto& window_proxy = static_cast<WindowProxy&>(this_value.as_object());
|
||||||
|
TRY(window_proxy.window()->internal_define_own_property("@attribute.name@", JS::PropertyDescriptor { .value = vm.argument(0), .writable = true }));
|
||||||
|
return JS::js_undefined();
|
||||||
|
}
|
||||||
|
)~~~");
|
||||||
|
} else {
|
||||||
|
|
||||||
attribute_generator.append(R"~~~(
|
attribute_generator.append(R"~~~(
|
||||||
JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
||||||
{
|
{
|
||||||
|
@ -3196,6 +3210,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
||||||
return JS::js_undefined();
|
return JS::js_undefined();
|
||||||
}
|
}
|
||||||
)~~~");
|
)~~~");
|
||||||
|
}
|
||||||
} else if (auto put_forwards_identifier = attribute.extended_attributes.get("PutForwards"sv); put_forwards_identifier.has_value()) {
|
} else if (auto put_forwards_identifier = attribute.extended_attributes.get("PutForwards"sv); put_forwards_identifier.has_value()) {
|
||||||
attribute_generator.set("put_forwards_identifier"sv, *put_forwards_identifier);
|
attribute_generator.set("put_forwards_identifier"sv, *put_forwards_identifier);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
hello
|
|
@ -0,0 +1,7 @@
|
||||||
|
<script src="include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
window.event = "hello";
|
||||||
|
println(window.event);
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue