mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
LibWeb: Implement the CrossOriginGet AO
This commit is contained in:
parent
c7b977547d
commit
245ec99813
Notes:
sideshowbarker
2024-07-17 17:51:39 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/245ec99813 Pull-request: https://github.com/SerenityOS/serenity/pull/12919 Reviewed-by: https://github.com/awesomekling ✅
2 changed files with 31 additions and 0 deletions
|
@ -166,4 +166,33 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<Lo
|
|||
return {};
|
||||
}
|
||||
|
||||
// 7.2.3.5 CrossOriginGet ( O, P, Receiver ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginget-(-o,-p,-receiver-)
|
||||
JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::GlobalObject& global_object, JS::Object const& object, JS::PropertyKey const& property_key, JS::Value receiver)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Let desc be ? O.[[GetOwnProperty]](P).
|
||||
auto descriptor = TRY(object.internal_get_own_property(property_key));
|
||||
|
||||
// 2. Assert: desc is not undefined.
|
||||
VERIFY(descriptor.has_value());
|
||||
|
||||
// 3. If IsDataDescriptor(desc) is true, then return desc.[[Value]].
|
||||
if (descriptor->is_data_descriptor())
|
||||
return descriptor->value;
|
||||
|
||||
// 4. Assert: IsAccessorDescriptor(desc) is true.
|
||||
VERIFY(descriptor->is_accessor_descriptor());
|
||||
|
||||
// 5. Let getter be desc.[[Get]].
|
||||
auto& getter = descriptor->get;
|
||||
|
||||
// 6. If getter is undefined, then throw a "SecurityError" DOMException.
|
||||
if (!getter.has_value())
|
||||
return vm.throw_completion<DOMExceptionWrapper>(global_object, DOM::SecurityError::create(String::formatted("Can't get property '{}' on cross-origin object", property_key)));
|
||||
|
||||
// 7. Return ? Call(getter, Receiver).
|
||||
return JS::call(global_object, *getter, receiver);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ Vector<CrossOriginProperty> cross_origin_properties(Variant<LocationObject 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&);
|
||||
JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::GlobalObject&, JS::Object const&, JS::PropertyKey const&, JS::Value receiver);
|
||||
JS::ThrowCompletionOr<bool> cross_origin_set(JS::GlobalObject&, JS::Object&, JS::PropertyKey const&, JS::Value, JS::Value receiver);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue