mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
LibWeb: Port DOMException interface from DeprecatedString to String
This commit is contained in:
parent
bcb6851c07
commit
41928c2902
65 changed files with 296 additions and 296 deletions
|
@ -1104,7 +1104,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 WebIDL::SecurityError::create(source_browsing_context.active_document()->realm(), "Source browsing context not allowed to navigate"sv);
|
||||
return WebIDL::SecurityError::create(source_browsing_context.active_document()->realm(), "Source browsing context not allowed to navigate"_fly_string);
|
||||
}
|
||||
|
||||
// FIXME: 2. Otherwise, the user agent may instead offer to open resource in a new top-level browsing context
|
||||
|
|
|
@ -48,17 +48,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 WebIDL::IndexSizeError::create(m_self->realm(), DeprecatedString::formatted("The radius provided ({}) is negative.", radius));
|
||||
return WebIDL::IndexSizeError::create(m_self->realm(), MUST(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 WebIDL::IndexSizeError::create(m_self->realm(), DeprecatedString::formatted("The major-axis radius provided ({}) is negative.", radius_x));
|
||||
return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The major-axis radius provided ({}) is negative.", radius_x)));
|
||||
|
||||
if (radius_y < 0)
|
||||
return WebIDL::IndexSizeError::create(m_self->realm(), DeprecatedString::formatted("The minor-axis radius provided ({}) is negative.", radius_y));
|
||||
return WebIDL::IndexSizeError::create(m_self->realm(), MUST(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)) {
|
||||
|
|
|
@ -17,9 +17,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> CanvasGradient::create_rad
|
|||
{
|
||||
// If either of r0 or r1 are negative, then an "IndexSizeError" DOMException must be thrown.
|
||||
if (r0 < 0)
|
||||
return WebIDL::IndexSizeError::create(realm, "The r0 passed is less than 0");
|
||||
return WebIDL::IndexSizeError::create(realm, "The r0 passed is less than 0"_fly_string);
|
||||
if (r1 < 0)
|
||||
return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0");
|
||||
return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"_fly_string);
|
||||
|
||||
auto radial_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1));
|
||||
return realm.heap().allocate<CanvasGradient>(realm, realm, *radial_gradient);
|
||||
|
@ -58,14 +58,14 @@ WebIDL::ExceptionOr<void> CanvasGradient::add_color_stop(double offset, StringVi
|
|||
{
|
||||
// 1. If the offset is less than 0 or greater than 1, then throw an "IndexSizeError" DOMException.
|
||||
if (offset < 0 || offset > 1)
|
||||
return WebIDL::IndexSizeError::create(realm(), "CanvasGradient color stop offset out of bounds");
|
||||
return WebIDL::IndexSizeError::create(realm(), "CanvasGradient color stop offset out of bounds"_fly_string);
|
||||
|
||||
// 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 WebIDL::SyntaxError::create(realm(), "Could not parse color for CanvasGradient");
|
||||
return WebIDL::SyntaxError::create(realm(), "Could not parse color for CanvasGradient"_fly_string);
|
||||
|
||||
// 4. Place a new stop on the gradient, at offset offset relative to the whole gradient, and with the color parsed color.
|
||||
TRY_OR_THROW_OOM(realm().vm(), m_gradient->add_color_stop(offset, parsed_color.value()));
|
||||
|
|
|
@ -119,7 +119,7 @@ WebIDL::ExceptionOr<JS::GCPtr<CanvasPattern>> CanvasPattern::create(JS::Realm& r
|
|||
// then throw a "SyntaxError" DOMException.
|
||||
auto repetition_value = parse_repetition(repetition);
|
||||
if (!repetition_value.has_value())
|
||||
return WebIDL::SyntaxError::create(realm, "Repetition value is not valid");
|
||||
return WebIDL::SyntaxError::create(realm, "Repetition value is not valid"_fly_string);
|
||||
|
||||
// Note: Bitmap won't be null here, as if it were it would have "bad" usability.
|
||||
auto const& bitmap = *image.visit([](auto const& source) -> Gfx::Bitmap const* { return source->bitmap(); });
|
||||
|
|
|
@ -320,11 +320,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 WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero"_fly_string);
|
||||
|
||||
// 2. If the CanvasRenderingContext2D's origin-clean flag is set to false, then throw a "SecurityError" DOMException.
|
||||
if (!m_origin_clean)
|
||||
return WebIDL::SecurityError::create(realm(), "CanvasRenderingContext2D is not origin-clean");
|
||||
return WebIDL::SecurityError::create(realm(), "CanvasRenderingContext2D is not origin-clean"_fly_string);
|
||||
|
||||
// 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.
|
||||
|
@ -572,7 +572,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 WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero");
|
||||
return WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero"_fly_string);
|
||||
return Optional<CanvasImageSourceUsability> {};
|
||||
}));
|
||||
if (usability.has_value())
|
||||
|
|
|
@ -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(WebIDL::SecurityError::create(*vm.current_realm(), DeprecatedString::formatted("Can't access property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), MUST(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-)
|
||||
|
@ -205,7 +205,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(WebIDL::SecurityError::create(*vm.current_realm(), DeprecatedString::formatted("Can't get property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), MUST(String::formatted("Can't get property '{}' on cross-origin object", property_key))));
|
||||
|
||||
// 7. Return ? Call(getter, Receiver).
|
||||
return JS::call(vm, *getter, receiver);
|
||||
|
@ -231,7 +231,7 @@ JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM& vm, JS::Object& object, JS:
|
|||
}
|
||||
|
||||
// 4. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), DeprecatedString::formatted("Can't set property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), MUST(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-)
|
||||
|
|
|
@ -112,7 +112,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
|
||||
// 2. If name is not a valid custom element name, then throw a "SyntaxError" DOMException.
|
||||
if (!is_valid_custom_element_name(name))
|
||||
return JS::throw_completion(WebIDL::SyntaxError::create(realm, DeprecatedString::formatted("'{}' is not a valid custom element name"sv, name)));
|
||||
return JS::throw_completion(WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name"sv, name))));
|
||||
|
||||
// 3. If this CustomElementRegistry contains an entry with name name, then throw a "NotSupportedError" DOMException.
|
||||
auto existing_definition_with_name_iterator = m_custom_element_definitions.find_if([&name](JS::Handle<CustomElementDefinition> const& definition) {
|
||||
|
@ -120,7 +120,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
});
|
||||
|
||||
if (existing_definition_with_name_iterator != m_custom_element_definitions.end())
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("A custom element with name '{}' is already defined"sv, name)));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("A custom element with name '{}' is already defined"sv, name))));
|
||||
|
||||
// 4. If this CustomElementRegistry contains an entry with constructor constructor, then throw a "NotSupportedError" DOMException.
|
||||
auto existing_definition_with_constructor_iterator = m_custom_element_definitions.find_if([&constructor](JS::Handle<CustomElementDefinition> const& definition) {
|
||||
|
@ -128,7 +128,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
});
|
||||
|
||||
if (existing_definition_with_constructor_iterator != m_custom_element_definitions.end())
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "The given constructor is already in use by another custom element"sv));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "The given constructor is already in use by another custom element"_fly_string));
|
||||
|
||||
// 5. Let localName be name.
|
||||
String local_name = name;
|
||||
|
@ -140,11 +140,11 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
if (extends.has_value()) {
|
||||
// 1. If extends is a valid custom element name, then throw a "NotSupportedError" DOMException.
|
||||
if (is_valid_custom_element_name(extends.value()))
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("'{}' is a custom element name, only non-custom elements can be extended"sv, extends.value())));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("'{}' is a custom element name, only non-custom elements can be extended"sv, extends.value()))));
|
||||
|
||||
// 2. If the element interface for extends and the HTML namespace is HTMLUnknownElement (e.g., if extends does not indicate an element definition in this specification), then throw a "NotSupportedError" DOMException.
|
||||
if (DOM::is_unknown_html_element(extends.value().to_deprecated_string()))
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("'{}' is an unknown HTML element"sv, extends.value())));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("'{}' is an unknown HTML element"sv, extends.value()))));
|
||||
|
||||
// 3. Set localName to extends.
|
||||
local_name = extends.value();
|
||||
|
@ -152,7 +152,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
|
||||
// 8. If this CustomElementRegistry's element definition is running flag is set, then throw a "NotSupportedError" DOMException.
|
||||
if (m_element_definition_is_running)
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"sv));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"_fly_string));
|
||||
|
||||
// 9. Set this CustomElementRegistry's element definition is running flag.
|
||||
m_element_definition_is_running = true;
|
||||
|
@ -334,7 +334,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> CustomElementRegistry::when_d
|
|||
// 1. If name is not a valid custom element name, then return a new promise rejected with a "SyntaxError" DOMException.
|
||||
if (!is_valid_custom_element_name(name)) {
|
||||
auto promise = JS::Promise::create(realm);
|
||||
promise->reject(WebIDL::SyntaxError::create(realm, DeprecatedString::formatted("'{}' is not a valid custom element name"sv, name)));
|
||||
promise->reject(WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name"sv, name))));
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(Deprecat
|
|||
if (current_character == '-' && character_index + 1 < name.length()) {
|
||||
auto next_character = name[character_index + 1];
|
||||
if (is_ascii_lower_alpha(next_character))
|
||||
return WebIDL::SyntaxError::create(realm(), "Name cannot contain a '-' followed by a lowercase character.");
|
||||
return WebIDL::SyntaxError::create(realm(), "Name cannot contain a '-' followed by a lowercase character."_fly_string);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -119,7 +119,7 @@ WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(StringView content_e
|
|||
MUST(set_attribute(HTML::AttributeNames::contenteditable, "false"));
|
||||
return {};
|
||||
}
|
||||
return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'");
|
||||
return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'"_fly_string);
|
||||
}
|
||||
|
||||
void HTMLElement::set_inner_text(StringView text)
|
||||
|
|
|
@ -223,7 +223,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::show_picker()
|
|||
|
||||
// 1. If this is not mutable, then throw an "InvalidStateError" DOMException.
|
||||
if (!m_is_mutable)
|
||||
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"sv);
|
||||
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_fly_string);
|
||||
|
||||
// 2. If this's relevant settings object's origin is not same origin with this's relevant settings object's top-level origin,
|
||||
// and this's type attribute is not in the File Upload state or Color state, then throw a "SecurityError" DOMException.
|
||||
|
@ -231,14 +231,14 @@ WebIDL::ExceptionOr<void> HTMLInputElement::show_picker()
|
|||
// and has never been guarded by an origin check.
|
||||
if (!relevant_settings_object(*this).origin().is_same_origin(relevant_settings_object(*this).top_level_origin)
|
||||
&& m_type != TypeAttributeState::FileUpload && m_type != TypeAttributeState::Color) {
|
||||
return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"_fly_string);
|
||||
}
|
||||
|
||||
// 3. If this's relevant global object does not have transient activation, then throw a "NotAllowedError" DOMException.
|
||||
// FIXME: The global object we get here should probably not need casted to Window to check for transient activation
|
||||
auto& global_object = relevant_global_object(*this);
|
||||
if (!is<HTML::Window>(global_object) || !static_cast<HTML::Window&>(global_object).has_transient_activation()) {
|
||||
return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"sv);
|
||||
return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"_fly_string);
|
||||
}
|
||||
|
||||
// 4. Show the picker, if applicable, for this.
|
||||
|
@ -342,7 +342,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_value(String const& value)
|
|||
if (type_state() == TypeAttributeState::FileUpload) {
|
||||
// On setting, if the new value is the empty string, empty the list of selected files; otherwise, throw an "InvalidStateError" DOMException.
|
||||
if (!value.is_empty())
|
||||
return WebIDL::InvalidStateError::create(realm(), "Setting value of input type file to non-empty string"sv);
|
||||
return WebIDL::InvalidStateError::create(realm(), "Setting value of input type file to non-empty string"_fly_string);
|
||||
m_selected_files = nullptr;
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> HTMLMediaElement::play()
|
|||
// 2. If the media element's error attribute is not null and its code is MEDIA_ERR_SRC_NOT_SUPPORTED, then return a promise
|
||||
// rejected with a "NotSupportedError" DOMException.
|
||||
if (m_error && m_error->code() == MediaError::Code::SrcNotSupported) {
|
||||
auto error = WebIDL::NotSupportedError::create(realm, m_error->message().to_deprecated_string());
|
||||
auto error = WebIDL::NotSupportedError::create(realm, m_error->message());
|
||||
auto promise = WebIDL::create_rejected_promise(realm, error);
|
||||
|
||||
return JS::NonnullGCPtr { verify_cast<JS::Promise>(*promise->promise()) };
|
||||
|
@ -396,7 +396,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::set_volume(double volume)
|
|||
// set to the new value. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an
|
||||
// "IndexSizeError" DOMException must be thrown instead.
|
||||
if (volume < 0.0 || volume > 1.0)
|
||||
return WebIDL::IndexSizeError::create(realm(), "Volume must be in the range 0.0 to 1.0, inclusive"sv);
|
||||
return WebIDL::IndexSizeError::create(realm(), "Volume must be in the range 0.0 to 1.0, inclusive"_fly_string);
|
||||
|
||||
m_volume = volume;
|
||||
volume_or_muted_attribute_changed();
|
||||
|
|
|
@ -197,7 +197,7 @@ private:
|
|||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
auto error = ErrorType::create(realm, message.to_deprecated_fly_string());
|
||||
auto error = ErrorType::create(realm, message);
|
||||
reject_pending_play_promises(promises, error);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,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 WebIDL::HierarchyRequestError::create(realm(), "The provided element is an ancestor of the root select element.");
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "The provided element is an ancestor of the root select element."_fly_string);
|
||||
|
||||
// 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 WebIDL::NotFoundError::create(realm(), "The 'before' element is not a descendant of the root select element.");
|
||||
return WebIDL::NotFoundError::create(realm(), "The 'before' element is not a descendant of the root select element."_fly_string);
|
||||
|
||||
// 3. If element and before are the same element, then return.
|
||||
if (before_element && (resolved_element.ptr() == before_element.ptr()))
|
||||
|
|
|
@ -153,7 +153,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement*
|
|||
{
|
||||
// If the new value is neither null nor a thead element, then a "HierarchyRequestError" DOMException must be thrown instead.
|
||||
if (thead && thead->local_name() != TagNames::thead)
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Element is not thead");
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Element is not thead"_fly_string);
|
||||
|
||||
// On setting, if the new value is null or a thead element, the first thead element child of the table element,
|
||||
// if any, must be removed,
|
||||
|
@ -251,7 +251,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_foot(HTMLTableSectionElement*
|
|||
{
|
||||
// If the new value is neither null nor a tfoot element, then a "HierarchyRequestError" DOMException must be thrown instead.
|
||||
if (tfoot && tfoot->local_name() != TagNames::tfoot)
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Element is not tfoot");
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Element is not tfoot"_fly_string);
|
||||
|
||||
// On setting, if the new value is null or a tfoot element, the first tfoot element child of the table element,
|
||||
// if any, must be removed,
|
||||
|
@ -363,7 +363,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableElement::ins
|
|||
auto rows_length = rows->length();
|
||||
|
||||
if (index < -1 || index > (long)rows_length) {
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_fly_string);
|
||||
}
|
||||
auto& tr = static_cast<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
|
||||
if (rows_length == 0 && !has_child_of_type<HTMLTableRowElement>()) {
|
||||
|
@ -390,7 +390,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 WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"_fly_string);
|
||||
|
||||
// 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) {
|
||||
|
|
|
@ -129,7 +129,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableCellElement>> HTMLTableRowElement:
|
|||
|
||||
// 1. If index is less than −1 or greater than the number of elements in the cells collection, then throw an "IndexSizeError" DOMException.
|
||||
if (index < -1 || index > cells_collection_size)
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells"_fly_string);
|
||||
|
||||
// 2. Let table cell be the result of creating an element given this tr element's node document, td, and the HTML namespace.
|
||||
auto& table_cell = static_cast<HTMLTableCellElement&>(*TRY(DOM::create_element(document(), HTML::TagNames::td, Namespace::HTML)));
|
||||
|
@ -154,7 +154,7 @@ WebIDL::ExceptionOr<void> HTMLTableRowElement::delete_cell(i32 index)
|
|||
|
||||
// 1. If index is less than −1 or greater than or equal to the number of elements in the cells collection, then throw an "IndexSizeError" DOMException.
|
||||
if (index < -1 || index >= cells_collection_size)
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of cells");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of cells"_fly_string);
|
||||
|
||||
// 2. If index is −1, then remove the last element in the cells collection from its parent, or do nothing if the cells collection is empty.
|
||||
if (index == -1) {
|
||||
|
|
|
@ -54,7 +54,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 WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_fly_string);
|
||||
|
||||
// 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&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
|
||||
|
@ -78,7 +78,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 WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows");
|
||||
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"_fly_string);
|
||||
|
||||
// 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) {
|
||||
|
|
|
@ -55,7 +55,7 @@ WebIDL::ExceptionOr<u64> History::length() const
|
|||
{
|
||||
// 1. If this's associated Document is not fully active, then throw a "SecurityError" DOMException.
|
||||
if (!m_associated_document->is_fully_active())
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."_fly_string);
|
||||
|
||||
// 2. Return the number of entries in the top-level browsing context's joint session history.
|
||||
auto const* browsing_context = m_associated_document->browsing_context();
|
||||
|
@ -72,7 +72,7 @@ WebIDL::ExceptionOr<void> History::go(long delta = 0)
|
|||
|
||||
// 2. If document is not fully active, then throw a "SecurityError" DOMException.
|
||||
if (!m_associated_document->is_fully_active())
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."_fly_string);
|
||||
|
||||
// 3. If delta is 0, then act as if the location.reload() method was called, and return.
|
||||
auto* browsing_context = m_associated_document->browsing_context();
|
||||
|
@ -157,7 +157,7 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value v
|
|||
|
||||
// 2. If document is not fully active, then throw a "SecurityError" DOMException.
|
||||
if (!document->is_fully_active())
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform pushState or replaceState on a document that isn't fully active."sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot perform pushState or replaceState on a document that isn't fully active."_fly_string);
|
||||
|
||||
// 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.)
|
||||
|
@ -178,14 +178,14 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value v
|
|||
|
||||
// 2. If that fails, then throw a "SecurityError" DOMException.
|
||||
if (!parsed_url.is_valid())
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_fly_string);
|
||||
|
||||
// 3. Set newURL to the resulting URL record.
|
||||
new_url = parsed_url;
|
||||
|
||||
// 4. If document cannot have its URL rewritten to newURL, then throw a "SecurityError" DOMException.
|
||||
if (!can_have_its_url_rewritten(document, new_url))
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_fly_string);
|
||||
}
|
||||
|
||||
// FIXME: 7. Let navigation be history's relevant global object's navigation API.
|
||||
|
|
|
@ -108,7 +108,7 @@ WebIDL::ExceptionOr<String> Location::href() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 2. Return this's url, serialized.
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize()));
|
||||
|
@ -144,7 +144,7 @@ WebIDL::ExceptionOr<String> Location::origin() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 2. Return the serialization of this's url's origin.
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_origin()));
|
||||
|
@ -158,7 +158,7 @@ WebIDL::ExceptionOr<String> Location::protocol() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 2. Return this's url's scheme, followed by ":".
|
||||
return TRY_OR_THROW_OOM(vm, String::formatted("{}:", url().scheme()));
|
||||
|
@ -178,7 +178,7 @@ WebIDL::ExceptionOr<String> Location::host() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 2. Let url be this's url.
|
||||
auto url = this->url();
|
||||
|
@ -209,7 +209,7 @@ WebIDL::ExceptionOr<String> Location::hostname() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
auto url = this->url();
|
||||
|
||||
|
@ -235,7 +235,7 @@ WebIDL::ExceptionOr<String> Location::port() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
auto url = this->url();
|
||||
|
||||
|
@ -261,7 +261,7 @@ WebIDL::ExceptionOr<String> Location::pathname() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 2. Return the result of URL path serializing this Location object's url.
|
||||
return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_path()));
|
||||
|
@ -281,7 +281,7 @@ WebIDL::ExceptionOr<String> Location::search() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
auto url = this->url();
|
||||
|
||||
|
@ -307,7 +307,7 @@ WebIDL::ExceptionOr<String> Location::hash() const
|
|||
// 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
auto const relevant_document = this->relevant_document();
|
||||
if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
auto url = this->url();
|
||||
|
||||
|
@ -331,7 +331,7 @@ WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
|
|||
|
||||
// 2. If this's relevant Document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
if (!relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 3. Let copyURL be a copy of this's url.
|
||||
auto copy_url = this->url();
|
||||
|
@ -381,12 +381,12 @@ WebIDL::ExceptionOr<void> Location::assign(String const& url) const
|
|||
|
||||
// 2. If this's relevant Document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
if (!relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
|
||||
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string);
|
||||
|
||||
// 3. Parse url relative to the entry settings object. If that failed, throw a "SyntaxError" DOMException.
|
||||
auto assign_url = entry_settings_object().parse_url(url);
|
||||
if (!assign_url.is_valid())
|
||||
return WebIDL::SyntaxError::create(realm(), DeprecatedString::formatted("Invalid URL '{}'", url));
|
||||
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url)));
|
||||
|
||||
// 4. Location-object navigate this to the resulting URL record.
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
|
@ -469,7 +469,7 @@ JS::ThrowCompletionOr<bool> Location::internal_define_own_property(JS::PropertyK
|
|||
}
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(realm(), DeprecatedString::formatted("Can't define property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(realm(), MUST(String::formatted("Can't define property '{}' on cross-origin object", property_key))));
|
||||
}
|
||||
|
||||
// 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get
|
||||
|
@ -506,7 +506,7 @@ JS::ThrowCompletionOr<bool> Location::internal_delete(JS::PropertyKey const& pro
|
|||
return JS::Object::internal_delete(property_key);
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(realm(), DeprecatedString::formatted("Can't delete property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(realm(), MUST(String::formatted("Can't delete property '{}' on cross-origin object", property_key))));
|
||||
}
|
||||
|
||||
// 7.10.5.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-ownpropertykeys
|
||||
|
|
|
@ -842,7 +842,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(
|
|||
if (!source_document->navigable()->allowed_by_sandboxing_to_navigate(*this, source_snapshot_params)) {
|
||||
// 1. If exceptionsEnabled is true, then throw a "SecurityError" DOMException.
|
||||
if (exceptions_enabled) {
|
||||
return WebIDL::SecurityError::create(realm, "Source document's node navigable is not allowed to navigate"sv);
|
||||
return WebIDL::SecurityError::create(realm, "Source document's node navigable is not allowed to navigate"_fly_string);
|
||||
}
|
||||
|
||||
// 2 Return.
|
||||
|
|
|
@ -72,11 +72,11 @@ WebIDL::ExceptionOr<void> NavigateEvent::intercept(NavigationInterceptOptions co
|
|||
|
||||
// 2. If this's canIntercept attribute was initialized to false, then throw a "SecurityError" DOMException.
|
||||
if (!m_can_intercept)
|
||||
return WebIDL::SecurityError::create(realm, "NavigateEvent cannot be intercepted");
|
||||
return WebIDL::SecurityError::create(realm, "NavigateEvent cannot be intercepted"_fly_string);
|
||||
|
||||
// 3. If this's dispatch flag is unset, then throw an "InvalidStateError" DOMException.
|
||||
if (!this->dispatched())
|
||||
return WebIDL::InvalidStateError::create(realm, "NavigationEvent is not dispatched yet");
|
||||
return WebIDL::InvalidStateError::create(realm, "NavigationEvent is not dispatched yet"_fly_string);
|
||||
|
||||
// 4. Assert: this's interception state is either "none" or "intercepted".
|
||||
VERIFY(m_interception_state == InterceptionState::None || m_interception_state == InterceptionState::Intercepted);
|
||||
|
@ -130,7 +130,7 @@ WebIDL::ExceptionOr<void> NavigateEvent::scroll()
|
|||
|
||||
// 2. If this's interception state is not "committed", then throw an "InvalidStateError" DOMException.
|
||||
if (m_interception_state != InterceptionState::Committed)
|
||||
return WebIDL::InvalidStateError::create(realm(), "Cannot scroll NavigationEvent that is not committed");
|
||||
return WebIDL::InvalidStateError::create(realm(), "Cannot scroll NavigationEvent that is not committed"_fly_string);
|
||||
|
||||
// 3. Process scroll behavior given this.
|
||||
process_scroll_behavior();
|
||||
|
@ -147,15 +147,15 @@ WebIDL::ExceptionOr<void> NavigateEvent::perform_shared_checks()
|
|||
// then throw an "InvalidStateError" DOMException.
|
||||
auto& associated_document = verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document();
|
||||
if (!associated_document.is_fully_active())
|
||||
return WebIDL::InvalidStateError::create(realm(), "Document is not fully active");
|
||||
return WebIDL::InvalidStateError::create(realm(), "Document is not fully active"_fly_string);
|
||||
|
||||
// 2. If event's isTrusted attribute was initialized to false, then throw a "SecurityError" DOMException.
|
||||
if (!this->is_trusted())
|
||||
return WebIDL::SecurityError::create(realm(), "NavigateEvent is not trusted");
|
||||
return WebIDL::SecurityError::create(realm(), "NavigateEvent is not trusted"_fly_string);
|
||||
|
||||
// 3. If event's canceled flag is set, then throw an "InvalidStateError" DOMException.
|
||||
if (this->cancelled())
|
||||
return WebIDL::InvalidStateError::create(realm(), "NavigateEvent already cancelled");
|
||||
return WebIDL::InvalidStateError::create(realm(), "NavigateEvent already cancelled"_fly_string);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ WebIDL::ExceptionOr<void> Navigation::update_current_entry(NavigationUpdateCurre
|
|||
|
||||
// 2. If current is null, then throw an "InvalidStateError" DOMException.
|
||||
if (current == nullptr)
|
||||
return WebIDL::InvalidStateError::create(realm(), "Cannot update current NavigationHistoryEntry when there is no current entry"sv);
|
||||
return WebIDL::InvalidStateError::create(realm(), "Cannot update current NavigationHistoryEntry when there is no current entry"_fly_string);
|
||||
|
||||
// 3. Let serializedState be StructuredSerializeForStorage(options["state"]), rethrowing any exceptions.
|
||||
auto serialized_state = TRY(structured_serialize_for_storage(vm(), options.state));
|
||||
|
@ -210,7 +210,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::navigate(String url, Navigatio
|
|||
// Otherwise, let urlRecord be the resulting URL record.
|
||||
auto url_record = relevant_settings_object(*this).parse_url(url);
|
||||
if (!url_record.is_valid())
|
||||
return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL"));
|
||||
return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL"_fly_string));
|
||||
|
||||
// 2. Let document be this's relevant global object's associated Document.
|
||||
auto& document = verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document();
|
||||
|
@ -218,7 +218,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::navigate(String url, Navigatio
|
|||
// 3. If options["history"] is "push", and the navigation must be a replace given urlRecord and document,
|
||||
// then return an early error result for a "NotSupportedError" DOMException.
|
||||
if (options.history == Bindings::NavigationHistoryBehavior::Push && navigation_must_be_a_replace(url_record, document))
|
||||
return early_error_result(WebIDL::NotSupportedError::create(realm, "Navigation must be a replace, but push was requested"));
|
||||
return early_error_result(WebIDL::NotSupportedError::create(realm, "Navigation must be a replace, but push was requested"_fly_string));
|
||||
|
||||
// 4. Let state be options["state"], if it exists; otherwise, undefined.
|
||||
auto state = options.state.value_or(JS::js_undefined());
|
||||
|
@ -237,11 +237,11 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::navigate(String url, Navigatio
|
|||
|
||||
// 6. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (!document.is_fully_active())
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_fly_string));
|
||||
|
||||
// 7. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (document.unload_counter() > 0)
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_fly_string));
|
||||
|
||||
// 8. Let info be options["info"], if it exists; otherwise, undefined.
|
||||
auto info = options.info.value_or(JS::js_undefined());
|
||||
|
@ -270,7 +270,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::navigate(String url, Navigatio
|
|||
// that upcoming API method tracker to ongoing.
|
||||
if (m_upcoming_non_traverse_api_method_tracker == api_method_tracker) {
|
||||
m_upcoming_non_traverse_api_method_tracker = nullptr;
|
||||
return early_error_result(WebIDL::AbortError::create(realm, "Navigation aborted"));
|
||||
return early_error_result(WebIDL::AbortError::create(realm, "Navigation aborted"_fly_string));
|
||||
}
|
||||
|
||||
// 12. Return a navigation API method tracker-derived result for apiMethodTracker.
|
||||
|
@ -313,11 +313,11 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::reload(NavigationReloadOptions
|
|||
|
||||
// 5. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (!document.is_fully_active())
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_fly_string));
|
||||
|
||||
// 6. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (document.unload_counter() > 0)
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_fly_string));
|
||||
|
||||
// 7. Let info be options["info"], if it exists; otherwise, undefined.
|
||||
auto info = options.info.value_or(JS::js_undefined());
|
||||
|
@ -341,7 +341,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::traverse_to(String key, Naviga
|
|||
|
||||
// 1. If this's current entry index is −1, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (m_current_entry_index == -1)
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: no current session history entry"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: no current session history entry"_fly_string));
|
||||
|
||||
// 2. If this's entry list does not contain a NavigationHistoryEntry whose session history entry's navigation API key equals key,
|
||||
// then return an early error result for an "InvalidStateError" DOMException.
|
||||
|
@ -349,7 +349,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::traverse_to(String key, Naviga
|
|||
return entry->session_history_entry().navigation_api_key == key;
|
||||
});
|
||||
if (it == m_entry_list.end())
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: key not found in session history list"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: key not found in session history list"_fly_string));
|
||||
|
||||
// 3. Return the result of performing a navigation API traversal given this, key, and options.
|
||||
return perform_a_navigation_api_traversal(key, options);
|
||||
|
@ -363,7 +363,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::back(NavigationOptions const&
|
|||
|
||||
// 1. If this's current entry index is −1 or 0, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (m_current_entry_index == -1 || m_current_entry_index == 0)
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate back: no previous session history entry"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate back: no previous session history entry"_fly_string));
|
||||
|
||||
// 2. Let key be this's entry list[this's current entry index − 1]'s session history entry's navigation API key.
|
||||
auto key = m_entry_list[m_current_entry_index - 1]->session_history_entry().navigation_api_key;
|
||||
|
@ -381,7 +381,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::forward(NavigationOptions cons
|
|||
// 1. If this's current entry index is −1 or is equal to this's entry list's size − 1,
|
||||
// then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (m_current_entry_index == -1 || m_current_entry_index == static_cast<i64>(m_entry_list.size() - 1))
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate forward: no next session history entry"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate forward: no next session history entry"_fly_string));
|
||||
|
||||
// 2. Let key be this's entry list[this's current entry index + 1]'s session history entry's navigation API key.
|
||||
auto key = m_entry_list[m_current_entry_index + 1]->session_history_entry().navigation_api_key;
|
||||
|
@ -610,11 +610,11 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
|
|||
|
||||
// 2. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (!document.is_fully_active())
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_fly_string));
|
||||
|
||||
// 3. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException.
|
||||
if (document.unload_counter() > 0)
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"));
|
||||
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_fly_string));
|
||||
|
||||
// 4. Let current be the current entry of navigation.
|
||||
auto current = current_entry();
|
||||
|
@ -666,7 +666,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
|
|||
queue_global_task(HTML::Task::Source::NavigationAndTraversal, relevant_global_object(*this), [this, api_method_tracker] {
|
||||
auto& reject_realm = relevant_realm(*this);
|
||||
WebIDL::reject_promise(reject_realm, api_method_tracker->finished_promise,
|
||||
WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"));
|
||||
WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"_fly_string));
|
||||
});
|
||||
|
||||
// 2. Abort these steps.
|
||||
|
|
|
@ -118,7 +118,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, JS::GCPtr<JS::En
|
|||
settings.clean_up_after_running_script();
|
||||
|
||||
// 2. Throw a "NetworkError" DOMException.
|
||||
return throw_completion(WebIDL::NetworkError::create(settings.realm(), "Script error."));
|
||||
return throw_completion(WebIDL::NetworkError::create(settings.realm(), "Script error."_fly_string));
|
||||
}
|
||||
|
||||
// 3. Otherwise, rethrow errors is false. Perform the following steps:
|
||||
|
|
|
@ -143,7 +143,7 @@ JS::Promise* JavaScriptModuleScript::run(PreventErrorReporting)
|
|||
// then set evaluationPromise to a promise rejected with a new "QuotaExceededError" DOMException.
|
||||
if (elevation_promise_or_error.is_error()) {
|
||||
auto promise = JS::Promise::create(settings_object().realm());
|
||||
promise->reject(WebIDL::QuotaExceededError::create(settings_object().realm(), "Failed to evaluate module script").ptr());
|
||||
promise->reject(WebIDL::QuotaExceededError::create(settings_object().realm(), "Failed to evaluate module script"_fly_string).ptr());
|
||||
|
||||
evaluation_promise = promise;
|
||||
} else {
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
|
||||
// 5. If Type(value) is Symbol, then throw a "DataCloneError" DOMException.
|
||||
if (value.is_symbol())
|
||||
return WebIDL::DataCloneError::create(*m_vm.current_realm(), "Cannot serialize Symbol"sv);
|
||||
return WebIDL::DataCloneError::create(*m_vm.current_realm(), "Cannot serialize Symbol"_fly_string);
|
||||
|
||||
// 6. Let serialized be an uninitialized value.
|
||||
// NOTE: We use the range of the soon-to-be-serialized value in our serialized data buffer
|
||||
|
@ -173,7 +173,7 @@ public:
|
|||
|
||||
// 12 - 24: FIXME: Serialize other data types
|
||||
else {
|
||||
return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Unsupported type"sv));
|
||||
return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Unsupported type"_fly_string));
|
||||
}
|
||||
|
||||
// 25. Set memory[value] to serialized.
|
||||
|
@ -302,7 +302,7 @@ public:
|
|||
break;
|
||||
}
|
||||
default:
|
||||
m_error = "Unsupported type"sv;
|
||||
m_error = "Unsupported type"_fly_string;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -311,16 +311,16 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<JS::Value> result()
|
||||
{
|
||||
if (m_error.is_null())
|
||||
if (!m_error.has_value())
|
||||
return m_memory[0];
|
||||
return WebIDL::DataCloneError::create(*m_vm.current_realm(), m_error);
|
||||
return WebIDL::DataCloneError::create(*m_vm.current_realm(), m_error.value());
|
||||
}
|
||||
|
||||
private:
|
||||
JS::VM& m_vm;
|
||||
SerializationRecord const& m_vector;
|
||||
JS::MarkedVector<JS::Value> m_memory; // Index -> JS value
|
||||
StringView m_error;
|
||||
Optional<FlyString> m_error;
|
||||
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::PrimitiveString>> deserialize_string_primitive(JS::VM& vm, Vector<u32> const& vector, u32& position)
|
||||
{
|
||||
|
|
|
@ -363,7 +363,7 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
|
|||
if (!url.is_empty()) {
|
||||
url_record = entry_settings_object().parse_url(url);
|
||||
if (!url_record.is_valid())
|
||||
return WebIDL::SyntaxError::create(realm(), "URL is not valid");
|
||||
return WebIDL::SyntaxError::create(realm(), "URL is not valid"_fly_string);
|
||||
}
|
||||
|
||||
// FIXME: 5. If urlRecord matches about:blank, then perform the URL and history update steps given target browsing context's active document and urlRecord.
|
||||
|
@ -393,7 +393,7 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
|
|||
// 2. Parse url relative to the entry settings object, and set urlRecord to the resulting URL record, if any. If the parse a URL algorithm failed, then throw a "SyntaxError" DOMException.
|
||||
url_record = entry_settings_object().parse_url(url);
|
||||
if (!url_record.is_valid())
|
||||
return WebIDL::SyntaxError::create(realm(), "URL is not valid");
|
||||
return WebIDL::SyntaxError::create(realm(), "URL is not valid"_fly_string);
|
||||
|
||||
// 3. Let request be a new request whose URL is urlRecord.
|
||||
auto request = Fetch::Infrastructure::Request::create(vm);
|
||||
|
|
|
@ -96,7 +96,7 @@ WebIDL::ExceptionOr<String> WindowOrWorkerGlobalScopeMixin::btoa(String const& d
|
|||
byte_string.ensure_capacity(data.bytes().size());
|
||||
for (u32 code_point : Utf8View(data)) {
|
||||
if (code_point > 0xff)
|
||||
return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF");
|
||||
return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF"_fly_string);
|
||||
byte_string.append(code_point);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ WebIDL::ExceptionOr<String> WindowOrWorkerGlobalScopeMixin::atob(String const& d
|
|||
|
||||
// 2. If decodedData is failure, then throw an "InvalidCharacterError" DOMException.
|
||||
if (decoded_data.is_error())
|
||||
return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data");
|
||||
return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data"_fly_string);
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -95,7 +95,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_ge
|
|||
return Optional<JS::PropertyDescriptor> {};
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(m_window->realm(), DeprecatedString::formatted("Can't access property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(m_window->realm(), MUST(String::formatted("Can't access property '{}' on cross-origin object", property_key))));
|
||||
}
|
||||
|
||||
// 6. Return PropertyDescriptor{ [[Value]]: value, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true }.
|
||||
|
@ -145,7 +145,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_define_own_property(JS::Proper
|
|||
}
|
||||
|
||||
// 3. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(m_window->realm(), DeprecatedString::formatted("Can't define property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(m_window->realm(), MUST(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
|
||||
|
@ -218,7 +218,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_delete(JS::PropertyKey const&
|
|||
}
|
||||
|
||||
// 3. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(m_window->realm(), DeprecatedString::formatted("Can't delete property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(m_window->realm(), MUST(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
|
||||
|
|
|
@ -51,7 +51,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(String const& scrip
|
|||
{
|
||||
// NOTE: We don't start a worker because they're not properly implemented yet and would likely crash.
|
||||
dbgln("FIXME: Implement web workers");
|
||||
return WebIDL::NotSupportedError::create(document.realm(), "Web workers not supported yet");
|
||||
return WebIDL::NotSupportedError::create(document.realm(), "Web workers not supported yet"_fly_string);
|
||||
|
||||
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url);
|
||||
|
||||
|
@ -75,7 +75,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(String const& scrip
|
|||
// 4. If this fails, throw a "SyntaxError" DOMException.
|
||||
if (!url.is_valid()) {
|
||||
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", script_url);
|
||||
return WebIDL::SyntaxError::create(document.realm(), "url is not valid");
|
||||
return WebIDL::SyntaxError::create(document.realm(), "url is not valid"_fly_string);
|
||||
}
|
||||
|
||||
// 5. Let worker URL be the resulting URL record.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue