diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index 7be0802bf7..c75579fd70 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -895,26 +895,6 @@ WebIDL::ExceptionOr Window::structured_clone_impl(JS::VM& vm, JS::Val
return MUST(structured_deserialize(vm, serialized, *vm.current_realm(), {}));
}
-// https://html.spec.whatwg.org/multipage/window-object.html#dom-name
-DeprecatedString Window::name() const
-{
- // 1. If this's browsing context is null, then return the empty string.
- if (!browsing_context())
- return DeprecatedString::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(DeprecatedString 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);
-}
-
// https://html.spec.whatwg.org/multipage/interaction.html#transient-activation
bool Window::has_transient_activation() const
{
@@ -1094,7 +1074,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge Window::document() const
return associated_document();
}
+// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-name
+String Window::name() const
+{
+ // 1. If this's navigable is null, then return the empty string.
+ if (!browsing_context())
+ return String {};
+
+ // 2. Return this's navigable's target name.
+ return String::from_deprecated_string(browsing_context()->name()).release_value_but_fixme_should_propagate_errors();
+}
+
+// https://html.spec.whatwg.org/multipage/nav-history-apis.html#apis-for-creating-and-navigating-browsing-contexts-by-name:dom-name
+void Window::set_name(String const& name)
+{
+ // 1. If this's navigable is null, then return.
+ if (!browsing_context())
+ return;
+
+ // 2. Set this's navigable's active session history entry's document state's navigable target name to the given value.
+ browsing_context()->set_name(name.to_deprecated_string());
+}
+
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS::NonnullGCPtr Window::frames() const
{
@@ -1897,17 +1898,4 @@ JS_DEFINE_NATIVE_FUNCTION(Window::session_storage_getter)
return impl->session_storage();
}
-JS_DEFINE_NATIVE_FUNCTION(Window::name_getter)
-{
- auto* impl = TRY(impl_from(vm));
- return JS::PrimitiveString::create(vm, impl->name());
-}
-
-JS_DEFINE_NATIVE_FUNCTION(Window::name_setter)
-{
- auto* impl = TRY(impl_from(vm));
- impl->set_name(TRY(vm.argument(0).to_deprecated_string(vm)));
- return JS::js_undefined();
-}
-
}
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index 35a81d036f..10b1aac64d 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -121,9 +121,6 @@ public:
WebIDL::ExceptionOr structured_clone_impl(JS::VM& vm, JS::Value);
- DeprecatedString name() const;
- void set_name(DeprecatedString const&);
-
void start_an_idle_period();
u32 request_idle_callback_impl(WebIDL::CallbackType& callback);
@@ -143,6 +140,8 @@ public:
JS::NonnullGCPtr window() const;
JS::NonnullGCPtr self() const;
JS::NonnullGCPtr document() const;
+ String name() const;
+ void set_name(String const&);
JS::NonnullGCPtr frames() const;
@@ -227,9 +226,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(location_getter);
JS_DECLARE_NATIVE_FUNCTION(location_setter);
- JS_DECLARE_NATIVE_FUNCTION(name_getter);
- JS_DECLARE_NATIVE_FUNCTION(name_setter);
-
JS_DECLARE_NATIVE_FUNCTION(performance_getter);
JS_DECLARE_NATIVE_FUNCTION(performance_setter);
diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl
index 981837c0b0..1b282460f7 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -10,6 +10,7 @@ interface Window : EventTarget {
[LegacyUnforgeable] readonly attribute WindowProxy window;
[Replaceable] readonly attribute WindowProxy self;
[LegacyUnforgeable] readonly attribute Document document;
+ attribute DOMString name;
// other browsing contexts
[Replaceable] readonly attribute WindowProxy frames;