mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +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:
parent
619794dfa7
commit
7969161f07
6 changed files with 57 additions and 0 deletions
|
@ -613,4 +613,24 @@ DOM::ExceptionOr<void> Window::post_message(JS::Value message, String const&)
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-name
|
||||
String Window::name() const
|
||||
{
|
||||
// 1. If this's browsing context is null, then return the empty string.
|
||||
if (!browsing_context())
|
||||
return String::empty();
|
||||
// 2. Return this's browsing context's name.
|
||||
return browsing_context()->name();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-name
|
||||
void Window::set_name(String const& name)
|
||||
{
|
||||
// 1. If this's browsing context is null, then return.
|
||||
if (!browsing_context())
|
||||
return;
|
||||
// 2. Set this's browsing context's name to the given value.
|
||||
browsing_context()->set_name(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue