mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-07 01:21:57 +00:00
LibJS: Add and use ValidateNonRevokedProxy AO
This refactor is from two editorial changes to the spec from a while back.44d1cae2b2
21ffeee869
This commit is contained in:
parent
e48645c83f
commit
9bae24cc4a
Notes:
github-actions[bot]
2025-04-24 08:38:42 +00:00
Author: https://github.com/ADKaster
Commit: 9bae24cc4a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4437
4 changed files with 107 additions and 122 deletions
|
@ -175,29 +175,26 @@ ThrowCompletionOr<Realm*> get_function_realm(VM& vm, FunctionObject const& funct
|
|||
}
|
||||
|
||||
// 2. If obj is a bound function exotic object, then
|
||||
if (is<BoundFunction>(function)) {
|
||||
auto& bound_function = static_cast<BoundFunction const&>(function);
|
||||
if (auto const* bound_function = as_if<BoundFunction>(function)) {
|
||||
// a. Let boundTargetFunction be obj.[[BoundTargetFunction]].
|
||||
auto& bound_target_function = bound_function->bound_target_function();
|
||||
|
||||
// a. Let target be obj.[[BoundTargetFunction]].
|
||||
auto& target = bound_function.bound_target_function();
|
||||
|
||||
// b. Return ? GetFunctionRealm(target).
|
||||
return get_function_realm(vm, target);
|
||||
// b. Return ? GetFunctionRealm(boundTargetFunction).
|
||||
return get_function_realm(vm, bound_target_function);
|
||||
}
|
||||
|
||||
// 3. If obj is a Proxy exotic object, then
|
||||
if (is<ProxyObject>(function)) {
|
||||
auto& proxy = static_cast<ProxyObject const&>(function);
|
||||
|
||||
// a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
||||
if (proxy.is_revoked())
|
||||
return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked);
|
||||
if (auto const* proxy = as_if<ProxyObject>(function)) {
|
||||
// a. a. Perform ? ValidateNonRevokedProxy(obj).
|
||||
TRY(proxy->validate_non_revoked_proxy());
|
||||
|
||||
// b. Let proxyTarget be obj.[[ProxyTarget]].
|
||||
auto& proxy_target = proxy.target();
|
||||
auto& proxy_target = proxy->target();
|
||||
|
||||
// c. Return ? GetFunctionRealm(proxyTarget).
|
||||
// c. Assert: proxyTarget is a function object.
|
||||
VERIFY(proxy_target.is_function());
|
||||
|
||||
// d. Return ? GetFunctionRealm(proxyTarget).
|
||||
return get_function_realm(vm, static_cast<FunctionObject const&>(proxy_target));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue