1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

LibWeb: Add window.navigation property

This commit is contained in:
Andrew Kaster 2023-08-23 10:58:09 -06:00 committed by Andrew Kaster
parent 0c2f758067
commit 7f043e3083
3 changed files with 22 additions and 0 deletions

View file

@ -38,6 +38,7 @@
#include <LibWeb/HTML/Focus.h>
#include <LibWeb/HTML/Location.h>
#include <LibWeb/HTML/MessageEvent.h>
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/Navigator.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/PageTransitionEvent.h>
@ -106,6 +107,7 @@ void Window::visit_edges(JS::Cell::Visitor& visitor)
visitor.visit(m_location);
visitor.visit(m_crypto);
visitor.visit(m_navigator);
visitor.visit(m_navigation);
visitor.visit(m_custom_element_registry);
for (auto& plugin_object : m_pdf_viewer_plugin_objects)
visitor.visit(plugin_object);
@ -1410,6 +1412,20 @@ JS::NonnullGCPtr<Crypto::Crypto> Window::crypto()
return JS::NonnullGCPtr { *m_crypto };
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation
JS::NonnullGCPtr<Navigation> Window::navigation()
{
// Upon creation of the Window object, its navigation API must be set
// to a new Navigation object created in the Window object's relevant realm.
if (!m_navigation) {
auto& realm = relevant_realm(*this);
m_navigation = heap().allocate<Navigation>(realm, realm);
}
// The navigation getter steps are to return this's navigation API.
return *m_navigation;
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-window-customelements
JS::NonnullGCPtr<CustomElementRegistry> Window::custom_elements()
{