mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibJS: Initialize ShadowRealm internal slots through setters
This allows us to align our implementation in the same order as the specification. No functional change with the current implementation of this AO. However, this change is required in order to correctly implement a proposed update of the shadow realm proposal for integration with the HTML spec host bindings in order to give the ShadowRealm object the correct 'intrinsic' realm. This is due to that proposed change adding a step which manipulates the currently executing Javascript execution context, making the ordering important.
This commit is contained in:
parent
db6ec2792a
commit
0ec8af5b70
Notes:
github-actions[bot]
2024-10-23 17:31:05 +00:00
Author: https://github.com/shannonbooth
Commit: 0ec8af5b70
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1927
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 17 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -43,9 +44,15 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(Functi
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
// 2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%ShadowRealm.prototype%", « [[ShadowRealm]], [[ExecutionContext]] »).
|
||||
auto object = TRY(ordinary_create_from_constructor<ShadowRealm>(vm, new_target, &Intrinsics::shadow_realm_prototype));
|
||||
|
||||
// 3. Let realmRec be CreateRealm().
|
||||
auto realm = MUST_OR_THROW_OOM(Realm::create(vm));
|
||||
|
||||
// 4. Set O.[[ShadowRealm]] to realmRec.
|
||||
object->set_shadow_realm(realm);
|
||||
|
||||
// 5. Let context be a new execution context.
|
||||
auto context = ExecutionContext::create();
|
||||
|
||||
|
@ -58,10 +65,8 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(Functi
|
|||
// 8. Set the ScriptOrModule of context to null.
|
||||
// Note: This is already the default value.
|
||||
|
||||
// 2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%ShadowRealm.prototype%", « [[ShadowRealm]], [[ExecutionContext]] »).
|
||||
// 4. Set O.[[ShadowRealm]] to realmRec.
|
||||
// 9. Set O.[[ExecutionContext]] to context.
|
||||
auto object = TRY(ordinary_create_from_constructor<ShadowRealm>(vm, new_target, &Intrinsics::shadow_realm_prototype, *realm, move(context)));
|
||||
object->set_execution_context(move(context));
|
||||
|
||||
// 10. Perform ? SetRealmGlobalObject(realmRec, undefined, undefined).
|
||||
realm->set_global_object(nullptr, nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue