mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibWeb: Implement the CrossOriginGet AO
This commit is contained in:
parent
c7b977547d
commit
245ec99813
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 {};
|
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&);
|
JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS::GlobalObject&, JS::PropertyKey const&);
|
||||||
bool is_platform_object_same_origin(JS::Object 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&);
|
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…
Add table
Add a link
Reference in a new issue