LibJS: Actually create a new Realm in $262.createRealm()

This commit is contained in:
Andreas Kling 2022-08-05 12:21:02 +02:00
commit e2ae286132
Notes: sideshowbarker 2024-07-17 08:24:54 +09:00

View file

@ -57,10 +57,14 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::clear_kept_objects)
JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm)
{
// FIXME: This doesn't look right.
auto realm = vm.heap().allocate_without_global_object<GlobalObject>(*global_object.associated_realm());
realm->initialize_global_object();
return Value(realm->$262());
auto* realm = Realm::create(vm);
VERIFY(realm);
auto* realm_global_object = vm.heap().allocate_without_global_object<GlobalObject>(*realm);
VERIFY(realm_global_object);
realm->set_global_object(realm_global_object, js_undefined());
realm_global_object->set_associated_realm(*realm);
realm_global_object->initialize_global_object();
return Value(realm_global_object->$262());
}
JS_DEFINE_NATIVE_FUNCTION($262Object::detach_array_buffer)