diff --git a/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Libraries/LibWeb/HTML/WorkerLocation.cpp index 720fbd74ab2..d3f2586eaa4 100644 --- a/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -14,11 +14,10 @@ namespace Web::HTML { GC_DEFINE_ALLOCATOR(WorkerLocation); // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-href -WebIDL::ExceptionOr WorkerLocation::href() const +String WorkerLocation::href() const { - auto& vm = realm().vm(); // The href getter steps are to return this's WorkerGlobalScope object's url, serialized. - return TRY_OR_THROW_OOM(vm, String::from_byte_string(m_global_scope->url().serialize())); + return MUST(String::from_byte_string(m_global_scope->url().serialize())); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-origin @@ -29,18 +28,15 @@ String WorkerLocation::origin() const } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-protocol -WebIDL::ExceptionOr WorkerLocation::protocol() const +String WorkerLocation::protocol() const { - auto& vm = realm().vm(); // The protocol getter steps are to return this's WorkerGlobalScope object's url's scheme, followed by ":". - return TRY_OR_THROW_OOM(vm, String::formatted("{}:", m_global_scope->url().scheme())); + return MUST(String::formatted("{}:", m_global_scope->url().scheme())); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-host -WebIDL::ExceptionOr WorkerLocation::host() const +String WorkerLocation::host() const { - auto& vm = realm().vm(); - // The host getter steps are: // 1. Let url be this's WorkerGlobalScope object's url. auto const& url = m_global_scope->url(); @@ -54,11 +50,11 @@ WebIDL::ExceptionOr WorkerLocation::host() const return url.serialized_host(); // 4. Return url's host, serialized, followed by ":" and url's port, serialized. - return TRY_OR_THROW_OOM(vm, String::formatted("{}:{}", url.serialized_host(), url.port().value())); + return MUST(String::formatted("{}:{}", url.serialized_host(), url.port().value())); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-hostname -WebIDL::ExceptionOr WorkerLocation::hostname() const +String WorkerLocation::hostname() const { // The hostname getter steps are: // 1. Let host be this's WorkerGlobalScope object's url's host. @@ -73,7 +69,7 @@ WebIDL::ExceptionOr WorkerLocation::hostname() const } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-port -WebIDL::ExceptionOr WorkerLocation::port() const +String WorkerLocation::port() const { // The port getter steps are: // 1. Let port be this's WorkerGlobalScope object's url's port. @@ -82,6 +78,7 @@ WebIDL::ExceptionOr WorkerLocation::port() const // 2. If port is null, return the empty string. if (!port.has_value()) return String {}; + // 3. Return port, serialized. return String::number(port.value()); } @@ -94,10 +91,8 @@ String WorkerLocation::pathname() const } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-search -WebIDL::ExceptionOr WorkerLocation::search() const +String WorkerLocation::search() const { - auto& vm = realm().vm(); - // The search getter steps are: // 1. Let query be this's WorkerGlobalScope object's url's query. auto const& query = m_global_scope->url().query(); @@ -107,14 +102,12 @@ WebIDL::ExceptionOr WorkerLocation::search() const return String {}; // 3. Return "?", followed by query. - return TRY_OR_THROW_OOM(vm, String::formatted("?{}", *query)); + return MUST(String::formatted("?{}", *query)); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-hash -WebIDL::ExceptionOr WorkerLocation::hash() const +String WorkerLocation::hash() const { - auto& vm = realm().vm(); - // The hash getter steps are: // 1. Let fragment be this's WorkerGlobalScope object's url's fragment. auto const& fragment = m_global_scope->url().fragment(); @@ -124,7 +117,7 @@ WebIDL::ExceptionOr WorkerLocation::hash() const return String {}; // 3. Return "#", followed by fragment. - return TRY_OR_THROW_OOM(vm, String::formatted("#{}", *fragment)); + return MUST(String::formatted("#{}", *fragment)); } WorkerLocation::WorkerLocation(WorkerGlobalScope& global_scope) diff --git a/Libraries/LibWeb/HTML/WorkerLocation.h b/Libraries/LibWeb/HTML/WorkerLocation.h index 17f352bb03c..8caace9089b 100644 --- a/Libraries/LibWeb/HTML/WorkerLocation.h +++ b/Libraries/LibWeb/HTML/WorkerLocation.h @@ -18,15 +18,15 @@ class WorkerLocation : public Bindings::PlatformObject { public: virtual ~WorkerLocation() override; - WebIDL::ExceptionOr href() const; + String href() const; String origin() const; - WebIDL::ExceptionOr protocol() const; - WebIDL::ExceptionOr host() const; - WebIDL::ExceptionOr hostname() const; - WebIDL::ExceptionOr port() const; + String protocol() const; + String host() const; + String hostname() const; + String port() const; String pathname() const; - WebIDL::ExceptionOr search() const; - WebIDL::ExceptionOr hash() const; + String search() const; + String hash() const; private: explicit WorkerLocation(WorkerGlobalScope&);