MessageChannel.cpp 761 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/Document.h>
  7. #include <LibWeb/HTML/MessageChannel.h>
  8. #include <LibWeb/HTML/MessagePort.h>
  9. namespace Web::HTML {
  10. MessageChannel::MessageChannel(Bindings::WindowObject& global_object)
  11. {
  12. auto& context = global_object.impl().associated_document();
  13. // 1. Set this's port 1 to a new MessagePort in this's relevant Realm.
  14. m_port1 = MessagePort::create(context);
  15. // 2. Set this's port 2 to a new MessagePort in this's relevant Realm.
  16. m_port2 = MessagePort::create(context);
  17. // 3. Entangle this's port 1 and this's port 2.
  18. m_port1->entangle_with({}, *m_port2);
  19. }
  20. MessageChannel::~MessageChannel()
  21. {
  22. }
  23. }