LibWeb: Use correct condition and field for navigation initiator origin

The guard for setting top-level navigation initiator origin called
top_level_traversable()->parent() == nullptr, which is tautologically
true: top_level_traversable() already walks to the topmost traversable,
whose parent is always null. This caused the field to be set on every
navigation, including child navigable navigations inside iframes.

The value was also read from document_state()->origin() instead of
document_state()->initiator_origin(), giving the document's own origin
rather than the origin of whoever initiated the navigation.

Use is_top_level_traversable() and initiator_origin() to match the
spec step.
This commit is contained in:
Praise-Garfield
2026-02-21 16:48:04 +00:00
committed by Jelle Raaijmakers
parent 8d4084261a
commit 6a3b9c5ffc
Notes: github-actions[bot] 2026-02-23 12:09:07 +00:00

View File

@@ -1120,8 +1120,8 @@ static void create_navigation_params_by_fetching(GC::Ptr<SessionHistoryEntry> en
// 4. If navigable is a top-level traversable, then set request's top-level navigation initiator origin to entry's
// document state's initiator origin.
if (navigable->top_level_traversable()->parent() == nullptr)
request->set_top_level_navigation_initiator_origin(entry->document_state()->origin());
if (navigable->is_top_level_traversable())
request->set_top_level_navigation_initiator_origin(entry->document_state()->initiator_origin());
// 5. If request's client is null:
if (request->client() == nullptr) {