From 885004abee65fc7ad5740e6641da5313d13dcb63 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 6 Aug 2022 01:02:41 +0100 Subject: [PATCH] LibJS: Support creation of global object in Realm::set_global_object() --- Userland/Libraries/LibJS/Runtime/Realm.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Realm.cpp b/Userland/Libraries/LibJS/Runtime/Realm.cpp index 54a50610374235..93cfb071d5d08e 100644 --- a/Userland/Libraries/LibJS/Runtime/Realm.cpp +++ b/Userland/Libraries/LibJS/Runtime/Realm.cpp @@ -75,8 +75,11 @@ void Realm::set_global_object(GlobalObject* global_object, GlobalObject* this_va { // 1. If globalObj is undefined, then if (global_object == nullptr) { - // NOTE: Step 1 is not supported, the global object must be allocated elsewhere. - VERIFY_NOT_REACHED(); + // a. Let intrinsics be realmRec.[[Intrinsics]]. + // b. Set globalObj to OrdinaryObjectCreate(intrinsics.[[%Object.prototype%]]). + // NOTE: We allocate a proper GlobalObject directly as this plain object is + // turned into one via SetDefaultGlobalBindings in the spec. + global_object = heap().allocate_without_global_object(*this); } // 2. Assert: Type(globalObj) is Object.