summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-08-21 21:21:52 +0100
committerLinus Groh <mail@linusgroh.de>2022-08-23 13:58:30 +0100
commitf8fb985b059ee026e81eb511660581f84cc35157 (patch)
tree09abee5119fa3708908170c8974d40e9afda02b9 /Userland/Libraries
parent5f1fe4b012d9f19aff14144ce41c8f22b57241b8 (diff)
downloadserenity-f8fb985b059ee026e81eb511660581f84cc35157.zip
LibWeb: Replace GlobalObject with VM in CrossOrigin AOs [Part 2/4]
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp12
-rw-r--r--Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h6
-rw-r--r--Userland/Libraries/LibWeb/Bindings/LocationObject.cpp13
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp13
4 files changed, 18 insertions, 26 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp
index b60f982d05..84a7f0d452 100644
--- a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.cpp
@@ -67,10 +67,8 @@ bool is_cross_origin_accessible_window_property_name(JS::PropertyKey const& prop
}
// 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)
+JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS::VM& vm, JS::PropertyKey const& property_key)
{
- auto& vm = global_object.vm();
-
// 1. If P is "then", @@toStringTag, @@hasInstance, or @@isConcatSpreadable, then return PropertyDescriptor{ [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
auto property_key_is_then = property_key.is_string() && property_key.as_string() == vm.names.then.as_string();
auto property_key_is_allowed_symbol = property_key.is_symbol()
@@ -179,10 +177,8 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<Lo
}
// 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)
+JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::VM& vm, 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));
@@ -208,10 +204,8 @@ JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::GlobalObject& global_objec
}
// 7.2.3.6 CrossOriginSet ( O, P, V, Receiver ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginset-(-o,-p,-v,-receiver-)
-JS::ThrowCompletionOr<bool> cross_origin_set(JS::GlobalObject& global_object, JS::Object& object, JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver)
+JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM& vm, JS::Object& object, JS::PropertyKey const& property_key, JS::Value value, 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));
diff --git a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h
index 8c0081d5af..19c962d0e9 100644
--- a/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h
+++ b/Userland/Libraries/LibWeb/Bindings/CrossOriginAbstractOperations.h
@@ -29,11 +29,11 @@ using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDes
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&);
+JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS::VM&, 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);
+JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::VM&, JS::Object const&, JS::PropertyKey const&, JS::Value receiver);
+JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM&, JS::Object&, JS::PropertyKey const&, JS::Value, JS::Value receiver);
JS::MarkedVector<JS::Value> cross_origin_own_property_keys(Variant<LocationObject const*, WindowObject const*> const&);
}
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
index 9bc06c81d6..9c970a5f52 100644
--- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -268,8 +268,7 @@ JS::ThrowCompletionOr<bool> LocationObject::internal_prevent_extensions()
// 7.10.5.5 [[GetOwnProperty]] ( P ), https://html.spec.whatwg.org/multipage/history.html#location-getownproperty
JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> LocationObject::internal_get_own_property(JS::PropertyKey const& property_key) const
{
- auto& global_object = HTML::current_global_object();
- auto& vm = global_object.vm();
+ auto& vm = this->vm();
// 1. If IsPlatformObjectSameOrigin(this) is true, then:
if (is_platform_object_same_origin(*this)) {
@@ -295,7 +294,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> LocationObject::internal
return property;
// 4. Return ? CrossOriginPropertyFallback(P).
- return TRY(cross_origin_property_fallback(global_object, property_key));
+ return TRY(cross_origin_property_fallback(vm, property_key));
}
// 7.10.5.6 [[DefineOwnProperty]] ( P, Desc ), https://html.spec.whatwg.org/multipage/history.html#location-defineownproperty
@@ -318,27 +317,27 @@ JS::ThrowCompletionOr<bool> LocationObject::internal_define_own_property(JS::Pro
// 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get
JS::ThrowCompletionOr<JS::Value> LocationObject::internal_get(JS::PropertyKey const& property_key, JS::Value receiver) const
{
- auto& global_object = HTML::current_global_object();
+ auto& vm = this->vm();
// 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinaryGet(this, P, Receiver).
if (is_platform_object_same_origin(*this))
return JS::Object::internal_get(property_key, receiver);
// 2. Return ? CrossOriginGet(this, P, Receiver).
- return cross_origin_get(global_object, static_cast<JS::Object const&>(*this), property_key, receiver);
+ return cross_origin_get(vm, static_cast<JS::Object const&>(*this), property_key, receiver);
}
// 7.10.5.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-set
JS::ThrowCompletionOr<bool> LocationObject::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver)
{
- auto& global_object = HTML::current_global_object();
+ auto& vm = this->vm();
// 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinarySet(this, P, V, Receiver).
if (is_platform_object_same_origin(*this))
return JS::Object::internal_set(property_key, value, receiver);
// 2. Return ? CrossOriginSet(this, P, V, Receiver).
- return cross_origin_set(global_object, static_cast<JS::Object&>(*this), property_key, value, receiver);
+ return cross_origin_set(vm, static_cast<JS::Object&>(*this), property_key, value, receiver);
}
// 7.10.5.9 [[Delete]] ( P ), https://html.spec.whatwg.org/multipage/history.html#location-delete
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp b/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp
index 8acf44d5dd..e77e175fac 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp
@@ -65,8 +65,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_prevent_extensions()
// 7.4.5 [[GetOwnProperty]] ( P ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-getownproperty
JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_get_own_property(JS::PropertyKey const& property_key) const
{
- auto& global_object = HTML::current_global_object();
- auto& vm = global_object.vm();
+ auto& vm = this->vm();
// 1. Let W be the value of the [[Window]] internal slot of this.
@@ -123,7 +122,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_ge
}
// 7. Return ? CrossOriginPropertyFallback(P).
- return TRY(cross_origin_property_fallback(global_object, property_key));
+ return TRY(cross_origin_property_fallback(vm, property_key));
}
// 7.4.6 [[DefineOwnProperty]] ( P, Desc ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-defineownproperty
@@ -152,7 +151,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_define_own_property(JS::Proper
// 7.4.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-get
JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const& property_key, JS::Value receiver) const
{
- auto& global_object = HTML::current_global_object();
+ auto& vm = this->vm();
// 1. Let W be the value of the [[Window]] internal slot of this.
@@ -166,13 +165,13 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
// 4. Return ? CrossOriginGet(this, P, Receiver).
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.
- return cross_origin_get(global_object, *this, property_key, receiver);
+ return cross_origin_get(vm, *this, property_key, receiver);
}
// 7.4.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-set
JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver)
{
- auto& global_object = HTML::current_global_object();
+ auto& vm = this->vm();
// 1. Let W be the value of the [[Window]] internal slot of this.
@@ -191,7 +190,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& pro
// 4. Return ? CrossOriginSet(this, P, V, Receiver).
// NOTE: this is passed rather than W as CrossOriginSet will invoke the [[GetOwnProperty]] internal method.
- return cross_origin_set(global_object, *this, property_key, value, receiver);
+ return cross_origin_set(vm, *this, property_key, value, receiver);
}
// 7.4.9 [[Delete]] ( P ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-delete