diff options
author | Linus Groh <mail@linusgroh.de> | 2022-03-05 21:03:06 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-03-06 23:27:39 +0100 |
commit | bccbad003f56d589545999fdc25898a5b9db7444 (patch) | |
tree | 1453a28c2379fb2d961c3334dc84b40f92e32794 /Userland/Libraries/LibWeb | |
parent | 34fed7bfcc4171e7c9f41302434d254693f45ec8 (diff) | |
download | serenity-bccbad003f56d589545999fdc25898a5b9db7444.zip |
LibWeb: Implement the IsPlatformObjectSameOrigin AO
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp index fc397a8707..f45129df91 100644 --- a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp @@ -71,4 +71,11 @@ JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS: return vm.throw_completion<DOMExceptionWrapper>(global_object, DOM::SecurityError::create(String::formatted("Can't access property '{}' on cross-origin object", property_key))); } +// 7.2.3.3 IsPlatformObjectSameOrigin ( O ), https://html.spec.whatwg.org/multipage/browsers.html#isplatformobjectsameorigin-(-o-) +bool is_platform_object_same_origin(JS::Object const& object) +{ + // 1. Return true if the current settings object's origin is same origin-domain with O's relevant settings object's origin, and false otherwise. + return HTML::current_settings_object().origin().is_same_origin_domain(HTML::relevant_settings_object(object).origin()); +} + } diff --git a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h index 748b055645..b5527833a1 100644 --- a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h +++ b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h @@ -29,6 +29,7 @@ using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDes Vector<CrossOriginProperty> cross_origin_properties(Variant<LocationObject const*, WindowObject const*> const&); JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS::GlobalObject&, JS::PropertyKey const&); +bool is_platform_object_same_origin(JS::Object const&); } |