1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

LibWeb: Implement window.name

Right now the only functionality supported is getting/setting via JS
and resetting when browsing cross origin.

The HTML Specification (7.11 Browsing the web) also specifies how the
name should be restored from history entries, but we don't have those
yet.
This commit is contained in:
Simon Wanner 2022-03-16 17:15:11 +01:00 committed by Linus Groh
parent 619794dfa7
commit 7969161f07
6 changed files with 57 additions and 0 deletions

View file

@ -80,6 +80,19 @@ void BrowsingContext::set_active_document(DOM::Document* document)
if (m_active_document)
m_active_document->detach_from_browsing_context({}, *this);
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#resetBCName
// FIXME: The rest of set_active_document does not follow the spec very closely, this just implements the
// relevant steps for resetting the browsing context name and should be updated closer to the spec once
// the other parts of history handling/navigating are implemented
// 3. If newDocument's origin is not same origin with the current entry's document's origin, then:
if (!document || !m_active_document || !document->origin().is_same_origin(m_active_document->origin())) {
// 3. If the browsing context is a top-level browsing context, but not an auxiliary browsing context
// whose disowned is false, then set the browsing context's name to the empty string.
// FIXME: this is not checking the second part of the condition yet
if (is_top_level())
m_name = String::empty();
}
m_active_document = document;
if (m_active_document) {