diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 30d40feaee..db5ef88654 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -1064,7 +1064,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge(JS::ErrorType::BadArgCountOne, "btoa"); - auto string = TRY(vm.argument(0).to_deprecated_string(vm)); - - Vector byte_string; - byte_string.ensure_capacity(string.length()); - for (u32 code_point : Utf8View(string)) { - if (code_point > 0xff) - return throw_completion(WebIDL::InvalidCharacterError::create(*vm.current_realm(), "Data contains characters outside the range U+0000 and U+00FF")); - byte_string.append(code_point); - } - - auto encoded = MUST(encode_base64(byte_string.span())); - return JS::PrimitiveString::create(vm, encoded.to_deprecated_string()); -} - // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus JS_DEFINE_NATIVE_FUNCTION(Window::focus) { diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 440311b930..2bb6dfc368 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -46,6 +46,8 @@ public: ~Window(); + using WindowOrWorkerGlobalScopeMixin::btoa; + // ^DOM::EventTarget virtual bool dispatch_event(DOM::Event&) override; @@ -265,7 +267,6 @@ private: JS_DECLARE_NATIVE_FUNCTION(request_animation_frame); JS_DECLARE_NATIVE_FUNCTION(cancel_animation_frame); JS_DECLARE_NATIVE_FUNCTION(atob); - JS_DECLARE_NATIVE_FUNCTION(btoa); JS_DECLARE_NATIVE_FUNCTION(focus); JS_DECLARE_NATIVE_FUNCTION(get_computed_style); diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl index 7702f5e363..029f3f7ff3 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.idl +++ b/Userland/Libraries/LibWeb/HTML/Window.idl @@ -39,6 +39,7 @@ interface Window : EventTarget { // FIXME: Replace these with 'Window includes WindowOrWorkerGlobalScope;' once we have feature parity [Replaceable] readonly attribute USVString origin; readonly attribute boolean isSecureContext; + DOMString btoa(DOMString data); }; Window includes GlobalEventHandlers; Window includes WindowEventHandlers;