mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibWeb: Move DOMException from DOM/ to WebIDL/
This commit is contained in:
parent
ad04d7ac9b
commit
bbaa05fcf9
49 changed files with 206 additions and 203 deletions
|
@ -881,7 +881,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::navigate(
|
|||
// 1. If exceptionsEnabled is given and is true, then throw a "SecurityError" DOMException.
|
||||
if (exceptions_enabled) {
|
||||
VERIFY(source_browsing_context.active_document());
|
||||
return DOM::SecurityError::create(source_browsing_context.active_document()->global_object(), "Source browsing context not allowed to navigate"sv);
|
||||
return WebIDL::SecurityError::create(source_browsing_context.active_document()->global_object(), "Source browsing context not allowed to navigate"sv);
|
||||
}
|
||||
|
||||
// FIXME: 2. Otherwise, the user agent may instead offer to open resource in a new top-level browsing context
|
||||
|
|
|
@ -39,17 +39,17 @@ void CanvasPath::bezier_curve_to(double cp1x, double cp1y, double cp2x, double c
|
|||
WebIDL::ExceptionOr<void> CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise)
|
||||
{
|
||||
if (radius < 0)
|
||||
return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The radius provided ({}) is negative.", radius));
|
||||
return WebIDL::IndexSizeError::create(m_self.global_object(), String::formatted("The radius provided ({}) is negative.", radius));
|
||||
return ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise)
|
||||
{
|
||||
if (radius_x < 0)
|
||||
return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The major-axis radius provided ({}) is negative.", radius_x));
|
||||
return WebIDL::IndexSizeError::create(m_self.global_object(), String::formatted("The major-axis radius provided ({}) is negative.", radius_x));
|
||||
|
||||
if (radius_y < 0)
|
||||
return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The minor-axis radius provided ({}) is negative.", radius_y));
|
||||
return WebIDL::IndexSizeError::create(m_self.global_object(), String::formatted("The minor-axis radius provided ({}) is negative.", radius_y));
|
||||
|
||||
if (constexpr float tau = M_TAU; (!counter_clockwise && (end_angle - start_angle) >= tau)
|
||||
|| (counter_clockwise && (start_angle - end_angle) >= tau)) {
|
||||
|
|
|
@ -53,14 +53,14 @@ WebIDL::ExceptionOr<void> CanvasGradient::add_color_stop(double offset, String c
|
|||
{
|
||||
// 1. If the offset is less than 0 or greater than 1, then throw an "IndexSizeError" DOMException.
|
||||
if (offset < 0 || offset > 1)
|
||||
return DOM::IndexSizeError::create(global_object(), "CanvasGradient color stop offset out of bounds");
|
||||
return WebIDL::IndexSizeError::create(global_object(), "CanvasGradient color stop offset out of bounds");
|
||||
|
||||
// 2. Let parsed color be the result of parsing color.
|
||||
auto parsed_color = Color::from_string(color);
|
||||
|
||||
// 3. If parsed color is failure, throw a "SyntaxError" DOMException.
|
||||
if (!parsed_color.has_value())
|
||||
return DOM::SyntaxError::create(global_object(), "Could not parse color for CanvasGradient");
|
||||
return WebIDL::SyntaxError::create(global_object(), "Could not parse color for CanvasGradient");
|
||||
|
||||
// 4. Place a new stop on the gradient, at offset offset relative to the whole gradient, and with the color parsed color.
|
||||
m_color_stops.append(ColorStop { offset, parsed_color.value() });
|
||||
|
|
|
@ -275,11 +275,11 @@ WebIDL::ExceptionOr<JS::GCPtr<ImageData>> CanvasRenderingContext2D::get_image_da
|
|||
{
|
||||
// 1. If either the sw or sh arguments are zero, then throw an "IndexSizeError" DOMException.
|
||||
if (width == 0 || height == 0)
|
||||
return DOM::IndexSizeError::create(global_object(), "Width and height must not be zero");
|
||||
return WebIDL::IndexSizeError::create(global_object(), "Width and height must not be zero");
|
||||
|
||||
// 2. If the CanvasRenderingContext2D's origin-clean flag is set to false, then throw a "SecurityError" DOMException.
|
||||
if (!m_origin_clean)
|
||||
return DOM::SecurityError::create(global_object(), "CanvasRenderingContext2D is not origin-clean");
|
||||
return WebIDL::SecurityError::create(global_object(), "CanvasRenderingContext2D is not origin-clean");
|
||||
|
||||
// 3. Let imageData be a new ImageData object.
|
||||
// 4. Initialize imageData given sw, sh, settings set to settings, and defaultColorSpace set to this's color space.
|
||||
|
@ -497,7 +497,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
|
|||
[](JS::Handle<HTMLCanvasElement> const& canvas_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
|
||||
// If image has either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException.
|
||||
if (canvas_element->width() == 0 || canvas_element->height() == 0)
|
||||
return DOM::InvalidStateError::create(canvas_element->global_object(), "Canvas width or height is zero");
|
||||
return WebIDL::InvalidStateError::create(canvas_element->global_object(), "Canvas width or height is zero");
|
||||
return Optional<CanvasImageSourceUsability> {};
|
||||
}));
|
||||
if (usability.has_value())
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
#include <LibWeb/Bindings/LocationObject.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -78,7 +78,7 @@ JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS:
|
|||
return JS::PropertyDescriptor { .value = JS::js_undefined(), .writable = false, .enumerable = false, .configurable = true };
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(DOM::SecurityError::create(vm.current_realm()->global_object(), String::formatted("Can't access property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(vm.current_realm()->global_object(), String::formatted("Can't access property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 7.2.3.3 IsPlatformObjectSameOrigin ( O ), https://html.spec.whatwg.org/multipage/browsers.html#isplatformobjectsameorigin-(-o-)
|
||||
|
@ -196,7 +196,7 @@ JS::ThrowCompletionOr<JS::Value> cross_origin_get(JS::VM& vm, JS::Object const&
|
|||
|
||||
// 6. If getter is undefined, then throw a "SecurityError" DOMException.
|
||||
if (!getter.has_value())
|
||||
return throw_completion(DOM::SecurityError::create(vm.current_realm()->global_object(), String::formatted("Can't get property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(vm.current_realm()->global_object(), String::formatted("Can't get property '{}' on cross-origin object", property_key)));
|
||||
|
||||
// 7. Return ? Call(getter, Receiver).
|
||||
return JS::call(vm, *getter, receiver);
|
||||
|
@ -222,7 +222,7 @@ JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM& vm, JS::Object& object, JS:
|
|||
}
|
||||
|
||||
// 4. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(DOM::SecurityError::create(vm.current_realm()->global_object(), String::formatted("Can't set property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(vm.current_realm()->global_object(), String::formatted("Can't set property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 7.2.3.7 CrossOriginOwnPropertyKeys ( O ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginownpropertykeys-(-o-)
|
||||
|
|
|
@ -126,7 +126,7 @@ WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String c
|
|||
if (current_character == '-' && character_index + 1 < name.length()) {
|
||||
auto next_character = name[character_index + 1];
|
||||
if (is_ascii_lower_alpha(next_character))
|
||||
return DOM::SyntaxError::create(global_object(), "Name cannot contain a '-' followed by a lowercase character.");
|
||||
return WebIDL::SyntaxError::create(global_object(), "Name cannot contain a '-' followed by a lowercase character.");
|
||||
}
|
||||
|
||||
// 2. For each ASCII upper alpha in name, insert a U+002D HYPHEN-MINUS character (-) before the character and replace the character with the same character converted to ASCII lowercase.
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/IDLEventListener.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
|
@ -24,6 +23,7 @@
|
|||
#include <LibWeb/UIEvents/EventNames.h>
|
||||
#include <LibWeb/UIEvents/FocusEvent.h>
|
||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -104,7 +104,7 @@ WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(String const& conten
|
|||
set_attribute(HTML::AttributeNames::contenteditable, "false");
|
||||
return {};
|
||||
}
|
||||
return DOM::SyntaxError::create(global_object(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'");
|
||||
return WebIDL::SyntaxError::create(global_object(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'");
|
||||
}
|
||||
|
||||
void HTMLElement::set_inner_text(StringView text)
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/HTML/HTMLOptGroupElement.h>
|
||||
#include <LibWeb/HTML/HTMLOptionElement.h>
|
||||
#include <LibWeb/HTML/HTMLOptionsCollection.h>
|
||||
#include <LibWeb/HTML/HTMLSelectElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -40,11 +40,11 @@ WebIDL::ExceptionOr<void> HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement
|
|||
|
||||
// 1. If element is an ancestor of the select element on which the HTMLOptionsCollection is rooted, then throw a "HierarchyRequestError" DOMException.
|
||||
if (resolved_element->is_ancestor_of(root()))
|
||||
return DOM::HierarchyRequestError::create(global_object(), "The provided element is an ancestor of the root select element.");
|
||||
return WebIDL::HierarchyRequestError::create(global_object(), "The provided element is an ancestor of the root select element.");
|
||||
|
||||
// 2. If before is an element, but that element isn't a descendant of the select element on which the HTMLOptionsCollection is rooted, then throw a "NotFoundError" DOMException.
|
||||
if (before_element && !before_element->is_descendant_of(root()))
|
||||
return DOM::NotFoundError::create(global_object(), "The 'before' element is not a descendant of the root select element.");
|
||||
return WebIDL::NotFoundError::create(global_object(), "The 'before' element is not a descendant of the root select element.");
|
||||
|
||||
// 3. If element and before are the same element, then return.
|
||||
if (before_element && (resolved_element.ptr() == before_element.ptr()))
|
||||
|
|
|
@ -103,7 +103,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement*
|
|||
VERIFY(thead);
|
||||
|
||||
if (thead->local_name() != TagNames::thead)
|
||||
return DOM::HierarchyRequestError::create(global_object(), "Element is not thead");
|
||||
return WebIDL::HierarchyRequestError::create(global_object(), "Element is not thead");
|
||||
|
||||
// FIXME: The spec requires deleting the current thead if thead is null
|
||||
// Currently the wrapper generator doesn't send us a nullable value
|
||||
|
@ -190,7 +190,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_foot(HTMLTableSectionElement*
|
|||
VERIFY(tfoot);
|
||||
|
||||
if (tfoot->local_name() != TagNames::tfoot)
|
||||
return DOM::HierarchyRequestError::create(global_object(), "Element is not tfoot");
|
||||
return WebIDL::HierarchyRequestError::create(global_object(), "Element is not tfoot");
|
||||
|
||||
// FIXME: The spec requires deleting the current tfoot if tfoot is null
|
||||
// Currently the wrapper generator doesn't send us a nullable value
|
||||
|
@ -286,7 +286,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableElement::ins
|
|||
auto rows_length = rows->length();
|
||||
|
||||
if (index < -1 || index > (long)rows_length) {
|
||||
return DOM::IndexSizeError::create(global_object(), "Index is negative or greater than the number of rows");
|
||||
return WebIDL::IndexSizeError::create(global_object(), "Index is negative or greater than the number of rows");
|
||||
}
|
||||
auto& tr = static_cast<HTMLTableRowElement&>(*DOM::create_element(document(), TagNames::tr, Namespace::HTML));
|
||||
if (rows_length == 0 && !has_child_of_type<HTMLTableRowElement>()) {
|
||||
|
@ -313,7 +313,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::delete_row(long index)
|
|||
|
||||
// 1. If index is less than −1 or greater than or equal to the number of elements in the rows collection, then throw an "IndexSizeError" DOMException.
|
||||
if (index < -1 || index >= (long)rows_length)
|
||||
return DOM::IndexSizeError::create(global_object(), "Index is negative or greater than or equal to the number of rows");
|
||||
return WebIDL::IndexSizeError::create(global_object(), "Index is negative or greater than or equal to the number of rows");
|
||||
|
||||
// 2. If index is −1, then remove the last element in the rows collection from its parent, or do nothing if the rows collection is empty.
|
||||
if (index == -1) {
|
||||
|
|
|
@ -43,7 +43,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableSectionEleme
|
|||
|
||||
// 1. If index is less than −1 or greater than the number of elements in the rows collection, throw an "IndexSizeError" DOMException.
|
||||
if (index < -1 || index > rows_collection_size)
|
||||
return DOM::IndexSizeError::create(global_object(), "Index is negative or greater than the number of rows");
|
||||
return WebIDL::IndexSizeError::create(global_object(), "Index is negative or greater than the number of rows");
|
||||
|
||||
// 2. Let table row be the result of creating an element given this element's node document, tr, and the HTML namespace.
|
||||
auto& table_row = static_cast<HTMLTableRowElement&>(*DOM::create_element(document(), TagNames::tr, Namespace::HTML));
|
||||
|
@ -67,7 +67,7 @@ WebIDL::ExceptionOr<void> HTMLTableSectionElement::delete_row(long index)
|
|||
|
||||
// 1. If index is less than −1 or greater than or equal to the number of elements in the rows collection, then throw an "IndexSizeError" DOMException.
|
||||
if (index < -1 || index >= rows_collection_size)
|
||||
return DOM::IndexSizeError::create(global_object(), "Index is negative or greater than or equal to the number of rows");
|
||||
return WebIDL::IndexSizeError::create(global_object(), "Index is negative or greater than or equal to the number of rows");
|
||||
|
||||
// 2. If index is −1, then remove the last element in the rows collection from this element, or do nothing if the rows collection is empty.
|
||||
if (index == -1) {
|
||||
|
|
|
@ -50,7 +50,7 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value,
|
|||
|
||||
// 2. If document is not fully active, then throw a "SecurityError" DOMException.
|
||||
if (!m_associated_document->is_fully_active())
|
||||
return DOM::SecurityError::create(global_object(), "Cannot perform pushState or replaceState on a document that isn't fully active.");
|
||||
return WebIDL::SecurityError::create(global_object(), "Cannot perform pushState or replaceState on a document that isn't fully active.");
|
||||
|
||||
// 3. Optionally, return. (For example, the user agent might disallow calls to these methods that are invoked on a timer,
|
||||
// or from event listeners that are not triggered in response to a clear user action, or that are invoked in rapid succession.)
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -124,7 +124,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
|
|||
dbgln("network error");
|
||||
|
||||
// 2. Throw a "NetworkError" DOMException.
|
||||
return throw_completion(DOM::NetworkError::create(settings.global_object(), "Script error."));
|
||||
return throw_completion(WebIDL::NetworkError::create(settings.global_object(), "Script error."));
|
||||
}
|
||||
|
||||
// 3. Otherwise, rethrow errors is false. Perform the following steps:
|
||||
|
|
|
@ -1075,7 +1075,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::btoa)
|
|||
byte_string.ensure_capacity(string.length());
|
||||
for (u32 code_point : Utf8View(string)) {
|
||||
if (code_point > 0xff)
|
||||
return throw_completion(DOM::InvalidCharacterError::create(vm.current_realm()->global_object(), "Data contains characters outside the range U+0000 and U+00FF"));
|
||||
return throw_completion(WebIDL::InvalidCharacterError::create(vm.current_realm()->global_object(), "Data contains characters outside the range U+0000 and U+00FF"));
|
||||
byte_string.append(code_point);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/PropertyDescriptor.h>
|
||||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
|
||||
#include <LibWeb/HTML/CrossOrigin/Reporting.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -90,7 +90,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_ge
|
|||
return Optional<JS::PropertyDescriptor> {};
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(DOM::SecurityError::create(window(), String::formatted("Can't access property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(window(), String::formatted("Can't access property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 6. Return PropertyDescriptor{ [[Value]]: value, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true }.
|
||||
|
@ -140,7 +140,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_define_own_property(JS::Proper
|
|||
}
|
||||
|
||||
// 3. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(DOM::SecurityError::create(window(), String::formatted("Can't define property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(window(), String::formatted("Can't define property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 7.4.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-get
|
||||
|
@ -213,7 +213,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_delete(JS::PropertyKey const&
|
|||
}
|
||||
|
||||
// 3. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(DOM::SecurityError::create(window(), String::formatted("Can't delete property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(window(), String::formatted("Can't delete property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 7.4.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-ownpropertykeys
|
||||
|
|
|
@ -63,7 +63,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(FlyString const& sc
|
|||
// 4. If this fails, throw a "SyntaxError" DOMException.
|
||||
if (!url.is_valid()) {
|
||||
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", script_url);
|
||||
return DOM::SyntaxError::create(document.global_object(), "url is not valid");
|
||||
return WebIDL::SyntaxError::create(document.global_object(), "url is not valid");
|
||||
}
|
||||
|
||||
// 5. Let worker URL be the resulting URL record.
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/WorkerGlobalScopePrototype.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
|
@ -18,6 +17,7 @@
|
|||
#include <LibWeb/HTML/WorkerGlobalScope.h>
|
||||
#include <LibWeb/HTML/WorkerLocation.h>
|
||||
#include <LibWeb/HTML/WorkerNavigator.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -131,7 +131,7 @@ WebIDL::ExceptionOr<String> WorkerGlobalScope::btoa(String const& data) const
|
|||
byte_string.ensure_capacity(data.length());
|
||||
for (u32 code_point : Utf8View(data)) {
|
||||
if (code_point > 0xff)
|
||||
return DOM::InvalidCharacterError::create(global_object(), "Data contains characters outside the range U+0000 and U+00FF");
|
||||
return WebIDL::InvalidCharacterError::create(global_object(), "Data contains characters outside the range U+0000 and U+00FF");
|
||||
byte_string.append(code_point);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ WebIDL::ExceptionOr<String> WorkerGlobalScope::atob(String const& data) const
|
|||
|
||||
// 2. If decodedData is failure, then throw an "InvalidCharacterError" DOMException.
|
||||
if (decoded_data.is_error())
|
||||
return DOM::InvalidCharacterError::create(global_object(), "Input string is not valid base64 data");
|
||||
return WebIDL::InvalidCharacterError::create(global_object(), "Input string is not valid base64 data");
|
||||
|
||||
// 3. Return decodedData.
|
||||
// decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue