1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:57:35 +00:00

LibWeb: Add the 'opener browsing context' BrowsingContext property

This will also be used by the window.open algorithm steps.
This commit is contained in:
Idan Horowitz 2022-11-15 01:58:26 +02:00 committed by Linus Groh
parent b27f855107
commit c948873c5b
3 changed files with 12 additions and 4 deletions

View file

@ -246,6 +246,7 @@ void BrowsingContext::visit_edges(Cell::Visitor& visitor)
visitor.visit(entry.document);
visitor.visit(m_container);
visitor.visit(m_window_proxy);
visitor.visit(m_opener_browsing_context);
visitor.visit(m_group);
visitor.visit(m_parent);
visitor.visit(m_first_child);

View file

@ -124,6 +124,10 @@ public:
HTML::WindowProxy* window_proxy();
HTML::WindowProxy const* window_proxy() const;
JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
HTML::Window* active_window();
HTML::Window const* active_window() const;
@ -288,6 +292,9 @@ private:
// https://html.spec.whatwg.org/multipage/browsers.html#browsing-context
JS::GCPtr<HTML::WindowProxy> m_window_proxy;
// https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
JS::GCPtr<BrowsingContext> m_opener_browsing_context;
DOM::Position m_cursor_position;
RefPtr<Platform::Timer> m_cursor_blink_timer;
bool m_cursor_blink_state { false };

View file

@ -26,12 +26,12 @@ void check_if_access_between_two_browsing_contexts_should_be_reported(BrowsingCo
// 4. Let accessorAccessedRelationship be a new accessor-accessed relationship with value none.
auto accessor_accessed_relationship = AccessorAccessedRelationship::None;
// FIXME: 5. If accessed's top-level browsing context's opener browsing context is accessor or an ancestor of accessor, then set accessorAccessedRelationship to accessor is opener.
if (false)
// 5. If accessed's top-level browsing context's opener browsing context is accessor or an ancestor of accessor, then set accessorAccessedRelationship to accessor is opener.
if (auto opener = accessed.top_level_browsing_context().opener_browsing_context(); opener && (opener == &accessor || opener->is_ancestor_of(accessor)))
accessor_accessed_relationship = AccessorAccessedRelationship::AccessorIsOpener;
// FIXME: 6. If accessor's top-level browsing context's opener browsing context is accessed or an ancestor of accessed, then set accessorAccessedRelationship to accessor is openee.
if (false)
// 6. If accessor's top-level browsing context's opener browsing context is accessed or an ancestor of accessed, then set accessorAccessedRelationship to accessor is openee.
if (auto opener = accessor.top_level_browsing_context().opener_browsing_context(); opener && (opener == &accessed || opener->is_ancestor_of(accessed)))
accessor_accessed_relationship = AccessorAccessedRelationship::AccessorIsOpenee;
// FIXME: 7. Queue violation reports for accesses, given accessorAccessedRelationship, accessor's top-level browsing context's active document's cross-origin opener policy, accessed's top-level browsing context's active document's cross-origin opener policy, accessor's active document's URL, accessed's active document's URL, accessor's top-level browsing context's initial URL, accessed's top-level browsing context's initial URL, accessor's active document's origin, accessed's active document's origin, accessor's top-level browsing context's opener origin at creation, accessed's top-level browsing context's opener origin at creation, accessor's top-level browsing context's active document's referrer, accessed's top-level browsing context's active document's referrer, P, and environment.