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

LibWeb: Handle window.open() when passed a navigable name

This commit is contained in:
Andrew Kaster 2023-11-28 08:36:09 -07:00 committed by Alexander Kalenik
parent e3f5bbcbbe
commit 0104c8d052
3 changed files with 47 additions and 1 deletions

View file

@ -748,6 +748,36 @@ bool BrowsingContext::is_ancestor_of(BrowsingContext const& other) const
return false;
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#familiar-with
bool BrowsingContext::is_familiar_with(BrowsingContext const& other) const
{
// A browsing context A is familiar with a second browsing context B if the following algorithm returns true:
auto const& A = *this;
auto const& B = other;
// 1. If A's active document's origin is same origin with B's active document's origin, then return true.
if (A.active_document()->origin().is_same_origin(B.active_document()->origin()))
return true;
// 2. If A's top-level browsing context is B, then return true.
if (A.top_level_browsing_context() == &B)
return true;
// 3. If B is an auxiliary browsing context and A is familiar with B's opener browsing context, then return true.
if (B.opener_browsing_context() != nullptr && A.is_familiar_with(*B.opener_browsing_context()))
return true;
// 4. If there exists an ancestor browsing context of B whose active document has the same origin as the active document of A, then return true.
// NOTE: This includes the case where A is an ancestor browsing context of B.
for (auto ancestor = B.parent(); ancestor; ancestor = ancestor->parent()) {
if (ancestor->active_document()->origin().is_same_origin(A.active_document()->origin()))
return true;
}
// 5. Return false.
return false;
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-target-snapshot-params
SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&, JS::GCPtr<DOM::Element>)
{