summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-08-16 00:20:49 +0100
committerLinus Groh <mail@linusgroh.de>2022-08-23 13:58:30 +0100
commitb99cc7d05039b9386538a581244be5af782c8d05 (patch)
tree76e012c25d6ecda6dc56b37354dc833bd1a1b9ee /Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
parent5dd5896588b0e5a7bc7bdadeaa7dd4865f663b79 (diff)
downloadserenity-b99cc7d05039b9386538a581244be5af782c8d05.zip
LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
index 6d6d2d51af..beadbce5b8 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
@@ -15,6 +15,7 @@ namespace JS {
ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global_object, Value constructor)
{
auto& vm = global_object.vm();
+ auto& realm = *global_object.associated_realm();
// 1. If IsConstructor(C) is false, throw a TypeError exception.
if (!constructor.is_constructor())
@@ -55,7 +56,7 @@ ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global
};
// 5. Let executor be CreateBuiltinFunction(executorClosure, 2, "", « »).
- auto* executor = NativeFunction::create(global_object, move(executor_closure), 2, "");
+ auto* executor = NativeFunction::create(realm, move(executor_closure), 2, "");
// 6. Let promise be ? Construct(C, « executor »).
auto* promise = TRY(construct(global_object, constructor.as_function(), executor));