WorkerEnvironmentSettingsObject.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h>
  7. #include <LibWeb/HTML/WorkerGlobalScope.h>
  8. namespace Web::HTML {
  9. JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObject::setup(NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
  10. {
  11. auto realm = execution_context->realm;
  12. VERIFY(realm);
  13. auto& worker = verify_cast<HTML::WorkerGlobalScope>(realm->global_object());
  14. auto settings_object = realm->heap().allocate<WorkerEnvironmentSettingsObject>(*realm, move(execution_context), worker);
  15. settings_object->target_browsing_context = nullptr;
  16. auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
  17. auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
  18. realm->set_host_defined(move(host_defined));
  19. // Non-Standard: We cannot fully initialize worker object until *after* the we set up
  20. // the realm's [[HostDefined]] internal slot as the internal slot contains the web platform intrinsics
  21. worker.initialize_web_interfaces({});
  22. return settings_object;
  23. }
  24. void WorkerEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
  25. {
  26. Base::visit_edges(visitor);
  27. visitor.visit(m_global_scope);
  28. }
  29. }