mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:58:11 +00:00
LibWeb: Implement 'cross-origin accessible window property name' concept
This commit is contained in:
parent
d124889698
commit
ae96eae4f9
2 changed files with 11 additions and 0 deletions
|
@ -55,6 +55,16 @@ Vector<CrossOriginProperty> cross_origin_properties(Variant<LocationObject const
|
|||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#cross-origin-accessible-window-property-name
|
||||
bool is_cross_origin_accessible_window_property_name(JS::PropertyKey const& property_key)
|
||||
{
|
||||
// A JavaScript property name P is a cross-origin accessible window property name if it is "window", "self", "location", "close", "closed", "focus", "blur", "frames", "length", "top", "opener", "parent", "postMessage", or an array index property name.
|
||||
static Array<FlyString, 13> property_names {
|
||||
"window"sv, "self"sv, "location"sv, "close"sv, "closed"sv, "focus"sv, "blur"sv, "frames"sv, "length"sv, "top"sv, "opener"sv, "parent"sv, "postMessage"sv
|
||||
};
|
||||
return (property_key.is_string() && any_of(property_names, [&](auto const& name) { return property_key.as_string() == name; })) || property_key.is_number();
|
||||
}
|
||||
|
||||
// 7.2.3.2 CrossOriginPropertyFallback ( P ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertyfallback-(-p-)
|
||||
JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS::GlobalObject& global_object, JS::PropertyKey const& property_key)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ struct CrossOriginKey {
|
|||
using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
|
||||
|
||||
Vector<CrossOriginProperty> cross_origin_properties(Variant<LocationObject const*, WindowObject const*> const&);
|
||||
bool is_cross_origin_accessible_window_property_name(JS::PropertyKey const&);
|
||||
JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS::GlobalObject&, JS::PropertyKey const&);
|
||||
bool is_platform_object_same_origin(JS::Object const&);
|
||||
Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<LocationObject*, WindowObject*> const&, JS::PropertyKey const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue