LibJS+LibWeb: Port interned bytecode strings to UTF-16

This was almost a no-op, except we intern JS exception messages. So the
bulk of this patch is porting exception messages to UTF-16.
This commit is contained in:
Timothy Flynn 2025-08-07 19:31:52 -04:00 committed by Jelle Raaijmakers
parent cf61171864
commit 70db474cf0
162 changed files with 1405 additions and 1422 deletions

View File

@ -444,8 +444,8 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> StringLiteral::generate
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> RegExpLiteral::generate_bytecode(Bytecode::Generator& generator, Optional<ScopedOperand> preferred_dst) const
{
Bytecode::Generator::SourceLocationScope scope(generator, *this);
auto source_index = generator.intern_string(m_pattern.to_utf8_but_should_be_ported_to_utf16());
auto flags_index = generator.intern_string(m_flags.to_utf8_but_should_be_ported_to_utf16());
auto source_index = generator.intern_string(m_pattern);
auto flags_index = generator.intern_string(m_flags);
auto regex_index = generator.intern_regex(Bytecode::ParsedRegex {
.regex = m_parsed_regex,
.pattern = m_parsed_pattern,
@ -1770,7 +1770,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> CallExpression::generat
Optional<Bytecode::StringTableIndex> expression_string_index;
if (auto expression_string = this->expression_string(); expression_string.has_value())
expression_string_index = generator.intern_string(expression_string->to_utf8_but_should_be_ported_to_utf16());
expression_string_index = generator.intern_string(expression_string.release_value());
bool has_spread = any_of(arguments(), [](auto& argument) { return argument.is_spread; });
auto dst = choose_dst(generator, preferred_dst);

View File

@ -98,7 +98,7 @@ public:
Optional<IdentifierTableIndex> length_identifier;
String const& get_string(StringTableIndex index) const { return string_table->get(index); }
Utf16String const& get_string(StringTableIndex index) const { return string_table->get(index); }
Utf16FlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
Optional<Utf16FlyString const&> get_identifier(Optional<IdentifierTableIndex> const& index) const

View File

@ -202,7 +202,7 @@ public:
return m_current_basic_block->is_terminated();
}
StringTableIndex intern_string(String string)
StringTableIndex intern_string(Utf16String string)
{
return m_string_table->insert(move(string));
}

View File

@ -2264,8 +2264,8 @@ void NewRegExp::execute_impl(Bytecode::Interpreter& interpreter) const
new_regexp(
interpreter.vm(),
interpreter.current_executable().regex_table->get(m_regex_index),
Utf16String::from_utf8(interpreter.current_executable().get_string(m_source_index)),
Utf16String::from_utf8(interpreter.current_executable().get_string(m_flags_index))));
interpreter.current_executable().get_string(m_source_index),
interpreter.current_executable().get_string(m_flags_index)));
}
#define JS_DEFINE_NEW_BUILTIN_ERROR_OP(ErrorName) \

View File

@ -8,13 +8,13 @@
namespace JS::Bytecode {
StringTableIndex StringTable::insert(String string)
StringTableIndex StringTable::insert(Utf16String string)
{
m_strings.append(move(string));
return { static_cast<u32>(m_strings.size() - 1) };
}
String const& StringTable::get(StringTableIndex index) const
Utf16String const& StringTable::get(StringTableIndex index) const
{
return m_strings[index.value];
}

View File

@ -7,7 +7,7 @@
#pragma once
#include <AK/DistinctNumeric.h>
#include <AK/String.h>
#include <AK/Utf16String.h>
#include <AK/Vector.h>
namespace JS::Bytecode {
@ -25,13 +25,13 @@ class StringTable {
public:
StringTable() = default;
StringTableIndex insert(String);
String const& get(StringTableIndex) const;
StringTableIndex insert(Utf16String);
Utf16String const& get(StringTableIndex) const;
void dump() const;
bool is_empty() const { return m_strings.is_empty(); }
private:
Vector<String> m_strings;
Vector<Utf16String> m_strings;
};
}

View File

@ -1802,8 +1802,8 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
// a. If options is not an Object, then
if (!options.is_object()) {
// i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::NotAnObject.message(), "options"sv)));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::NotAnObject, "options"sv);
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// ii. Return promiseCapability.[[Promise]].
return promise_capability->promise();
@ -1818,8 +1818,8 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
// i. If attributesObj is not an Object, then
if (!attributes_obj.is_object()) {
// 1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::NotAnObject.message(), "with"sv)));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::NotAnObject, "with"sv);
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// 2. Return promiseCapability.[[Promise]].
return promise_capability->promise();
@ -1842,8 +1842,8 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
// a. If value is not a String, then
if (!value.is_string()) {
// i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::NotAString.message(), "Import attribute value"sv)));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::NotAnObject, "Import attribute value"sv);
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// ii. Return promiseCapability.[[Promise]].
return promise_capability->promise();
@ -1858,8 +1858,8 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
// e. If AllImportAttributesSupported(attributes) is false, then
if (!all_import_attributes_supported(vm, attributes)) {
// i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::ImportAttributeUnsupported.message())));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::ImportAttributeUnsupported);
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// ii. Return promiseCapability.[[Promise]].
return promise_capability->promise();

View File

@ -322,7 +322,7 @@ struct YearWeek {
// 14.5.1.1 ToIntegerIfIntegral ( argument ), https://tc39.es/proposal-temporal/#sec-tointegerifintegral
template<typename... Args>
ThrowCompletionOr<double> to_integer_if_integral(VM& vm, Value argument, ErrorType error_type, Args&&... args)
ThrowCompletionOr<double> to_integer_if_integral(VM& vm, Value argument, ErrorType const& error_type, Args&&... args)
{
// 1. Let number be ? ToNumber(argument).
auto number = TRY(argument.to_number(vm));

View File

@ -115,8 +115,8 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncDisposableStackPrototype::dispose_async)
// 3. If asyncDisposableStack does not have an [[AsyncDisposableState]] internal slot, then
if (!async_disposable_stack_value.is_object() || !is<AsyncDisposableStack>(async_disposable_stack_value.as_object())) {
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::NotAnObjectOfType.message(), display_name())));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, display_name());
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// b. Return promiseCapability.[[Promise]].
return promise_capability->promise();

View File

@ -181,9 +181,9 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::return_)
// 12. If Type(result) is not Object, then
if (!result.is_object()) {
auto error = TypeError::create(realm, TRY_OR_THROW_OOM(vm, String::formatted(ErrorType::NotAnObject.message(), "SyncIteratorReturnResult")));
auto error = vm.throw_completion<TypeError>(ErrorType::NotAnObject, "SyncIteratorReturnResult");
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// b. Return promiseCapability.[[Promise]].
return promise_capability->promise();
@ -230,8 +230,8 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::throw_)
// f. NOTE: If closing syncIterator does not throw then the result of that operation is ignored, even if it yields a rejected promise.
// g. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::IsUndefined.message(), "throw method")));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::IsUndefined, "throw method");
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// h. Return promiseCapability.[[Promise]].
return promise_capability->promise();
@ -249,8 +249,8 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::throw_)
// 12. If result is not an Object, then
if (!result.is_object()) {
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
auto error = TypeError::create(realm, MUST(String::formatted(ErrorType::NotAnObject.message(), "SyncIteratorThrowResult")));
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
auto error = vm.throw_completion<TypeError>(ErrorType::NotAnObject, "SyncIteratorThrowResult");
MUST(call(vm, *promise_capability->reject(), js_undefined(), error.value()));
// b. Return promiseCapability.[[Promise]].
return promise_capability->promise();

View File

@ -39,7 +39,7 @@ GC::Ref<Error> Error::create(Realm& realm)
return realm.create<Error>(realm.intrinsics().error_prototype());
}
GC::Ref<Error> Error::create(Realm& realm, String message)
GC::Ref<Error> Error::create(Realm& realm, Utf16String message)
{
auto error = Error::create(realm);
error->set_message(move(message));
@ -48,7 +48,7 @@ GC::Ref<Error> Error::create(Realm& realm, String message)
GC::Ref<Error> Error::create(Realm& realm, StringView message)
{
return create(realm, MUST(String::from_utf8(message)));
return create(realm, Utf16String::from_utf8(message));
}
Error::Error(Object& prototype)
@ -75,7 +75,7 @@ ThrowCompletionOr<void> Error::install_error_cause(Value options)
return {};
}
void Error::set_message(String message)
void Error::set_message(Utf16String message)
{
auto& vm = this->vm();
@ -169,7 +169,7 @@ String Error::stack_string(CompactTraceback compact) const
return realm.create<ClassName>(realm.intrinsics().snake_name##_prototype()); \
} \
\
GC::Ref<ClassName> ClassName::create(Realm& realm, String message) \
GC::Ref<ClassName> ClassName::create(Realm& realm, Utf16String message) \
{ \
auto error = ClassName::create(realm); \
error->set_message(move(message)); \
@ -178,7 +178,7 @@ String Error::stack_string(CompactTraceback compact) const
\
GC::Ref<ClassName> ClassName::create(Realm& realm, StringView message) \
{ \
return create(realm, MUST(String::from_utf8(message))); \
return create(realm, Utf16String::from_utf8(message)); \
} \
\
ClassName::ClassName(Object& prototype) \

View File

@ -9,6 +9,7 @@
#include <AK/FlyString.h>
#include <AK/String.h>
#include <AK/Utf16String.h>
#include <LibJS/Export.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
@ -34,7 +35,7 @@ class JS_API Error : public Object {
public:
static GC::Ref<Error> create(Realm&);
static GC::Ref<Error> create(Realm&, String message);
static GC::Ref<Error> create(Realm&, Utf16String message);
static GC::Ref<Error> create(Realm&, StringView message);
virtual ~Error() override = default;
@ -43,7 +44,7 @@ public:
ThrowCompletionOr<void> install_error_cause(Value options);
void set_message(String);
void set_message(Utf16String);
Vector<TracebackFrame, 32> const& traceback() const { return m_traceback; }
@ -70,7 +71,7 @@ inline bool Object::fast_is<Error>() const { return is_error_object(); }
\
public: \
static GC::Ref<ClassName> create(Realm&); \
static GC::Ref<ClassName> create(Realm&, String message); \
static GC::Ref<ClassName> create(Realm&, Utf16String message); \
static GC::Ref<ClassName> create(Realm&, StringView message); \
\
explicit ClassName(Object& prototype); \

View File

@ -53,7 +53,7 @@ ThrowCompletionOr<GC::Ref<Object>> ErrorConstructor::construct(FunctionObject& n
// 3. If message is not undefined, then
if (!message.is_undefined()) {
// a. Let msg be ? ToString(message).
auto msg = TRY(message.to_string(vm));
auto msg = TRY(message.to_utf16_string(vm));
// b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg)));
@ -107,7 +107,7 @@ ThrowCompletionOr<GC::Ref<Object>> ErrorConstructor::construct(FunctionObject& n
/* 3. If message is not undefined, then */ \
if (!message.is_undefined()) { \
/* a. Let msg be ? ToString(message). */ \
auto msg = TRY(message.to_string(vm)); \
auto msg = TRY(message.to_utf16_string(vm)); \
\
/* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \
error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg))); \

View File

@ -27,7 +27,7 @@ void ErrorPrototype::initialize(Realm& realm)
Base::initialize(realm);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"_string), attr);
define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr);
define_direct_property(vm.names.message, PrimitiveString::create(vm, Utf16String {}), attr);
define_native_function(realm, vm.names.toString, to_string, 0, attr);
// Non standard property "stack"
// Every other engine seems to have this in some way or another, and the spec
@ -55,8 +55,8 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
// 6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
auto message = message_property.is_undefined()
? String {}
: TRY(message_property.to_string(vm));
? Utf16String {}
: TRY(message_property.to_utf16_string(vm));
// 7. If name is the empty String, return msg.
if (name.is_empty())
@ -92,9 +92,9 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_getter)
else
name = "Error"_string;
String message {};
Utf16String message {};
if (auto message_property = TRY(error.get(vm.names.message)); !message_property.is_undefined())
message = TRY(message_property.to_string(vm));
message = TRY(message_property.to_utf16_string(vm));
auto header = message.is_empty()
? move(name)
@ -138,7 +138,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter)
Base::initialize(realm); \
u8 attr = Attribute::Writable | Attribute::Configurable; \
define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName##_string), attr); \
define_direct_property(vm.names.message, PrimitiveString::create(vm, String {}), attr); \
define_direct_property(vm.names.message, PrimitiveString::create(vm, Utf16String {}), attr); \
}
JS_ENUMERATE_NATIVE_ERRORS

View File

@ -13,4 +13,11 @@ namespace JS {
JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR)
#undef __ENUMERATE_JS_ERROR
Utf16String const& ErrorType::message() const
{
if (m_message.is_empty())
m_message = Utf16String::from_utf8_without_validation(m_format);
return m_message;
}
}

View File

@ -6,8 +6,8 @@
#pragma once
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Utf16String.h>
#include <LibJS/Export.h>
#define JS_ENUMERATE_ERROR_TYPES(M) \
@ -314,18 +314,17 @@ public:
JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR)
#undef __ENUMERATE_JS_ERROR
String message() const
{
return m_message;
}
StringView format() const { return m_format; }
Utf16String const& message() const;
private:
explicit ErrorType(StringView message)
: m_message(MUST(String::from_utf8(message)))
explicit ErrorType(StringView format)
: m_format(format)
{
}
String m_message;
StringView m_format;
mutable Utf16String m_message;
};
}

View File

@ -30,42 +30,42 @@ Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(Utf
switch (ch) {
case 'd':
if (d)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
d = true;
break;
case 'g':
if (g)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
g = true;
options |= regex::ECMAScriptFlags::Global;
break;
case 'i':
if (i)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
i = true;
options |= regex::ECMAScriptFlags::Insensitive;
break;
case 'm':
if (m)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
m = true;
options |= regex::ECMAScriptFlags::Multiline;
break;
case 's':
if (s)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
s = true;
options |= regex::ECMAScriptFlags::SingleLine;
break;
case 'u':
if (u)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
u = true;
options |= regex::ECMAScriptFlags::Unicode;
break;
case 'y':
if (y)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
y = true;
// Now for the more interesting flag, 'sticky' actually unsets 'global', part of which is the default.
options.reset_flag(regex::ECMAScriptFlags::Global);
@ -77,12 +77,12 @@ Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(Utf
break;
case 'v':
if (v)
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectRepeatedFlag.format(), ch));
v = true;
options |= regex::ECMAScriptFlags::UnicodeSets;
break;
default:
return MUST(String::formatted(ErrorType::RegExpObjectBadFlag.message(), ch));
return MUST(String::formatted(ErrorType::RegExpObjectBadFlag.format(), ch));
}
}
@ -93,7 +93,7 @@ Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(Utf
ErrorOr<String, ParseRegexPatternError> parse_regex_pattern(Utf16View const& pattern, bool unicode, bool unicode_sets)
{
if (unicode && unicode_sets)
return ParseRegexPatternError { MUST(String::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v')) };
return ParseRegexPatternError { MUST(String::formatted(ErrorType::RegExpObjectIncompatibleFlags.format(), 'u', 'v')) };
StringBuilder builder;

View File

@ -202,7 +202,7 @@ ThrowCompletionOr<DifferenceSettings> get_difference_settings(VM&, DurationOpera
// 13.39 ToIntegerWithTruncation ( argument ), https://tc39.es/proposal-temporal/#sec-tointegerwithtruncation
template<typename... Args>
ThrowCompletionOr<double> to_integer_with_truncation(VM& vm, Value argument, ErrorType error_type, Args&&... args)
ThrowCompletionOr<double> to_integer_with_truncation(VM& vm, Value argument, ErrorType const& error_type, Args&&... args)
{
// 1. Let number be ? ToNumber(argument).
auto number = TRY(argument.to_number(vm));
@ -219,7 +219,7 @@ ThrowCompletionOr<double> to_integer_with_truncation(VM& vm, Value argument, Err
// AD-HOC: We often need to use this AO when we have a parsed StringView. This overload allows callers to avoid creating
// a PrimitiveString for the primary definition.
template<typename... Args>
ThrowCompletionOr<double> to_integer_with_truncation(VM& vm, StringView argument, ErrorType error_type, Args&&... args)
ThrowCompletionOr<double> to_integer_with_truncation(VM& vm, StringView argument, ErrorType const& error_type, Args&&... args)
{
// 1. Let number be ? ToNumber(argument).
auto number = string_to_number(argument);
@ -234,7 +234,7 @@ ThrowCompletionOr<double> to_integer_with_truncation(VM& vm, StringView argument
// 13.38 ToPositiveIntegerWithTruncation ( argument ), https://tc39.es/proposal-temporal/#sec-topositiveintegerwithtruncation
template<typename... Args>
ThrowCompletionOr<double> to_positive_integer_with_truncation(VM& vm, Value argument, ErrorType error_type, Args&&... args)
ThrowCompletionOr<double> to_positive_integer_with_truncation(VM& vm, Value argument, ErrorType const& error_type, Args&&... args)
{
// 1. Let integer be ? ToIntegerWithTruncation(argument).
auto integer = TRY(to_integer_with_truncation(vm, argument, error_type, args...));

View File

@ -216,7 +216,7 @@ VM::VM(ErrorMessages error_messages)
VM::~VM() = default;
String const& VM::error_message(ErrorMessage type) const
Utf16String const& VM::error_message(ErrorMessage type) const
{
VERIFY(type < ErrorMessage::__Count);

View File

@ -102,7 +102,7 @@ public:
// Keep this last:
__Count,
};
String const& error_message(ErrorMessage) const;
Utf16String const& error_message(ErrorMessage) const;
bool did_reach_stack_space_limit() const
{
@ -216,15 +216,15 @@ public:
}
template<typename T>
Completion throw_completion(ErrorType type)
Completion throw_completion(ErrorType const& type)
{
return throw_completion<T>(String::from_utf8_without_validation(type.message().bytes()));
return throw_completion<T>(type.message());
}
template<typename T, typename... Args>
Completion throw_completion(ErrorType type, Args&&... args)
Completion throw_completion(ErrorType const& type, Args&&... args)
{
return throw_completion<T>(MUST(String::formatted(type.message(), forward<Args>(args)...)));
return throw_completion<T>(Utf16String::formatted(type.format(), forward<Args>(args)...));
}
Value get_new_target();
@ -303,7 +303,7 @@ public:
Vector<StackTraceElement> stack_trace() const;
private:
using ErrorMessages = AK::Array<String, to_underlying(ErrorMessage::__Count)>;
using ErrorMessages = AK::Array<Utf16String, to_underlying(ErrorMessage::__Count)>;
struct WellKnownSymbols {
#define __JS_ENUMERATE(SymbolName, snake_name) \

View File

@ -434,7 +434,7 @@ void Animation::cancel(ShouldInvalidate should_invalidate)
reset_an_animations_pending_tasks();
// 2. Reject the current finished promise with a DOMException named "AbortError".
auto dom_exception = WebIDL::AbortError::create(realm, "Animation was cancelled"_string);
auto dom_exception = WebIDL::AbortError::create(realm, "Animation was cancelled"_utf16);
WebIDL::reject_promise(realm, current_finished_promise(), dom_exception);
// 3. Set the [[PromiseIsHandled]] internal slot of the current finished promise to true.
@ -494,9 +494,9 @@ WebIDL::ExceptionOr<void> Animation::finish()
// effect end is infinity, throw an "InvalidStateError" DOMException and abort these steps.
auto effective_playback_rate = this->effective_playback_rate();
if (effective_playback_rate == 0.0)
return WebIDL::InvalidStateError::create(realm(), "Animation with a playback rate of 0 cannot be finished"_string);
return WebIDL::InvalidStateError::create(realm(), "Animation with a playback rate of 0 cannot be finished"_utf16);
if (effective_playback_rate > 0.0 && isinf(associated_effect_end()))
return WebIDL::InvalidStateError::create(realm(), "Animation with no end cannot be finished"_string);
return WebIDL::InvalidStateError::create(realm(), "Animation with no end cannot be finished"_utf16);
// 2. Apply any pending playback rate to animation.
apply_any_pending_playback_rate();
@ -595,7 +595,7 @@ WebIDL::ExceptionOr<void> Animation::play_an_animation(AutoRewind auto_rewind)
// -> If associated effect end is positive infinity,
if (isinf(associated_effect_end) && associated_effect_end > 0.0) {
// throw an "InvalidStateError" DOMException and abort these steps.
return WebIDL::InvalidStateError::create(realm(), "Cannot rewind an animation with an infinite effect end"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot rewind an animation with an infinite effect end"_utf16);
}
// -> Otherwise,
// Set seek time to animations associated effect end.
@ -716,7 +716,7 @@ WebIDL::ExceptionOr<void> Animation::pause()
auto associated_effect_end = this->associated_effect_end();
if (isinf(associated_effect_end) && associated_effect_end > 0.0) {
// throw an "InvalidStateError" DOMException and abort these steps.
return WebIDL::InvalidStateError::create(realm(), "Cannot pause an animation with an infinite effect end"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot pause an animation with an infinite effect end"_utf16);
}
// Otherwise,
@ -842,7 +842,7 @@ WebIDL::ExceptionOr<void> Animation::reverse()
// 1. If there is no timeline associated with animation, or the associated timeline is inactive throw an
// "InvalidStateError" DOMException and abort these steps.
if (!m_timeline || m_timeline->is_inactive())
return WebIDL::InvalidStateError::create(realm, "Cannot reverse an animation with an inactive timeline"_string);
return WebIDL::InvalidStateError::create(realm, "Cannot reverse an animation with an inactive timeline"_utf16);
// 2. Let original pending playback rate be animations pending playback rate.
auto original_pending_playback_rate = m_pending_playback_rate;
@ -1210,7 +1210,7 @@ void Animation::reset_an_animations_pending_tasks()
apply_any_pending_playback_rate();
// 5. Reject animations current ready promise with a DOMException named "AbortError".
auto dom_exception = WebIDL::AbortError::create(realm, "Animation was cancelled"_string);
auto dom_exception = WebIDL::AbortError::create(realm, "Animation was cancelled"_utf16);
WebIDL::reject_promise(realm, current_ready_promise(), dom_exception);
// 6. Set the [[PromiseIsHandled]] internal slot of animations current ready promise to true.

View File

@ -21,7 +21,7 @@ WebIDL::ExceptionOr<Optional<CSS::Selector::PseudoElementSelector>> pseudo_eleme
if (!pseudo_element.has_value()) {
// 1. Throw a DOMException with error name "SyntaxError".
// 2. Abort.
return WebIDL::SyntaxError::create(realm, MUST(String::formatted("Invalid pseudo-element selector: \"{}\"", value.value())));
return WebIDL::SyntaxError::create(realm, Utf16String::formatted("Invalid pseudo-element selector: \"{}\"", value.value()));
}
}

View File

@ -72,12 +72,12 @@ WebIDL::ExceptionOr<void> register_property(JS::VM& vm, PropertyDefinition defin
// 2. If name is not a custom property name string, throw a SyntaxError and exit this algorithm.
if (!is_a_custom_property_name_string(definition.name))
return WebIDL::SyntaxError::create(realm, "Invalid property name"_string);
return WebIDL::SyntaxError::create(realm, "Invalid property name"_utf16);
// If property set already contains an entry with name as its property name (compared codepoint-wise),
// throw an InvalidModificationError and exit this algorithm.
if (document.registered_custom_properties().contains(definition.name))
return WebIDL::InvalidModificationError::create(realm, "Property already registered"_string);
return WebIDL::InvalidModificationError::create(realm, "Property already registered"_utf16);
auto parsing_params = CSS::Parser::ParsingParams { document };
@ -86,7 +86,7 @@ WebIDL::ExceptionOr<void> register_property(JS::VM& vm, PropertyDefinition defin
auto syntax_component_values = parse_component_values_list(parsing_params, definition.syntax);
auto maybe_syntax = parse_as_syntax(syntax_component_values);
if (!maybe_syntax) {
return WebIDL::SyntaxError::create(realm, "Invalid syntax definition"_string);
return WebIDL::SyntaxError::create(realm, "Invalid syntax definition"_utf16);
}
RefPtr<StyleValue const> initial_value_maybe;
@ -104,12 +104,12 @@ WebIDL::ExceptionOr<void> register_property(JS::VM& vm, PropertyDefinition defin
// If this fails, throw a SyntaxError and exit this algorithm.
// Otherwise, let parsed initial value be the parsed result.
if (!initial_value_maybe) {
return WebIDL::SyntaxError::create(realm, "Invalid initial value"_string);
return WebIDL::SyntaxError::create(realm, "Invalid initial value"_utf16);
}
}
} else if (!definition.initial_value.has_value()) {
// Otherwise, if initialValue is not present, throw a SyntaxError and exit this algorithm.
return WebIDL::SyntaxError::create(realm, "Initial value must be provided for non-universal syntax"_string);
return WebIDL::SyntaxError::create(realm, "Initial value must be provided for non-universal syntax"_utf16);
} else {
// Otherwise, parse initialValue according to syntax definition.
auto initial_value_component_values = parse_component_values_list(parsing_params, definition.initial_value.value());
@ -121,7 +121,7 @@ WebIDL::ExceptionOr<void> register_property(JS::VM& vm, PropertyDefinition defin
// If this fails, throw a SyntaxError and exit this algorithm.
if (!initial_value_maybe || initial_value_maybe->is_guaranteed_invalid()) {
return WebIDL::SyntaxError::create(realm, "Invalid initial value"_string);
return WebIDL::SyntaxError::create(realm, "Invalid initial value"_utf16);
}
// Otherwise, let parsed initial value be the parsed result.
// NB: Already done

View File

@ -66,7 +66,7 @@ WebIDL::ExceptionOr<void> CSSDescriptors::set_property(StringView property, Stri
{
// 1. If the readonly flag is set, then throw a NoModificationAllowedError exception.
if (is_readonly())
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties of readonly CSSStyleDeclaration"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties of readonly CSSStyleDeclaration"_utf16);
// 2. If property is not a custom property, follow these substeps:
Optional<DescriptorID> descriptor_id;
@ -132,7 +132,7 @@ WebIDL::ExceptionOr<String> CSSDescriptors::remove_property(StringView property)
{
// 1. If the readonly flag is set, then throw a NoModificationAllowedError exception.
if (is_readonly())
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties of readonly CSSStyleDeclaration"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties of readonly CSSStyleDeclaration"_utf16);
// 2. If property is not a custom property, let property be property converted to ASCII lowercase.
// AD-HOC: We compare names case-insensitively instead.
@ -238,7 +238,7 @@ WebIDL::ExceptionOr<void> CSSDescriptors::set_css_text(StringView value)
{
// 1. If the readonly flag is set, then throw a NoModificationAllowedError exception.
if (is_readonly())
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties of readonly CSSStyleDeclaration"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties of readonly CSSStyleDeclaration"_utf16);
// 2. Empty the declarations.
m_descriptors.clear();

View File

@ -58,7 +58,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// 2. If index is greater than length, then throw an IndexSizeError exception.
if (index > length)
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_string);
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_utf16);
// 3. Set new rule to the results of performing parse a CSS rule on argument rule.
// NOTE: The insert-a-css-rule spec expects `rule` to be a string, but the CSSStyleSheet.insertRule()
@ -86,7 +86,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// - If declarations is empty, throw a SyntaxError exception.
if (declarations.custom_properties.is_empty() && declarations.properties.is_empty())
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS declarations block."_string);
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS declarations block."_utf16);
// - Otherwise, set new rule to a new nested declarations rule with declarations as it contents.
new_rule = CSSNestedDeclarations::create(realm(), CSSStyleProperties::create(realm(), move(declarations.properties), move(declarations.custom_properties)));
@ -94,7 +94,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// 5. If new rule is a syntax error, throw a SyntaxError exception.
if (!new_rule)
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_string);
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_utf16);
auto has_rule_of_type_other_than_specified_before_index = [&](Vector<CSSRule::Type> types, size_t index) {
for (size_t i = 0; i < index; i++) {
@ -138,11 +138,11 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// FIXME: There are more constraints that we should check here - Parser::is_valid_in_the_current_context is probably a good reference for that.
if (rule_is_disallowed || (nested == Nested::Yes && first_is_one_of(new_rule->type(), CSSRule::Type::Import, CSSRule::Type::Namespace)))
return WebIDL::HierarchyRequestError::create(realm(), "Cannot insert rule at specified index."_string);
return WebIDL::HierarchyRequestError::create(realm(), "Cannot insert rule at specified index."_utf16);
// 7. If new rule is an @namespace at-rule, and list contains anything other than @import at-rules, and @namespace at-rules, throw an InvalidStateError exception.
if (new_rule->type() == CSSRule::Type::Namespace && any_of(m_rules, [](auto existing_rule) { return existing_rule->type() != CSSRule::Type::Import && existing_rule->type() != CSSRule::Type::Namespace; }))
return WebIDL::InvalidStateError::create(realm(), "Cannot insert @namespace rule into a stylesheet with non-namespace/import rules"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot insert @namespace rule into a stylesheet with non-namespace/import rules"_utf16);
// 8. Insert new rule into list at the zero-indexed position index.
m_rules.insert(index, *new_rule);
@ -161,7 +161,7 @@ WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
// 2. If index is greater than or equal to length, then throw an IndexSizeError exception.
if (index >= length)
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_string);
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_utf16);
// 3. Set old rule to the indexth item in list.
CSSRule& old_rule = m_rules[index];
@ -170,7 +170,7 @@ WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
if (old_rule.type() == CSSRule::Type::Namespace) {
for (auto& rule : m_rules) {
if (rule->type() != CSSRule::Type::Import && rule->type() != CSSRule::Type::Namespace)
return WebIDL::InvalidStateError::create(realm(), "Cannot remove @namespace rule from a stylesheet with non-namespace/import rules."_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot remove @namespace rule from a stylesheet with non-namespace/import rules."_utf16);
}
}

View File

@ -245,7 +245,7 @@ WebIDL::ExceptionOr<void> CSSStyleProperties::set_property(StringView property_n
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
if (is_computed())
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"_utf16);
// FIXME: 2. If property is not a custom property, follow these substeps:
// FIXME: 1. Let property be property converted to ASCII lowercase.
@ -879,7 +879,7 @@ WebIDL::ExceptionOr<String> CSSStyleProperties::remove_property(StringView prope
{
// 1. If the readonly flag is set, then throw a NoModificationAllowedError exception.
if (is_readonly())
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove property: CSSStyleProperties is read-only."_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove property: CSSStyleProperties is read-only."_utf16);
auto property_id = property_id_from_string(property_name);
if (!property_id.has_value())
@ -1210,7 +1210,7 @@ WebIDL::ExceptionOr<void> CSSStyleProperties::set_css_text(StringView css_text)
{
// 1. If the readonly flag is set, then throw a NoModificationAllowedError exception.
if (is_readonly()) {
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties: CSSStyleProperties is read-only."_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties: CSSStyleProperties is read-only."_utf16);
}
// 2. Empty the declarations.

View File

@ -48,7 +48,7 @@ WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Re
// AD-HOC: This isn't explicitly mentioned in the specification, but multiple modern browsers do this.
Optional<::URL::URL> url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : ::URL::Parser::basic_parse(options->base_url.value());
if (!url.has_value())
return WebIDL::NotAllowedError::create(realm, "Constructed style sheets must have a valid base URL"_string);
return WebIDL::NotAllowedError::create(realm, "Constructed style sheets must have a valid base URL"_utf16);
sheet->set_base_url(url);
}
@ -138,18 +138,18 @@ WebIDL::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsign
// If the disallow modification flag is set, throw a NotAllowedError DOMException.
if (disallow_modification())
return WebIDL::NotAllowedError::create(realm(), "Can't call insert_rule() on non-modifiable stylesheets."_string);
return WebIDL::NotAllowedError::create(realm(), "Can't call insert_rule() on non-modifiable stylesheets."_utf16);
// 3. Let parsed rule be the return value of invoking parse a rule with rule.
auto parsed_rule = parse_css_rule(make_parsing_params(), rule);
// 4. If parsed rule is a syntax error, return parsed rule.
if (!parsed_rule)
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_string);
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_utf16);
// 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException.
if (constructed() && parsed_rule->type() == CSSRule::Type::Import)
return WebIDL::SyntaxError::create(realm(), "Can't insert @import rules into a constructed stylesheet."_string);
return WebIDL::SyntaxError::create(realm(), "Can't insert @import rules into a constructed stylesheet."_utf16);
// 6. Return the result of invoking insert a CSS rule rule in the CSS rules at index.
auto result = m_rules->insert_a_css_rule(parsed_rule, index, CSSRuleList::Nested::No, declared_namespaces());
@ -171,7 +171,7 @@ WebIDL::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
// 2. If the disallow modification flag is set, throw a NotAllowedError DOMException.
if (disallow_modification())
return WebIDL::NotAllowedError::create(realm(), "Can't call delete_rule() on non-modifiable stylesheets."_string);
return WebIDL::NotAllowedError::create(realm(), "Can't call delete_rule() on non-modifiable stylesheets."_utf16);
// 3. Remove a CSS rule in the CSS rules at index.
auto result = m_rules->remove_a_css_rule(index);
@ -191,12 +191,12 @@ GC::Ref<WebIDL::Promise> CSSStyleSheet::replace(String text)
// 2. If the constructed flag is not set, or the disallow modification flag is set, reject promise with a NotAllowedError DOMException and return promise.
if (!constructed()) {
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Can't call replace() on non-constructed stylesheets"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Can't call replace() on non-constructed stylesheets"_utf16));
return promise;
}
if (disallow_modification()) {
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Can't call replace() on non-modifiable stylesheets"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Can't call replace() on non-modifiable stylesheets"_utf16));
return promise;
}
@ -235,9 +235,9 @@ WebIDL::ExceptionOr<void> CSSStyleSheet::replace_sync(StringView text)
{
// 1. If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
if (!constructed())
return WebIDL::NotAllowedError::create(realm(), "Can't call replaceSync() on non-constructed stylesheets"_string);
return WebIDL::NotAllowedError::create(realm(), "Can't call replaceSync() on non-constructed stylesheets"_utf16);
if (disallow_modification())
return WebIDL::NotAllowedError::create(realm(), "Can't call replaceSync() on non-modifiable stylesheets"_string);
return WebIDL::NotAllowedError::create(realm(), "Can't call replaceSync() on non-modifiable stylesheets"_utf16);
// 2. Let rules be the result of running parse a stylesheets contents from text.
auto rules = CSS::Parser::Parser::create(make_parsing_params(), text).parse_as_stylesheet_contents();

View File

@ -80,7 +80,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
auto try_parse_descriptor = [&parsing_params, &font_face, &realm](DescriptorID descriptor_id, String const& string) -> String {
auto result = parse_css_descriptor(parsing_params, AtRuleID::FontFace, descriptor_id, string);
if (!result) {
font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, MUST(String::formatted("FontFace constructor: Invalid {}", to_string(descriptor_id)))));
font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, Utf16String::formatted("FontFace constructor: Invalid {}", to_string(descriptor_id))));
return {};
}
return result->to_string(SerializationMode::Normal);
@ -100,7 +100,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
if (auto* source_string = source.get_pointer<String>()) {
parsed_source = parse_css_descriptor(parsing_params, AtRuleID::FontFace, DescriptorID::Src, *source_string);
if (!parsed_source) {
font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, MUST(String::formatted("FontFace constructor: Invalid {}", to_string(DescriptorID::Src)))));
font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, Utf16String::formatted("FontFace constructor: Invalid {}", to_string(DescriptorID::Src))));
}
}
// Return font face. If font faces status is "error", terminate this algorithm;
@ -126,7 +126,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
}
if (font_face->m_binary_data.is_empty() && font_face->m_urls.is_empty())
font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, "FontFace constructor: Invalid font source"_string));
font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, "FontFace constructor: Invalid font source"_utf16));
// 3. If font faces [[Data]] slot is not null, queue a task to run the following steps synchronously:
if (font_face->m_binary_data.is_empty())
@ -164,7 +164,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
// 2. Otherwise, reject font faces [[FontStatusPromise]] with a DOMException named "SyntaxError"
// and set font faces status attribute to "error".
font->reject_status_promise(WebIDL::SyntaxError::create(font->realm(), MUST(String::formatted("Failed to load font: {}", error))));
font->reject_status_promise(WebIDL::SyntaxError::create(font->realm(), Utf16String::formatted("Failed to load font: {}", error)));
// FIXME: For each FontFaceSet font face is in:
@ -219,7 +219,7 @@ WebIDL::ExceptionOr<void> FontFace::set_family(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontFamily, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.family setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.family setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-family property
@ -239,7 +239,7 @@ WebIDL::ExceptionOr<void> FontFace::set_style(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontStyle, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.style setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.style setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-style property
@ -259,7 +259,7 @@ WebIDL::ExceptionOr<void> FontFace::set_weight(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontWeight, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.weight setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.weight setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-weight property
@ -280,7 +280,7 @@ WebIDL::ExceptionOr<void> FontFace::set_stretch(String const& string)
// NOTE: font-stretch is now an alias for font-width
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontWidth, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.stretch setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.stretch setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -300,7 +300,7 @@ WebIDL::ExceptionOr<void> FontFace::set_unicode_range(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::UnicodeRange, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.unicodeRange setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.unicodeRange setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -320,7 +320,7 @@ WebIDL::ExceptionOr<void> FontFace::set_feature_settings(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontFeatureSettings, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.featureSettings setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.featureSettings setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -340,7 +340,7 @@ WebIDL::ExceptionOr<void> FontFace::set_variation_settings(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontVariationSettings, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.variationSettings setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.variationSettings setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -360,7 +360,7 @@ WebIDL::ExceptionOr<void> FontFace::set_display(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::FontDisplay, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.display setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.display setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -380,7 +380,7 @@ WebIDL::ExceptionOr<void> FontFace::set_ascent_override(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::AscentOverride, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.ascentOverride setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.ascentOverride setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -400,7 +400,7 @@ WebIDL::ExceptionOr<void> FontFace::set_descent_override(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::DescentOverride, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.descentOverride setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.descentOverride setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -420,7 +420,7 @@ WebIDL::ExceptionOr<void> FontFace::set_line_gap_override(String const& string)
auto property = parse_css_descriptor(Parser::ParsingParams(), AtRuleID::FontFace, DescriptorID::LineGapOverride, string);
if (!property)
return WebIDL::SyntaxError::create(realm(), "FontFace.lineGapOverride setter: Invalid descriptor value"_string);
return WebIDL::SyntaxError::create(realm(), "FontFace.lineGapOverride setter: Invalid descriptor value"_utf16);
if (m_is_css_connected) {
// FIXME: Propagate to the CSSFontFaceRule and update the font-width property
@ -458,7 +458,7 @@ GC::Ref<WebIDL::Promise> FontFace::load()
// is "NetworkError" and set font faces status attribute to "error".
if (!maybe_typeface) {
font->m_status = Bindings::FontFaceLoadStatus::Error;
WebIDL::reject_promise(font->realm(), font->m_font_status_promise, WebIDL::NetworkError::create(font->realm(), "Failed to load font"_string));
WebIDL::reject_promise(font->realm(), font->m_font_status_promise, WebIDL::NetworkError::create(font->realm(), "Failed to load font"_utf16));
// FIXME: For each FontFaceSet font face is in:
}

View File

@ -80,7 +80,7 @@ FontFaceSet::add(GC::Root<FontFace> face)
// 2. If font is CSS-connected, throw an InvalidModificationError exception and exit this algorithm immediately.
if (face->is_css_connected()) {
return WebIDL::InvalidModificationError::create(realm(), "Cannot add a CSS-connected FontFace to a FontFaceSet"_string);
return WebIDL::InvalidModificationError::create(realm(), "Cannot add a CSS-connected FontFace to a FontFaceSet"_utf16);
}
// 3. Add the font argument to the FontFaceSets set entries.
@ -176,7 +176,7 @@ static WebIDL::ExceptionOr<GC::Ref<JS::Set>> find_matching_font_faces(JS::Realm&
// 1. Parse font using the CSS value syntax of the font property. If a syntax error occurs, return a syntax error.
auto property = parse_css_value(CSS::Parser::ParsingParams(), font, PropertyID::Font);
if (!property || !property->is_shorthand())
return WebIDL::SyntaxError::create(realm, "Unable to parse font"_string);
return WebIDL::SyntaxError::create(realm, "Unable to parse font"_utf16);
// If the parsed value is a CSS-wide keyword, return a syntax error.
// Note: This case is already caught by the is_shorthand check.

View File

@ -32,7 +32,7 @@ GC::Ref<ScreenOrientation> ScreenOrientation::create(JS::Realm& realm)
// https://w3c.github.io/screen-orientation/#lock-method
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> ScreenOrientation::lock(Bindings::OrientationLockType)
{
return WebIDL::NotSupportedError::create(realm(), "FIXME: ScreenOrientation::lock() is not implemented"_string);
return WebIDL::NotSupportedError::create(realm(), "FIXME: ScreenOrientation::lock() is not implemented"_utf16);
}
// https://w3c.github.io/screen-orientation/#unlock-method

View File

@ -194,7 +194,7 @@ GC::Ref<WebIDL::Promise> Clipboard::read(ClipboardUnsanitizedFormats formats)
// "NotAllowedError" DOMException in realm.
queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(realm.heap(), [&realm, promise]() mutable {
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard reading is only allowed through user activation"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard reading is only allowed through user activation"_utf16));
}));
// 2. Abort these steps.
@ -327,7 +327,7 @@ GC::Ref<WebIDL::Promise> Clipboard::read_text()
// "NotAllowedError" DOMException in realm.
queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(realm.heap(), [&realm, promise]() mutable {
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard reading is only allowed through user activation"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard reading is only allowed through user activation"_utf16));
}));
// 2. Abort these steps.
@ -386,7 +386,7 @@ GC::Ref<WebIDL::Promise> Clipboard::read_text()
}
// 2. Reject p with "NotFoundError" DOMException in realm.
WebIDL::reject_promise(realm, promise, WebIDL::NotFoundError::create(realm, "Did not find a text item in the system clipboard"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotFoundError::create(realm, "Did not find a text item in the system clipboard"_utf16));
}));
}));
}));
@ -415,7 +415,7 @@ GC::Ref<WebIDL::Promise> Clipboard::write(GC::RootVector<GC::Root<ClipboardItem>
// "NotAllowedError" DOMException in realm.
queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(realm.heap(), [&realm, promise]() mutable {
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_utf16));
}));
// 2. Abort these steps.
@ -477,7 +477,7 @@ GC::Ref<WebIDL::Promise> Clipboard::write(GC::RootVector<GC::Root<ClipboardItem>
HTML::TemporaryExecutionContext execution_context { realm };
// 1. Reject p with "NotAllowedError" DOMException in realm.
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, MUST(String::formatted("Writing to the clipboard failed: {}", reason))));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, Utf16String::formatted("Writing to the clipboard failed: {}", reason)));
// 2. Abort these steps.
// NOTE: This is handled below.
@ -506,7 +506,7 @@ GC::Ref<WebIDL::Promise> Clipboard::write(GC::RootVector<GC::Root<ClipboardItem>
// 2. If type is not in the mandatory data types or optional data types list, then reject p with
// "NotAllowedError" DOMException in realm and abort these steps.
if (!ClipboardItem::supports(realm.vm(), type)) {
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, MUST(String::formatted("Clipboard item type {} is not allowed", type))));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, Utf16String::formatted("Clipboard item type {} is not allowed", type)));
return;
}
@ -557,7 +557,7 @@ GC::Ref<WebIDL::Promise> Clipboard::write_text(String data)
// "NotAllowedError" DOMException in realm.
queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(realm.heap(), [&realm, promise]() mutable {
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_utf16));
}));
// 2. Abort these steps.

View File

@ -164,7 +164,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> ClipboardItem::get_type(String con
// 2. If representationDataPromise was rejected, then:
GC::create_function(realm.heap(), [&realm, type, promise](JS::Value) -> WebIDL::ExceptionOr<JS::Value> {
// 1. Reject p with "NotFoundError" DOMException in realm.
WebIDL::reject_promise(realm, promise, WebIDL::NotFoundError::create(realm, MUST(String::formatted("No data found for MIME type: {}", type))));
WebIDL::reject_promise(realm, promise, WebIDL::NotFoundError::create(realm, Utf16String::formatted("No data found for MIME type: {}", type)));
return JS::js_undefined();
}));
@ -175,7 +175,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> ClipboardItem::get_type(String con
}
// 9. Reject p with "NotFoundError" DOMException in realm.
WebIDL::reject_promise(realm, promise, WebIDL::NotFoundError::create(realm, MUST(String::formatted("No data found for MIME type: {}", type))));
WebIDL::reject_promise(realm, promise, WebIDL::NotFoundError::create(realm, Utf16String::formatted("No data found for MIME type: {}", type)));
// 10. Return p.
return promise;

View File

@ -101,7 +101,7 @@ GC::Ref<WebIDL::Promise> CookieStore::get(String name)
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -147,7 +147,7 @@ GC::Ref<WebIDL::Promise> CookieStore::get(CookieStoreGetOptions const& options)
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -226,7 +226,7 @@ GC::Ref<WebIDL::Promise> CookieStore::get_all(String name)
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -267,7 +267,7 @@ GC::Ref<WebIDL::Promise> CookieStore::get_all(CookieStoreGetOptions const& optio
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -488,7 +488,7 @@ GC::Ref<WebIDL::Promise> CookieStore::set(String name, String value)
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -536,7 +536,7 @@ GC::Ref<WebIDL::Promise> CookieStore::set(CookieInit const& options)
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -598,7 +598,7 @@ GC::Ref<WebIDL::Promise> CookieStore::delete_(String name)
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;
@ -641,7 +641,7 @@ GC::Ref<WebIDL::Promise> CookieStore::delete_(CookieStoreDeleteOptions const& op
// 3. If origin is an opaque origin, then return a promise rejected with a "SecurityError" DOMException.
if (origin.is_opaque())
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_string));
return WebIDL::create_rejected_promise(realm, WebIDL::SecurityError::create(realm, "Document origin is opaque"_utf16));
// 4. Let url be settingss creation URL.
auto url = settings.creation_url;

View File

@ -49,21 +49,21 @@ WebIDL::ExceptionOr<GC::Root<WebIDL::ArrayBufferView>> Crypto::get_random_values
{
// 1. If array is not an Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array, then throw a TypeMismatchError and terminate the algorithm.
if (!array->is_typed_array_base())
return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_string);
return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_utf16);
auto const& typed_array = *array->bufferable_object().get<GC::Ref<JS::TypedArrayBase>>();
if (!typed_array.element_name().is_one_of("Int8Array"sv, "Uint8Array"sv, "Uint8ClampedArray"sv, "Int16Array"sv, "Uint16Array"sv, "Int32Array"sv, "Uint32Array"sv, "BigInt64Array"sv, "BigUint64Array"sv))
return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_string);
return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_utf16);
auto typed_array_record = JS::make_typed_array_with_buffer_witness_record(typed_array, JS::ArrayBuffer::Order::SeqCst);
// IMPLEMENTATION DEFINED: If the viewed array buffer is out-of-bounds, throw a InvalidStateError and terminate the algorithm.
if (JS::is_typed_array_out_of_bounds(typed_array_record))
return WebIDL::InvalidStateError::create(realm(), MUST(String::formatted(JS::ErrorType::BufferOutOfBounds.message(), "TypedArray"sv)));
return WebIDL::InvalidStateError::create(realm(), Utf16String::formatted(JS::ErrorType::BufferOutOfBounds.format(), "TypedArray"sv));
// 2. If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm.
if (JS::typed_array_byte_length(typed_array_record) > 65536)
return WebIDL::QuotaExceededError::create(realm(), "array's byteLength may not be greater than 65536"_string);
return WebIDL::QuotaExceededError::create(realm(), "array's byteLength may not be greater than 65536"_utf16);
// 3. Overwrite all elements of array with cryptographically strong random values of the appropriate type.
::Crypto::fill_with_secure_random(array->viewed_array_buffer()->buffer().bytes().slice(array->byte_offset(), array->byte_length()));

File diff suppressed because it is too large Load Diff

View File

@ -303,62 +303,62 @@ public:
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> encrypt(AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "encrypt is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "encrypt is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> decrypt(AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "decrypt is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "decrypt is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> sign(AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "sign is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "sign is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<JS::Value> verify(AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "verify is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "verify is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> digest(AlgorithmParams const&, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "digest is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "digest is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> derive_bits(AlgorithmParams const&, GC::Ref<CryptoKey>, Optional<u32>)
{
return WebIDL::NotSupportedError::create(m_realm, "deriveBits is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "deriveBits is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<CryptoKey>> import_key(AlgorithmParams const&, Bindings::KeyFormat, CryptoKey::InternalKeyData, bool, Vector<Bindings::KeyUsage> const&)
{
return WebIDL::NotSupportedError::create(m_realm, "importKey is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "importKey is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<Variant<GC::Ref<CryptoKey>, GC::Ref<CryptoKeyPair>>> generate_key(AlgorithmParams const&, bool, Vector<Bindings::KeyUsage> const&)
{
return WebIDL::NotSupportedError::create(m_realm, "generateKey is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "generateKey is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::Object>> export_key(Bindings::KeyFormat, GC::Ref<CryptoKey>)
{
return WebIDL::NotSupportedError::create(m_realm, "exportKey is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "exportKey is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<JS::Value> get_key_length(AlgorithmParams const&)
{
return WebIDL::NotSupportedError::create(m_realm, "getKeyLength is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "getKeyLength is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> wrap_key(AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "wrapKey is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "wrapKey is not supported"_utf16);
}
virtual WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> unwrap_key(AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&)
{
return WebIDL::NotSupportedError::create(m_realm, "unwwrapKey is not supported"_string);
return WebIDL::NotSupportedError::create(m_realm, "unwwrapKey is not supported"_utf16);
}
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new AlgorithmMethods(realm)); }

View File

@ -38,7 +38,7 @@ JS::ThrowCompletionOr<JsonWebKey> JsonWebKey::parse(JS::Realm& realm, ReadonlyBy
auto json_value = maybe_json_value.release_value();
if (!json_value.is_object()) {
return vm.throw_completion<WebIDL::SyntaxError>("JSON value is not an object"_string);
return vm.throw_completion<WebIDL::SyntaxError>("JSON value is not an object"_utf16);
}
auto const& json_object = json_value.as_object();
@ -77,7 +77,7 @@ JS::ThrowCompletionOr<JsonWebKey> JsonWebKey::parse(JS::Realm& realm, ReadonlyBy
// 6. If the kty field of key is not defined, then throw a DataError.
if (!key.kty.has_value())
return vm.throw_completion<WebIDL::DataError>("kty field is not defined"_string);
return vm.throw_completion<WebIDL::DataError>("kty field is not defined"_utf16);
// 7. Return key.
return key;

View File

@ -110,7 +110,7 @@ WebIDL::ExceptionOr<NormalizedAlgorithmAndParameter> normalize_an_algorithm(JS::
} else {
// Otherwise:
// Return a new NotSupportedError and terminate this algorithm.
return WebIDL::NotSupportedError::create(realm, MUST(String::formatted("Algorithm '{}' is not supported for operation '{}'", algorithm_name, operation)));
return WebIDL::NotSupportedError::create(realm, Utf16String::formatted("Algorithm '{}' is not supported for operation '{}'", algorithm_name, operation));
}
// 8. Let normalizedAlgorithm be the result of converting the ECMAScript object represented by alg
@ -166,13 +166,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::encrypt(AlgorithmIdentifier const& algori
// 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 9. If the [[usages]] internal slot of key does not contain an entry that is "encrypt", then throw an InvalidAccessError.
if (!key->internal_usages().contains_slow(Bindings::KeyUsage::Encrypt)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support encryption"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support encryption"_utf16));
return;
}
@ -223,13 +223,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::decrypt(AlgorithmIdentifier const& algori
// 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 9. If the [[usages]] internal slot of key does not contain an entry that is "decrypt", then throw an InvalidAccessError.
if (!key->internal_usages().contains_slow(Bindings::KeyUsage::Decrypt)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support encryption"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support encryption"_utf16));
return;
}
@ -338,14 +338,14 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::generate_key(AlgorithmIdentifier algorith
result.visit(
[&](GC::Ref<CryptoKey>& key) {
if ((key->type() == Bindings::KeyType::Secret || key->type() == Bindings::KeyType::Private) && key_usages.is_empty()) {
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_string));
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_utf16));
return;
}
WebIDL::resolve_promise(realm, promise, key);
},
[&](GC::Ref<CryptoKeyPair>& key_pair) {
if (key_pair->private_key()->internal_usages().is_empty()) {
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_string));
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_utf16));
return;
}
WebIDL::resolve_promise(realm, promise, key_pair);
@ -413,7 +413,7 @@ JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> SubtleCrypto::import_key(Binding
// 11. If the [[type]] internal slot of result is "secret" or "private" and usages is empty, then throw a SyntaxError.
if ((result->type() == Bindings::KeyType::Secret || result->type() == Bindings::KeyType::Private) && key_usages.is_empty()) {
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_string));
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_utf16));
return;
}
@ -459,7 +459,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::export_key(Bindings::KeyFormat format, GC
// 6. If the [[extractable]] internal slot of key is false, then throw an InvalidAccessError.
if (!key->extractable()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key is not extractable"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key is not extractable"_utf16));
return;
}
@ -510,13 +510,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::sign(AlgorithmIdentifier const& algorithm
// 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 9. If the [[usages]] internal slot of key does not contain an entry that is "sign", then throw an InvalidAccessError.
if (!key->internal_usages().contains_slow(Bindings::KeyUsage::Sign)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support signing"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support signing"_utf16));
return;
}
@ -574,13 +574,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::verify(AlgorithmIdentifier const& algorit
// 9. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 10. If the [[usages]] internal slot of key does not contain an entry that is "verify", then throw an InvalidAccessError.
if (!key->internal_usages().contains_slow(Bindings::KeyUsage::Verify)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support verification"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support verification"_utf16));
return;
}
@ -621,13 +621,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::derive_bits(AlgorithmIdentifier algorithm
// 7. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of baseKey then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != base_key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 8. If the [[usages]] internal slot of baseKey does not contain an entry that is "deriveBits", then throw an InvalidAccessError.
if (!base_key->internal_usages().contains_slow(Bindings::KeyUsage::Derivebits)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support deriving bits"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support deriving bits"_utf16));
return;
}
@ -683,13 +683,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::derive_key(AlgorithmIdentifier algorithm,
// 11. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of baseKey then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != base_key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 12. If the [[usages]] internal slot of baseKey does not contain an entry that is "deriveKey", then throw an InvalidAccessError.
if (!base_key->internal_usages().contains_slow(Bindings::KeyUsage::Derivekey)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support deriving keys"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support deriving keys"_utf16));
return;
}
@ -729,7 +729,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::derive_key(AlgorithmIdentifier algorithm,
// 16. If the [[type]] internal slot of result is "secret" or "private" and usages is empty, then throw a SyntaxError.
if ((result->type() == Bindings::KeyType::Secret || result->type() == Bindings::KeyType::Private) && key_usages.is_empty()) {
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_string));
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "usages must not be empty"_utf16));
return;
}
@ -788,13 +788,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::wrap_key(Bindings::KeyFormat format, GC::
// 8. If the name member of normalizedAlgorithm is not equal to the name attribute
// of the [[algorithm]] internal slot of wrappingKey then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != wrapping_key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 9. If the [[usages]] internal slot of wrappingKey does not contain an entry that is "wrapKey", then throw an InvalidAccessError.
if (!wrapping_key->internal_usages().contains_slow(Bindings::KeyUsage::Wrapkey)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support wrapping keys"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support wrapping keys"_utf16));
return;
}
@ -803,7 +803,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::wrap_key(Bindings::KeyFormat format, GC::
// 11. If the [[extractable]] internal slot of key is false, then throw an InvalidAccessError.
if (!key->extractable()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key is not extractable"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key is not extractable"_utf16));
return;
}
@ -879,7 +879,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::wrap_key(Bindings::KeyFormat format, GC::
// Otherwise:
else {
// throw a NotSupportedError.
WebIDL::reject_promise(realm, promise, WebIDL::NotSupportedError::create(realm, "Algorithm does not support wrapping"_string));
WebIDL::reject_promise(realm, promise, WebIDL::NotSupportedError::create(realm, "Algorithm does not support wrapping"_utf16));
return;
}
@ -944,13 +944,13 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::unwrap_key(Bindings::KeyFormat format, Ke
// 11. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot
// of unwrappingKey then throw an InvalidAccessError.
if (normalized_algorithm.parameter->name != unwrapping_key->algorithm_name()) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Algorithm mismatch"_utf16));
return;
}
// 12. If the [[usages]] internal slot of unwrappingKey does not contain an entry that is "unwrapKey", then throw an InvalidAccessError.
if (!unwrapping_key->internal_usages().contains_slow(Bindings::KeyUsage::Unwrapkey)) {
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support unwrapping keys"_string));
WebIDL::reject_promise(realm, promise, WebIDL::InvalidAccessError::create(realm, "Key does not support unwrapping keys"_utf16));
return;
}
@ -972,7 +972,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::unwrap_key(Bindings::KeyFormat format, Ke
// Otherwise:
else {
// throw a NotSupportedError.
return WebIDL::NotSupportedError::create(realm, "Algorithm does not support wrapping"_string);
return WebIDL::NotSupportedError::create(realm, "Algorithm does not support wrapping"_utf16);
}
}();
if (key_or_error.is_error()) {
@ -1016,7 +1016,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::unwrap_key(Bindings::KeyFormat format, Ke
// 16. If the [[type]] internal slot of result is "secret" or "private" and usages is empty, then throw a SyntaxError.
if ((result->type() == Bindings::KeyType::Secret || result->type() == Bindings::KeyType::Private) && key_usages.is_empty()) {
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "Usages must not be empty"_string));
WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "Usages must not be empty"_utf16));
return;
}

View File

@ -64,7 +64,7 @@ void AbortSignal::signal_abort(JS::Value reason)
if (!reason.is_undefined())
m_abort_reason = reason;
else
m_abort_reason = WebIDL::AbortError::create(realm(), "Aborted without reason"_string).ptr();
m_abort_reason = WebIDL::AbortError::create(realm(), "Aborted without reason"_utf16).ptr();
// 3. Let dependentSignalsToAbort be a new list.
Vector<GC::Root<AbortSignal>> dependent_signals_to_abort;
@ -141,7 +141,7 @@ WebIDL::ExceptionOr<GC::Ref<AbortSignal>> AbortSignal::abort(JS::VM& vm, JS::Val
// 2. Set signals abort reason to reason if it is given; otherwise to a new "AbortError" DOMException.
if (reason.is_undefined())
reason = WebIDL::AbortError::create(*vm.current_realm(), "Aborted without reason"_string).ptr();
reason = WebIDL::AbortError::create(*vm.current_realm(), "Aborted without reason"_utf16).ptr();
signal->set_reason(reason);
@ -165,7 +165,7 @@ WebIDL::ExceptionOr<GC::Ref<AbortSignal>> AbortSignal::timeout(JS::VM& vm, WebID
window_or_worker.run_steps_after_a_timeout(milliseconds, [&realm, &global, signal]() {
// 1. Queue a global task on the timer task source given global to signal abort given signal and a new "TimeoutError" DOMException.
HTML::queue_global_task(HTML::Task::Source::TimerTask, global, GC::create_function(realm.heap(), [&realm, signal]() mutable {
auto reason = WebIDL::TimeoutError::create(realm, "Signal timed out"_string);
auto reason = WebIDL::TimeoutError::create(realm, "Signal timed out"_utf16);
signal->signal_abort(reason);
}));
});

View File

@ -26,9 +26,9 @@ GC::Ref<WebIDL::ObservableArray> create_adopted_style_sheets_list(Node& document
// 1. If values constructed flag is not set, or its constructor document is not equal to this
// DocumentOrShadowRoot's node document, throw a "NotAllowedError" DOMException.
if (!style_sheet.constructed())
return WebIDL::NotAllowedError::create(document_or_shadow_root.realm(), "StyleSheet's constructed flag is not set."_string);
return WebIDL::NotAllowedError::create(document_or_shadow_root.realm(), "StyleSheet's constructed flag is not set."_utf16);
if (!style_sheet.constructed() || style_sheet.constructor_document().ptr() != &document_or_shadow_root.document())
return WebIDL::NotAllowedError::create(document_or_shadow_root.realm(), "Sharing a StyleSheet between documents is not allowed."_string);
return WebIDL::NotAllowedError::create(document_or_shadow_root.realm(), "Sharing a StyleSheet between documents is not allowed."_utf16);
style_sheet.add_owning_document_or_shadow_root(document_or_shadow_root);
document_or_shadow_root.document().style_computer().load_fonts_from_sheet(style_sheet);

View File

@ -49,7 +49,7 @@ WebIDL::ExceptionOr<Utf16String> CharacterData::substring_data(size_t offset, si
// 2. If offset is greater than length, then throw an "IndexSizeError" DOMException.
if (offset > length)
return WebIDL::IndexSizeError::create(realm(), "Substring offset out of range."_string);
return WebIDL::IndexSizeError::create(realm(), "Substring offset out of range."_utf16);
// 3. If offset plus count is greater than length, return a string whose value is the code units from the offsetth code unit
// to the end of nodes data, and then return.
@ -68,7 +68,7 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
// 2. If offset is greater than length, then throw an "IndexSizeError" DOMException.
if (offset > length)
return WebIDL::IndexSizeError::create(realm(), "Replacement offset out of range."_string);
return WebIDL::IndexSizeError::create(realm(), "Replacement offset out of range."_utf16);
// 3. If offset plus count is greater than length, then set count to length minus offset.
if (offset + count > length)

View File

@ -142,7 +142,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentType>> DOMImplementation::create_document_ty
// 1. If name is not a valid doctype name, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_doctype_name(name))
return WebIDL::InvalidCharacterError::create(realm(), "Invalid doctype name"_string);
return WebIDL::InvalidCharacterError::create(realm(), "Invalid doctype name"_utf16);
// 2. Return a new doctype, with name as its name, publicId as its public ID, and systemId as its system ID, and with its node document set to the associated document of this.
auto document_type = DocumentType::create(document());

View File

@ -271,14 +271,14 @@ WebIDL::ExceptionOr<void> DOMTokenList::validate_token(StringView token) const
WebIDL::ExceptionOr<void> DOMTokenList::validate_token_not_empty(StringView token) const
{
if (token.is_empty())
return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed"_string);
return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed"_utf16);
return {};
}
WebIDL::ExceptionOr<void> DOMTokenList::validate_token_not_whitespace(StringView token) const
{
if (any_of(token, Infra::is_ascii_whitespace))
return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed"_string);
return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed"_utf16);
return {};
}

View File

@ -679,11 +679,11 @@ WebIDL::ExceptionOr<void> Document::run_the_document_write_steps(Vector<String>
// 6. If document is an XML document, then throw an "InvalidStateError" DOMException.
if (m_type == Type::XML)
return WebIDL::InvalidStateError::create(realm(), "write() called on XML document."_string);
return WebIDL::InvalidStateError::create(realm(), "write() called on XML document."_utf16);
// 7. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException.
if (m_throw_on_dynamic_markup_insertion_counter > 0)
return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_string);
return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_utf16);
// 8. If document's active parser was aborted is true, then return.
if (m_active_parser_was_aborted)
@ -726,18 +726,18 @@ WebIDL::ExceptionOr<Document*> Document::open(Optional<String> const&, Optional<
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException.
if (m_type == Type::XML)
return WebIDL::InvalidStateError::create(realm(), "open() called on XML document."_string);
return WebIDL::InvalidStateError::create(realm(), "open() called on XML document."_utf16);
// 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException.
if (m_throw_on_dynamic_markup_insertion_counter > 0)
return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_string);
return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_utf16);
// FIXME: 3. Let entryDocument be the entry global object's associated Document.
auto& entry_document = *this;
// 4. If document's origin is not same origin to entryDocument's origin, then throw a "SecurityError" DOMException.
if (origin() != entry_document.origin())
return WebIDL::SecurityError::create(realm(), "Document.origin() not the same as entryDocument's."_string);
return WebIDL::SecurityError::create(realm(), "Document.origin() not the same as entryDocument's."_utf16);
// 5. If document has an active parser whose script nesting level is greater than 0, then return document.
if (m_parser && m_parser->script_nesting_level() > 0)
@ -806,7 +806,7 @@ WebIDL::ExceptionOr<GC::Ptr<HTML::WindowProxy>> Document::open(StringView url, S
{
// 1. If this is not fully active, then throw an "InvalidAccessError" DOMException.
if (!is_fully_active())
return WebIDL::InvalidAccessError::create(realm(), "Cannot perform open on a document that isn't fully active."_string);
return WebIDL::InvalidAccessError::create(realm(), "Cannot perform open on a document that isn't fully active."_utf16);
// 2. Return the result of running the window open steps with url, name, and features.
return window()->window_open_steps(url, name, features);
@ -817,11 +817,11 @@ WebIDL::ExceptionOr<void> Document::close()
{
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception.
if (m_type == Type::XML)
return WebIDL::InvalidStateError::create(realm(), "close() called on XML document."_string);
return WebIDL::InvalidStateError::create(realm(), "close() called on XML document."_utf16);
// 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException.
if (m_throw_on_dynamic_markup_insertion_counter > 0)
return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_string);
return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_utf16);
// 3. If there is no script-created parser associated with the document, then return.
if (!m_parser)
@ -979,7 +979,7 @@ HTML::HTMLElement* Document::body()
WebIDL::ExceptionOr<void> Document::set_body(HTML::HTMLElement* new_body)
{
if (!is<HTML::HTMLBodyElement>(new_body) && !is<HTML::HTMLFrameSetElement>(new_body))
return WebIDL::HierarchyRequestError::create(realm(), "Invalid document body element, must be 'body' or 'frameset'"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Invalid document body element, must be 'body' or 'frameset'"_utf16);
auto* existing_body = body();
if (existing_body) {
@ -989,7 +989,7 @@ WebIDL::ExceptionOr<void> Document::set_body(HTML::HTMLElement* new_body)
auto* document_element = this->document_element();
if (!document_element)
return WebIDL::HierarchyRequestError::create(realm(), "Missing document element"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Missing document element"_utf16);
(void)TRY(document_element->append_child(*new_body));
return {};
@ -2101,7 +2101,7 @@ WebIDL::ExceptionOr<GC::Ref<Element>> Document::create_element(String const& loc
{
// 1. If localName is not a valid element local name, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_element_local_name(local_name))
return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in tag name."_string);
return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in tag name."_utf16);
// 2. If this is an HTML document, then set localName to localName in ASCII lowercase.
auto local_name_lower = document_type() == Type::HTML
@ -2163,11 +2163,11 @@ WebIDL::ExceptionOr<GC::Ref<CDATASection>> Document::create_cdata_section(Utf16S
{
// 1. If this is an HTML document, then throw a "NotSupportedError" DOMException.
if (is_html_document())
return WebIDL::NotSupportedError::create(realm(), "This operation is not supported for HTML documents"_string);
return WebIDL::NotSupportedError::create(realm(), "This operation is not supported for HTML documents"_utf16);
// 2. If data contains the string "]]>", then throw an "InvalidCharacterError" DOMException.
if (data.contains("]]>"sv))
return WebIDL::InvalidCharacterError::create(realm(), "String may not contain ']]>'"_string);
return WebIDL::InvalidCharacterError::create(realm(), "String may not contain ']]>'"_utf16);
// 3. Return a new CDATASection node with its data set to data and node document set to this.
return realm().create<CDATASection>(*this, move(data));
@ -2183,11 +2183,11 @@ WebIDL::ExceptionOr<GC::Ref<ProcessingInstruction>> Document::create_processing_
{
// 1. If target does not match the Name production, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_name(target))
return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in target name."_string);
return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in target name."_utf16);
// 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException.
if (data.contains("?>"sv))
return WebIDL::InvalidCharacterError::create(realm(), "String may not contain '?>'"_string);
return WebIDL::InvalidCharacterError::create(realm(), "String may not contain '?>'"_utf16);
// 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this.
return realm().create<ProcessingInstruction>(*this, move(data), target);
@ -2252,7 +2252,7 @@ WebIDL::ExceptionOr<GC::Ref<Event>> Document::create_event(StringView interface)
// 3. If constructor is null, then throw a "NotSupportedError" DOMException.
if (!event) {
return WebIDL::NotSupportedError::create(realm, "No constructor for interface found"_string);
return WebIDL::NotSupportedError::create(realm, "No constructor for interface found"_utf16);
}
// FIXME: 4. If the interface indicated by constructor is not exposed on the relevant global object of this, then throw a "NotSupportedError" DOMException.
@ -2333,7 +2333,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Document::import_node(GC::Ref<Node> node, boo
{
// 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException.
if (is<Document>(*node) || is<ShadowRoot>(*node))
return WebIDL::NotSupportedError::create(realm(), "Cannot import a document or shadow root."_string);
return WebIDL::NotSupportedError::create(realm(), "Cannot import a document or shadow root."_utf16);
// 2. Return a clone of node, with this and the clone children flag set if deep is true.
return node->clone_node(this, deep);
@ -2407,10 +2407,10 @@ void Document::adopt_node(Node& node)
WebIDL::ExceptionOr<GC::Ref<Node>> Document::adopt_node_binding(GC::Ref<Node> node)
{
if (is<Document>(*node))
return WebIDL::NotSupportedError::create(realm(), "Cannot adopt a document into a document"_string);
return WebIDL::NotSupportedError::create(realm(), "Cannot adopt a document into a document"_utf16);
if (is<ShadowRoot>(*node))
return WebIDL::HierarchyRequestError::create(realm(), "Cannot adopt a shadow root into a document"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Cannot adopt a shadow root into a document"_utf16);
if (is<DocumentFragment>(*node) && as<DocumentFragment>(*node).host())
return node;
@ -3138,7 +3138,7 @@ WebIDL::ExceptionOr<String> Document::cookie(Cookie::Source source)
// Otherwise, if the Document's origin is an opaque origin, the user agent must throw a "SecurityError" DOMException.
if (origin().is_opaque())
return WebIDL::SecurityError::create(realm(), "Document origin is opaque"_string);
return WebIDL::SecurityError::create(realm(), "Document origin is opaque"_utf16);
// Otherwise, the user agent must return the cookie-string for the document's URL for a "non-HTTP" API, decoded using
// UTF-8 decode without BOM.
@ -3154,7 +3154,7 @@ WebIDL::ExceptionOr<void> Document::set_cookie(StringView cookie_string, Cookie:
// Otherwise, if the Document's origin is an opaque origin, the user agent must throw a "SecurityError" DOMException.
if (origin().is_opaque())
return WebIDL::SecurityError::create(realm(), "Document origin is opaque"_string);
return WebIDL::SecurityError::create(realm(), "Document origin is opaque"_utf16);
// Otherwise, the user agent must act as it would when receiving a set-cookie-string for the document's URL via a
// "non-HTTP" API, consisting of the new value encoded as UTF-8.
@ -3866,22 +3866,22 @@ WebIDL::ExceptionOr<void> Document::set_domain(String const& domain)
// 1. If this's browsing context is null, then throw a "SecurityError" DOMException.
if (!m_browsing_context)
return WebIDL::SecurityError::create(realm, "Document.domain setter requires a browsing context"_string);
return WebIDL::SecurityError::create(realm, "Document.domain setter requires a browsing context"_utf16);
// 2. If this's active sandboxing flag set has its sandboxed document.domain browsing context flag set, then throw a "SecurityError" DOMException.
if (has_flag(active_sandboxing_flag_set(), HTML::SandboxingFlagSet::SandboxedDocumentDomain))
return WebIDL::SecurityError::create(realm, "Document.domain setter is sandboxed"_string);
return WebIDL::SecurityError::create(realm, "Document.domain setter is sandboxed"_utf16);
// 3. Let effectiveDomain be this's origin's effective domain.
auto effective_domain = origin().effective_domain();
// 4. If effectiveDomain is null, then throw a "SecurityError" DOMException.
if (!effective_domain.has_value())
return WebIDL::SecurityError::create(realm, "Document.domain setter called on a Document with a null effective domain"_string);
return WebIDL::SecurityError::create(realm, "Document.domain setter called on a Document with a null effective domain"_utf16);
// 5. If the given value is not a registrable domain suffix of and is not equal to effectiveDomain, then throw a "SecurityError" DOMException.
if (!is_a_registrable_domain_suffix_of_or_is_equal_to(domain, effective_domain.value()))
return WebIDL::SecurityError::create(realm, "Document.domain setter called for an invalid domain"_string);
return WebIDL::SecurityError::create(realm, "Document.domain setter called for an invalid domain"_utf16);
// FIXME: 6. If the surrounding agent's agent cluster's is origin-keyed is true, then return.
@ -4522,7 +4522,7 @@ WebIDL::ExceptionOr<GC::Ref<Attr>> Document::create_attribute(String const& loca
{
// 1. If localName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_attribute_local_name(local_name))
return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in attribute name."_string);
return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in attribute name."_utf16);
// 2. If this is an HTML document, then set localName to localName in ASCII lowercase.
// 3. Return a new attribute whose local name is localName and node document is this.

View File

@ -209,7 +209,7 @@ WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String c
{
// 1. If qualifiedName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_attribute_local_name(name))
return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty or contain invalid characters"_string);
return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty or contain invalid characters"_utf16);
// 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
bool insert_as_lowercase = namespace_uri() == Namespace::HTML && document().document_type() == Document::Type::HTML;
@ -314,7 +314,7 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Option
// 4. If prefix is not a valid namespace prefix, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_namespace_prefix(*prefix))
return WebIDL::InvalidCharacterError::create(realm, "Prefix not a valid namespace prefix."_string);
return WebIDL::InvalidCharacterError::create(realm, "Prefix not a valid namespace prefix."_utf16);
}
// 5. Assert: prefix is either null or a valid namespace prefix.
@ -322,27 +322,27 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Option
// 6. If context is "attribute" and localName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
if (context == ValidationContext::Attribute && !is_valid_attribute_local_name(local_name))
return WebIDL::InvalidCharacterError::create(realm, "Local name not a valid attribute local name."_string);
return WebIDL::InvalidCharacterError::create(realm, "Local name not a valid attribute local name."_utf16);
// 7. If context is "element" and localName is not a valid element local name, then throw an "InvalidCharacterError" DOMException.
if (context == ValidationContext::Element && !is_valid_element_local_name(local_name))
return WebIDL::InvalidCharacterError::create(realm, "Local name not a valid element local name."_string);
return WebIDL::InvalidCharacterError::create(realm, "Local name not a valid element local name."_utf16);
// 8. If prefix is non-null and namespace is null, then throw a "NamespaceError" DOMException.
if (prefix.has_value() && !namespace_.has_value())
return WebIDL::NamespaceError::create(realm, "Prefix is non-null and namespace is null."_string);
return WebIDL::NamespaceError::create(realm, "Prefix is non-null and namespace is null."_utf16);
// 9. If prefix is "xml" and namespace is not the XML namespace, then throw a "NamespaceError" DOMException.
if (prefix == "xml"sv && namespace_ != Namespace::XML)
return WebIDL::NamespaceError::create(realm, "Prefix is 'xml' and namespace is not the XML namespace."_string);
return WebIDL::NamespaceError::create(realm, "Prefix is 'xml' and namespace is not the XML namespace."_utf16);
// 10. If either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace, then throw a "NamespaceError" DOMException.
if ((qualified_name == "xmlns"sv || prefix == "xmlns"sv) && namespace_ != Namespace::XMLNS)
return WebIDL::NamespaceError::create(realm, "Either qualifiedName or prefix is 'xmlns' and namespace is not the XMLNS namespace."_string);
return WebIDL::NamespaceError::create(realm, "Either qualifiedName or prefix is 'xmlns' and namespace is not the XMLNS namespace."_utf16);
// 11. If namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns", then throw a "NamespaceError" DOMException.
if (namespace_ == Namespace::XMLNS && !(qualified_name == "xmlns"sv || prefix == "xmlns"sv))
return WebIDL::NamespaceError::create(realm, "Namespace is the XMLNS namespace and neither qualifiedName nor prefix is 'xmlns'."_string);
return WebIDL::NamespaceError::create(realm, "Namespace is the XMLNS namespace and neither qualifiedName nor prefix is 'xmlns'."_utf16);
// 12. Return (namespace, prefix, localName).
return QualifiedName { local_name, prefix, namespace_ };
@ -459,7 +459,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optio
{
// 1. If qualifiedName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
if (!is_valid_attribute_local_name(name))
return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty or contain invalid characters"_string);
return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty or contain invalid characters"_utf16);
// 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
bool insert_as_lowercase = namespace_uri() == Namespace::HTML && document().document_type() == Document::Type::HTML;
@ -881,11 +881,11 @@ WebIDL::ExceptionOr<void> Element::attach_a_shadow_root(Bindings::ShadowRootMode
{
// 1. If elements namespace is not the HTML namespace, then throw a "NotSupportedError" DOMException.
if (namespace_uri() != Namespace::HTML)
return WebIDL::NotSupportedError::create(realm(), "Element's namespace is not the HTML namespace"_string);
return WebIDL::NotSupportedError::create(realm(), "Element's namespace is not the HTML namespace"_utf16);
// 2. If elements local name is not a valid shadow host name, then throw a "NotSupportedError" DOMException.
if (!is_valid_shadow_host_name(local_name()))
return WebIDL::NotSupportedError::create(realm(), "Element's local name is not a valid shadow host name"_string);
return WebIDL::NotSupportedError::create(realm(), "Element's local name is not a valid shadow host name"_utf16);
// 3. If elements local name is a valid custom element name, or elements is value is not null, then:
if (HTML::is_valid_custom_element_name(local_name()) || m_is_value.has_value()) {
@ -894,7 +894,7 @@ WebIDL::ExceptionOr<void> Element::attach_a_shadow_root(Bindings::ShadowRootMode
// 2. If definition is not null and definitions disable shadow is true, then throw a "NotSupportedError" DOMException.
if (definition && definition->disable_shadow())
return WebIDL::NotSupportedError::create(realm(), "Cannot attach a shadow root to a custom element that has disabled shadow roots"_string);
return WebIDL::NotSupportedError::create(realm(), "Cannot attach a shadow root to a custom element that has disabled shadow roots"_utf16);
}
// 4. If element is a shadow host, then:
@ -907,7 +907,7 @@ WebIDL::ExceptionOr<void> Element::attach_a_shadow_root(Bindings::ShadowRootMode
// - currentShadowRoots mode is not mode,
// then throw a "NotSupportedError" DOMException.
if (!current_shadow_root->declarative() || current_shadow_root->mode() != mode) {
return WebIDL::NotSupportedError::create(realm(), "Element already is a shadow host"_string);
return WebIDL::NotSupportedError::create(realm(), "Element already is a shadow host"_utf16);
}
// 3. Otherwise:
@ -980,7 +980,7 @@ WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const
// 2. If s is failure, then throw a "SyntaxError" DOMException.
if (!maybe_selectors.has_value())
return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_string);
return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_utf16);
// 3. If the result of match a selector against an element, using s, this, and scoping root this, returns success, then return true; otherwise, return false.
auto sel = maybe_selectors.value();
@ -1000,7 +1000,7 @@ WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors)
// 2. If s is failure, then throw a "SyntaxError" DOMException.
if (!maybe_selectors.has_value())
return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_string);
return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_utf16);
auto matches_selectors = [this](CSS::SelectorList const& selector_list, Element const* element) {
// 4. For each element in elements, if match a selector against an element, using s, element, and scoping root this, returns success, return element.
@ -2079,7 +2079,7 @@ WebIDL::ExceptionOr<void> Element::set_outer_html(String const& value)
// 4. If parent is a Document, throw a "NoModificationAllowedError" DOMException.
if (parent->is_document())
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot set outer HTML on document"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot set outer HTML on document"_utf16);
// 5. If parent is a DocumentFragment, set parent to the result of creating an element given this's node document, "body", and the HTML namespace.
if (parent->is_document_fragment())
@ -2110,7 +2110,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
// 2. If context is null or a Document, throw a "NoModificationAllowedError" DOMException.
if (!context || context->is_document())
return WebIDL::NoModificationAllowedError::create(realm(), "insertAdjacentHTML: context is null or a Document"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "insertAdjacentHTML: context is null or a Document"_utf16);
}
// - If position is an ASCII case-insensitive match for the string "afterbegin"
// - If position is an ASCII case-insensitive match for the string "beforeend"
@ -2122,7 +2122,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
// Otherwise
else {
// Throw a "SyntaxError" DOMException.
return WebIDL::SyntaxError::create(realm(), "insertAdjacentHTML: invalid position argument"_string);
return WebIDL::SyntaxError::create(realm(), "insertAdjacentHTML: invalid position argument"_utf16);
}
// 3. If context is not an Element or the following are all true:
@ -2206,7 +2206,7 @@ WebIDL::ExceptionOr<GC::Ptr<Node>> Element::insert_adjacent(StringView where, GC
// -> Otherwise
// Throw a "SyntaxError" DOMException.
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Unknown position '{}'. Must be one of 'beforebegin', 'afterbegin', 'beforeend' or 'afterend'", where)));
return WebIDL::SyntaxError::create(realm(), Utf16String::formatted("Unknown position '{}'. Must be one of 'beforebegin', 'afterbegin', 'beforeend' or 'afterend'", where));
}
// https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
@ -2801,7 +2801,7 @@ JS::ThrowCompletionOr<void> Element::upgrade_element(GC::Ref<HTML::CustomElement
auto attempt_to_construct_custom_element = [&]() -> JS::ThrowCompletionOr<void> {
// 1. If definition's disable shadow is true and element's shadow root is non-null, then throw a "NotSupportedError" DOMException.
if (custom_element_definition->disable_shadow() && shadow_root())
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Custom element definition disables shadow DOM and the custom element has a shadow root"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Custom element definition disables shadow DOM and the custom element has a shadow root"_utf16));
// 2. Set element's custom element state to "precustomized".
set_custom_element_state(CustomElementState::Precustomized);

View File

@ -615,23 +615,23 @@ WebIDL::ExceptionOr<GC::Ref<Element>> create_element(Document& document, FlyStri
// 5. If results attribute list is not empty, then throw a "NotSupportedError" DOMException.
if (element->has_attributes())
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have attributes"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have attributes"_utf16));
// 6. If result has children, then throw a "NotSupportedError" DOMException.
if (element->has_children())
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have children"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have children"_utf16));
// 7. If results parent is not null, then throw a "NotSupportedError" DOMException.
if (element->parent())
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have a parent"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have a parent"_utf16));
// 8. If results node document is not document, then throw a "NotSupportedError" DOMException.
if (&element->document() != &document)
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must be in the same document that element creation was invoked in"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must be in the same document that element creation was invoked in"_utf16));
// 9. If results local name is not equal to localName, then throw a "NotSupportedError" DOMException.
if (element->local_name() != local_name)
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must have the same local name that element creation was invoked with"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must have the same local name that element creation was invoked with"_utf16));
// 10. Set results namespace prefix to prefix.
element->set_prefix(prefix);

View File

@ -289,10 +289,10 @@ WebIDL::ExceptionOr<bool> EventTarget::dispatch_event_binding(Event& event)
{
// 1. If events dispatch flag is set, or if its initialized flag is not set, then throw an "InvalidStateError" DOMException.
if (event.dispatched())
return WebIDL::InvalidStateError::create(realm(), "The event is already being dispatched."_string);
return WebIDL::InvalidStateError::create(realm(), "The event is already being dispatched."_utf16);
if (!event.initialized())
return WebIDL::InvalidStateError::create(realm(), "Cannot dispatch an uninitialized event."_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot dispatch an uninitialized event."_utf16);
// 2. Initialize events isTrusted attribute to false.
event.set_is_trusted(false);

View File

@ -114,7 +114,7 @@ WebIDL::ExceptionOr<Attr const*> NamedNodeMap::remove_named_item(FlyString const
// 2. If attr is null, then throw a "NotFoundError" DOMException.
if (!attribute)
return WebIDL::NotFoundError::create(realm(), MUST(String::formatted("Attribute with name '{}' not found", qualified_name)));
return WebIDL::NotFoundError::create(realm(), Utf16String::formatted("Attribute with name '{}' not found", qualified_name));
// 3. Return attr.
return attribute;
@ -128,7 +128,7 @@ WebIDL::ExceptionOr<Attr const*> NamedNodeMap::remove_named_item_ns(Optional<Fly
// 2. If attr is null, then throw a "NotFoundError" DOMException.
if (!attribute)
return WebIDL::NotFoundError::create(realm(), MUST(String::formatted("Attribute with namespace '{}' and local name '{}' not found", namespace_, local_name)));
return WebIDL::NotFoundError::create(realm(), Utf16String::formatted("Attribute with namespace '{}' and local name '{}' not found", namespace_, local_name));
// 3. Return attr.
return attribute;
@ -199,7 +199,7 @@ WebIDL::ExceptionOr<GC::Ptr<Attr>> NamedNodeMap::set_attribute(Attr& attribute)
{
// 1. If attrs element is neither null nor element, throw an "InUseAttributeError" DOMException.
if ((attribute.owner_element() != nullptr) && (attribute.owner_element() != &associated_element()))
return WebIDL::InUseAttributeError::create(realm(), "Attribute must not already be in use"_string);
return WebIDL::InUseAttributeError::create(realm(), "Attribute must not already be in use"_utf16);
// 2. Let oldAttr be the result of getting an attribute given attrs namespace, attrs local name, and element.
size_t old_attribute_index = 0;
@ -336,7 +336,7 @@ WebIDL::ExceptionOr<GC::Ref<Attr>> NamedNodeMap::remove_attribute_node(GC::Ref<A
// 1. If thiss attribute list does not contain attr, then throw a "NotFoundError" DOMException.
auto index = m_attributes.find_first_index(attr);
if (!index.has_value())
return WebIDL::NotFoundError::create(realm(), "Attribute not found"_string);
return WebIDL::NotFoundError::create(realm(), "Attribute not found"_utf16);
// 2. Remove attr.
remove_attribute_at_index(index.value());

View File

@ -594,24 +594,24 @@ WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::Realm& realm,
{
// 1. If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
if (!is<Document>(this) && !is<DocumentFragment>(this) && !is<Element>(this))
return WebIDL::HierarchyRequestError::create(realm, "Can only insert into a document, document fragment or element"_string);
return WebIDL::HierarchyRequestError::create(realm, "Can only insert into a document, document fragment or element"_utf16);
// 2. If node is a host-including inclusive ancestor of parent, then throw a "HierarchyRequestError" DOMException.
if (node->is_host_including_inclusive_ancestor_of(*this))
return WebIDL::HierarchyRequestError::create(realm, "New node is an ancestor of this node"_string);
return WebIDL::HierarchyRequestError::create(realm, "New node is an ancestor of this node"_utf16);
// 3. If child is non-null and its parent is not parent, then throw a "NotFoundError" DOMException.
if (child && child->parent() != this)
return WebIDL::NotFoundError::create(realm, "This node is not the parent of the given child"_string);
return WebIDL::NotFoundError::create(realm, "This node is not the parent of the given child"_utf16);
// FIXME: All the following "Invalid node type for insertion" messages could be more descriptive.
// 4. If node is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
if (!is<DocumentFragment>(*node) && !is<DocumentType>(*node) && !is<Element>(*node) && !is<Text>(*node) && !is<Comment>(*node) && !is<ProcessingInstruction>(*node) && !is<CDATASection>(*node))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
// 5. If either node is a Text node and parent is a document, or node is a doctype and parent is not a document, then throw a "HierarchyRequestError" DOMException.
if ((is<Text>(*node) && is<Document>(this)) || (is<DocumentType>(*node) && !is<Document>(this)))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
// 6. If parent is a document, and any of the statements below, switched on the interface node implements, are true, then throw a "HierarchyRequestError" DOMException.
if (is<Document>(this)) {
@ -622,18 +622,18 @@ WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::Realm& realm,
auto node_element_child_count = as<DocumentFragment>(*node).child_element_count();
if ((node_element_child_count > 1 || node->has_child_of_type<Text>())
|| (node_element_child_count == 1 && (has_child_of_type<Element>() || is<DocumentType>(child.ptr()) || (child && child->has_following_node_of_type_in_tree_order<DocumentType>())))) {
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
}
} else if (is<Element>(*node)) {
// Element
// If parent has an element child, child is a doctype, or child is non-null and a doctype is following child.
if (has_child_of_type<Element>() || is<DocumentType>(child.ptr()) || (child && child->has_following_node_of_type_in_tree_order<DocumentType>()))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
} else if (is<DocumentType>(*node)) {
// DocumentType
// parent has a doctype child, child is non-null and an element is preceding child, or child is null and parent has an element child.
if (has_child_of_type<DocumentType>() || (child && child->has_preceding_node_of_type_in_tree_order<Element>()) || (!child && has_child_of_type<Element>()))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
}
}
@ -837,7 +837,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::pre_remove(GC::Ref<Node> child)
{
// 1. If childs parent is not parent, then throw a "NotFoundError" DOMException.
if (child->parent() != this)
return WebIDL::NotFoundError::create(realm(), "Child does not belong to this node"_string);
return WebIDL::NotFoundError::create(realm(), "Child does not belong to this node"_utf16);
// 2. Remove child.
child->remove();
@ -1032,25 +1032,25 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::replace_child(GC::Ref<Node> node, GC::R
{
// If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
if (!is<Document>(this) && !is<DocumentFragment>(this) && !is<Element>(this))
return WebIDL::HierarchyRequestError::create(realm(), "Can only insert into a document, document fragment or element"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Can only insert into a document, document fragment or element"_utf16);
// 2. If node is a host-including inclusive ancestor of parent, then throw a "HierarchyRequestError" DOMException.
if (node->is_host_including_inclusive_ancestor_of(*this))
return WebIDL::HierarchyRequestError::create(realm(), "New node is an ancestor of this node"_string);
return WebIDL::HierarchyRequestError::create(realm(), "New node is an ancestor of this node"_utf16);
// 3. If childs parent is not parent, then throw a "NotFoundError" DOMException.
if (child->parent() != this)
return WebIDL::NotFoundError::create(realm(), "This node is not the parent of the given child"_string);
return WebIDL::NotFoundError::create(realm(), "This node is not the parent of the given child"_utf16);
// FIXME: All the following "Invalid node type for insertion" messages could be more descriptive.
// 4. If node is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
if (!is<DocumentFragment>(*node) && !is<DocumentType>(*node) && !is<Element>(*node) && !is<Text>(*node) && !is<Comment>(*node) && !is<ProcessingInstruction>(*node))
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_utf16);
// 5. If either node is a Text node and parent is a document, or node is a doctype and parent is not a document, then throw a "HierarchyRequestError" DOMException.
if ((is<Text>(*node) && is<Document>(this)) || (is<DocumentType>(*node) && !is<Document>(this)))
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_utf16);
// If parent is a document, and any of the statements below, switched on the interface node implements, are true, then throw a "HierarchyRequestError" DOMException.
if (is<Document>(this)) {
@ -1061,18 +1061,18 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::replace_child(GC::Ref<Node> node, GC::R
auto node_element_child_count = as<DocumentFragment>(*node).child_element_count();
if ((node_element_child_count > 1 || node->has_child_of_type<Text>())
|| (node_element_child_count == 1 && (first_child_of_type<Element>() != child || child->has_following_node_of_type_in_tree_order<DocumentType>()))) {
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_utf16);
}
} else if (is<Element>(*node)) {
// Element
// parent has an element child that is not child or a doctype is following child.
if (first_child_of_type<Element>() != child || child->has_following_node_of_type_in_tree_order<DocumentType>())
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_utf16);
} else if (is<DocumentType>(*node)) {
// DocumentType
// parent has a doctype child that is not child, or an element is preceding child.
if (first_child_of_type<DocumentType>() != child || child->has_preceding_node_of_type_in_tree_order<Element>())
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_utf16);
}
}
@ -1183,31 +1183,31 @@ WebIDL::ExceptionOr<void> Node::move_node(Node& new_parent, Node* child)
// 1. If newParents shadow-including root is not the same as nodes shadow-including root, then throw a "HierarchyRequestError" DOMException.
if (&new_parent.shadow_including_root() != &shadow_including_root())
return WebIDL::HierarchyRequestError::create(realm, "New parent is not in the same shadow tree"_string);
return WebIDL::HierarchyRequestError::create(realm, "New parent is not in the same shadow tree"_utf16);
// NOTE: This has the side effect of ensuring that a move is only performed if newParents connected is nodes connected.
// 2. If node is a host-including inclusive ancestor of newParent, then throw a "HierarchyRequestError" DOMException.
if (is_host_including_inclusive_ancestor_of(new_parent))
return WebIDL::HierarchyRequestError::create(realm, "New parent is an ancestor of this node"_string);
return WebIDL::HierarchyRequestError::create(realm, "New parent is an ancestor of this node"_utf16);
// 3. If child is non-null and its parent is not newParent, then throw a "NotFoundError" DOMException.
if (child && child->parent() != &new_parent)
return WebIDL::NotFoundError::create(realm, "Child does not belong to the new parent"_string);
return WebIDL::NotFoundError::create(realm, "Child does not belong to the new parent"_utf16);
// 4. If node is not an Element or a CharacterData node, then throw a "HierarchyRequestError" DOMException.
if (!is<Element>(*this) && !is<CharacterData>(*this))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
// 5. If node is a Text node and newParent is a document, then throw a "HierarchyRequestError" DOMException.
if (is<Text>(*this) && is<Document>(new_parent))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
// 6. If newParent is a document, node is an Element node, and either newParent has an element child, child is a doctype,
// or child is non-null and a doctype is following child then throw a "HierarchyRequestError" DOMException.
if (is<Document>(new_parent) && is<Element>(*this)) {
if (new_parent.has_child_of_type<Element>() || is<DocumentType>(child) || (child && child->has_following_node_of_type_in_tree_order<DocumentType>()))
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm, "Invalid node type for insertion"_utf16);
}
// 7. Let oldParent be nodes parent.
@ -1497,7 +1497,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_node_binding(bool subtree)
{
// 1. If this is a shadow root, then throw a "NotSupportedError" DOMException.
if (is<ShadowRoot>(*this))
return WebIDL::NotSupportedError::create(realm(), "Cannot clone shadow root"_string);
return WebIDL::NotSupportedError::create(realm(), "Cannot clone shadow root"_utf16);
// 2. Return the result of cloning a node given this with subtree set to subtree.
return clone_node(nullptr, subtree);

View File

@ -151,7 +151,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> NodeIterator::filter(Node& node)
{
// 1. If traversers active flag is set, then throw an "InvalidStateError" DOMException.
if (m_active)
return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active"_string));
return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active"_utf16));
// 2. Let n be nodes nodeType attribute value 1.
auto n = node.node_type() - 1;

View File

@ -56,13 +56,13 @@ static WebIDL::ExceptionOr<Variant<GC::Ptr<Element>, GC::Ref<NodeList>>> scope_m
// 2. If s is failure, then throw a "SyntaxError" DOMException.
if (!maybe_selectors.has_value())
return WebIDL::SyntaxError::create(node.realm(), "Failed to parse selector"_string);
return WebIDL::SyntaxError::create(node.realm(), "Failed to parse selector"_utf16);
auto selectors = maybe_selectors.value();
// "Note: Support for namespaces within selectors is not planned and will not be added."
if (contains_named_namespace(selectors))
return WebIDL::SyntaxError::create(node.realm(), "Failed to parse selector"_string);
return WebIDL::SyntaxError::create(node.realm(), "Failed to parse selector"_utf16);
// 3. Return the result of match a selector against a tree with s and nodes root using scoping root node.
GC::Ptr<Element> single_result;

View File

@ -182,11 +182,11 @@ WebIDL::ExceptionOr<void> Range::set_start_or_end(GC::Ref<Node> node, u32 offset
// 1. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(*node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
// 2. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node->length())
return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset)));
return WebIDL::IndexSizeError::create(realm(), Utf16String::formatted("Node does not contain a child at offset {}", offset));
// 3. Let bp be the boundary point (node, offset).
@ -243,7 +243,7 @@ WebIDL::ExceptionOr<void> Range::set_start_before(GC::Ref<Node> node)
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
if (!parent)
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
// 3. Set the start of this to boundary point (parent, nodes index).
return set_start_or_end(*parent, node->index(), StartOrEnd::Start);
@ -257,7 +257,7 @@ WebIDL::ExceptionOr<void> Range::set_start_after(GC::Ref<Node> node)
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
if (!parent)
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
// 3. Set the start of this to boundary point (parent, nodes index plus 1).
return set_start_or_end(*parent, node->index() + 1, StartOrEnd::Start);
@ -271,7 +271,7 @@ WebIDL::ExceptionOr<void> Range::set_end_before(GC::Ref<Node> node)
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
if (!parent)
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
// 3. Set the end of this to boundary point (parent, nodes index).
return set_start_or_end(*parent, node->index(), StartOrEnd::End);
@ -285,7 +285,7 @@ WebIDL::ExceptionOr<void> Range::set_end_after(GC::Ref<Node> node)
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
if (!parent)
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
// 3. Set the end of this to boundary point (parent, nodes index plus 1).
return set_start_or_end(*parent, node->index() + 1, StartOrEnd::End);
@ -301,11 +301,11 @@ WebIDL::ExceptionOr<WebIDL::Short> Range::compare_boundary_points(WebIDL::Unsign
// - END_TO_START,
// then throw a "NotSupportedError" DOMException.
if (how != HowToCompareBoundaryPoints::START_TO_START && how != HowToCompareBoundaryPoints::START_TO_END && how != HowToCompareBoundaryPoints::END_TO_END && how != HowToCompareBoundaryPoints::END_TO_START)
return WebIDL::NotSupportedError::create(realm(), MUST(String::formatted("Expected 'how' to be one of START_TO_START (0), START_TO_END (1), END_TO_END (2) or END_TO_START (3), got {}", how)));
return WebIDL::NotSupportedError::create(realm(), Utf16String::formatted("Expected 'how' to be one of START_TO_START (0), START_TO_END (1), END_TO_END (2) or END_TO_START (3), got {}", how));
// 2. If thiss root is not the same as sourceRanges root, then throw a "WrongDocumentError" DOMException.
if (root() != source_range.root())
return WebIDL::WrongDocumentError::create(realm(), "This range is not in the same tree as the source range."_string);
return WebIDL::WrongDocumentError::create(realm(), "This range is not in the same tree as the source range."_utf16);
GC::Ptr<Node> this_point_node;
u32 this_point_offset = 0;
@ -386,7 +386,7 @@ WebIDL::ExceptionOr<void> Range::select(GC::Ref<Node> node)
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
if (!parent)
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
// 3. Let index be nodes index.
auto index = node->index();
@ -429,7 +429,7 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(GC::Ref<Node> node)
{
// 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(*node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
// 2. Let length be the length of node.
auto length = node->length();
@ -503,11 +503,11 @@ WebIDL::ExceptionOr<bool> Range::is_point_in_range(GC::Ref<Node> node, WebIDL::U
// 2. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(*node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
// 3. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node->length())
return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset)));
return WebIDL::IndexSizeError::create(realm(), Utf16String::formatted("Node does not contain a child at offset {}", offset));
// 4. If (node, offset) is before start or after end, return false.
auto relative_position_to_start = position_of_boundary_point_relative_to_other_boundary_point({ node, offset }, start());
@ -524,15 +524,15 @@ WebIDL::ExceptionOr<WebIDL::Short> Range::compare_point(GC::Ref<Node> node, WebI
{
// 1. If nodes root is different from thiss root, then throw a "WrongDocumentError" DOMException.
if (&node->root() != root().ptr())
return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."_string);
return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."_utf16);
// 2. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(*node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
// 3. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node->length())
return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset)));
return WebIDL::IndexSizeError::create(realm(), Utf16String::formatted("Node does not contain a child at offset {}", offset));
// 4. If (node, offset) is before start, return 1.
auto relative_position_to_start = position_of_boundary_point_relative_to_other_boundary_point({ node, offset }, start());
@ -672,7 +672,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::extract()
// 12. If any member of contained children is a doctype, then throw a "HierarchyRequestError" DOMException.
for (auto const& child : contained_children) {
if (is<DocumentType>(*child))
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_utf16);
}
GC::Ptr<Node> new_node;
@ -816,7 +816,7 @@ WebIDL::ExceptionOr<void> Range::insert(GC::Ref<Node> node)
if ((is<ProcessingInstruction>(*m_start_container) || is<Comment>(*m_start_container))
|| (is<Text>(*m_start_container) && !m_start_container->parent_node())
|| m_start_container.ptr() == node.ptr()) {
return WebIDL::HierarchyRequestError::create(realm(), "Range has inappropriate start node for insertion"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Range has inappropriate start node for insertion"_utf16);
}
// 2. Let referenceNode be null.
@ -887,11 +887,11 @@ WebIDL::ExceptionOr<void> Range::surround_contents(GC::Ref<Node> new_parent)
if (is<Text>(*end_non_text_node))
end_non_text_node = end_non_text_node->parent_node();
if (start_non_text_node != end_non_text_node)
return WebIDL::InvalidStateError::create(realm(), "Non-Text node is partially contained in range."_string);
return WebIDL::InvalidStateError::create(realm(), "Non-Text node is partially contained in range."_utf16);
// 2. If newParent is a Document, DocumentType, or DocumentFragment node, then throw an "InvalidNodeTypeError" DOMException.
if (is<Document>(*new_parent) || is<DocumentType>(*new_parent) || is<DocumentFragment>(*new_parent))
return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"_utf16);
// 3. Let fragment be the result of extracting this.
auto fragment = TRY(extract());
@ -995,7 +995,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::clone_the_contents()
// 12. If any member of contained children is a doctype, then throw a "HierarchyRequestError" DOMException.
for (auto const& child : contained_children) {
if (is<DocumentType>(*child))
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_utf16);
}
// 13. If first partially contained child is a CharacterData node, then:

View File

@ -29,10 +29,10 @@ WebIDL::ExceptionOr<GC::Ref<StaticRange>> StaticRange::construct_impl(JS::Realm&
{
// 1. If init["startContainer"] or init["endContainer"] is a DocumentType or Attr node, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(*init.start_container) || is<Attr>(*init.start_container))
return WebIDL::InvalidNodeTypeError::create(realm, "startContainer cannot be a DocumentType or Attribute node."_string);
return WebIDL::InvalidNodeTypeError::create(realm, "startContainer cannot be a DocumentType or Attribute node."_utf16);
if (is<DocumentType>(*init.end_container) || is<Attr>(*init.end_container))
return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."_string);
return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."_utf16);
// 2. Set thiss start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]).
return realm.create<StaticRange>(*init.start_container, init.start_offset, *init.end_container, init.end_offset);

View File

@ -57,7 +57,7 @@ WebIDL::ExceptionOr<GC::Ref<Text>> Text::split_text(size_t offset)
// 2. If offset is greater than length, then throw an "IndexSizeError" DOMException.
if (offset > length)
return WebIDL::IndexSizeError::create(realm(), "Split offset is greater than length"_string);
return WebIDL::IndexSizeError::create(realm(), "Split offset is greater than length"_utf16);
// 3. Let count be length minus offset.
auto count = length - offset;

View File

@ -256,7 +256,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> TreeWalker::filter(Node& node)
{
// 1. If traversers active flag is set, then throw an "InvalidStateError" DOMException.
if (m_active)
return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active"_string));
return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active"_utf16));
// 2. Let n be nodes nodeType attribute value 1.
auto n = node.node_type() - 1;

View File

@ -21,7 +21,7 @@ WebIDL::ExceptionOr<bool> Document::exec_command(FlyString const& command, [[may
{
// AD-HOC: This is not directly mentioned in the spec, but all major browsers limit editing API calls to HTML documents
if (!is_html_document())
return WebIDL::InvalidStateError::create(realm(), "execCommand is only supported on HTML documents"_string);
return WebIDL::InvalidStateError::create(realm(), "execCommand is only supported on HTML documents"_utf16);
// AD-HOC: All major browsers refuse to recursively execute execCommand() (e.g. inside input event handlers).
if (m_inside_exec_command)
@ -141,7 +141,7 @@ WebIDL::ExceptionOr<bool> Document::query_command_enabled(FlyString const& comma
{
// AD-HOC: This is not directly mentioned in the spec, but all major browsers limit editing API calls to HTML documents
if (!is_html_document())
return WebIDL::InvalidStateError::create(realm(), "queryCommandEnabled is only supported on HTML documents"_string);
return WebIDL::InvalidStateError::create(realm(), "queryCommandEnabled is only supported on HTML documents"_utf16);
// 2. Return true if command is both supported and enabled, false otherwise.
if (!MUST(query_command_supported(command)))
@ -236,7 +236,7 @@ WebIDL::ExceptionOr<bool> Document::query_command_indeterm(FlyString const& comm
{
// AD-HOC: This is not directly mentioned in the spec, but all major browsers limit editing API calls to HTML documents
if (!is_html_document())
return WebIDL::InvalidStateError::create(realm(), "queryCommandIndeterm is only supported on HTML documents"_string);
return WebIDL::InvalidStateError::create(realm(), "queryCommandIndeterm is only supported on HTML documents"_utf16);
// 1. If command is not supported or has no indeterminacy, return false.
auto optional_command = Editing::find_command_definition(command);
@ -312,7 +312,7 @@ WebIDL::ExceptionOr<bool> Document::query_command_state(FlyString const& command
{
// AD-HOC: This is not directly mentioned in the spec, but all major browsers limit editing API calls to HTML documents
if (!is_html_document())
return WebIDL::InvalidStateError::create(realm(), "queryCommandState is only supported on HTML documents"_string);
return WebIDL::InvalidStateError::create(realm(), "queryCommandState is only supported on HTML documents"_utf16);
// 1. If command is not supported or has no state, return false.
auto optional_command = Editing::find_command_definition(command);
@ -361,7 +361,7 @@ WebIDL::ExceptionOr<bool> Document::query_command_supported(FlyString const& com
{
// AD-HOC: This is not directly mentioned in the spec, but all major browsers limit editing API calls to HTML documents
if (!is_html_document())
return WebIDL::InvalidStateError::create(realm(), "queryCommandSupported is only supported on HTML documents"_string);
return WebIDL::InvalidStateError::create(realm(), "queryCommandSupported is only supported on HTML documents"_utf16);
// When the queryCommandSupported(command) method on the Document interface is invoked, the user agent must return
// true if command is supported and available within the current script on the current site, and false otherwise.
@ -375,7 +375,7 @@ WebIDL::ExceptionOr<String> Document::query_command_value(FlyString const& comma
{
// AD-HOC: This is not directly mentioned in the spec, but all major browsers limit editing API calls to HTML documents
if (!is_html_document())
return WebIDL::InvalidStateError::create(realm(), "queryCommandValue is only supported on HTML documents"_string);
return WebIDL::InvalidStateError::create(realm(), "queryCommandValue is only supported on HTML documents"_utf16);
// 1. If command is not supported or has no value, return the empty string.
auto optional_command = Editing::find_command_definition(command);

View File

@ -74,7 +74,7 @@ WebIDL::ExceptionOr<String> TextDecoder::decode(Optional<GC::Root<WebIDL::Buffer
// FIXME: Implement the streaming stuff.
auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*input.value()->raw_object());
if (data_buffer_or_error.is_error())
return WebIDL::OperationError::create(realm(), "Failed to copy bytes from ArrayBuffer"_string);
return WebIDL::OperationError::create(realm(), "Failed to copy bytes from ArrayBuffer"_utf16);
auto& data_buffer = data_buffer_or_error.value();
auto result = TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({ data_buffer.data(), data_buffer.size() }));
if (this->fatal() && result.contains(0xfffd))

View File

@ -80,7 +80,7 @@ void FetchController::abort(JS::Realm& realm, Optional<JS::Value> error)
m_state = State::Aborted;
// 2. Let fallbackError be an "AbortError" DOMException.
auto fallback_error = WebIDL::AbortError::create(realm, "Fetch was aborted"_string);
auto fallback_error = WebIDL::AbortError::create(realm, "Fetch was aborted"_utf16);
// 3. Set error to fallbackError if it is not given.
if (!error.has_value())
@ -101,7 +101,7 @@ void FetchController::abort(JS::Realm& realm, Optional<JS::Value> error)
JS::Value FetchController::deserialize_a_serialized_abort_reason(JS::Realm& realm)
{
// 1. Let fallbackError be an "AbortError" DOMException.
auto fallback_error = WebIDL::AbortError::create(realm, "Fetch was aborted"_string);
auto fallback_error = WebIDL::AbortError::create(realm, "Fetch was aborted"_utf16);
// 2. Let deserializedError be fallbackError.
JS::Value deserialized_error = fallback_error;

View File

@ -142,7 +142,7 @@ WebIDL::ExceptionOr<void> FileReader::read_operation(Blob& blob, Type type, Opti
// 1. If frs state is "loading", throw an InvalidStateError DOMException.
if (m_state == State::Loading)
return WebIDL::InvalidStateError::create(realm, "Read already in progress"_string);
return WebIDL::InvalidStateError::create(realm, "Read already in progress"_utf16);
// 2. Set frs state to "loading".
m_state = State::Loading;

View File

@ -562,7 +562,7 @@ WebIDL::ExceptionOr<String> DOMMatrixReadOnly::to_string() const
|| !isfinite(m21()) || !isfinite(m22()) || !isfinite(m23()) || !isfinite(m24())
|| !isfinite(m31()) || !isfinite(m32()) || !isfinite(m33()) || !isfinite(m34())
|| !isfinite(m41()) || !isfinite(m42()) || !isfinite(m43()) || !isfinite(m44())) {
return WebIDL::InvalidStateError::create(realm(), "Cannot stringify non-finite matrix values"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot stringify non-finite matrix values"_utf16);
}
// 2. Let string be the empty string.
@ -951,7 +951,7 @@ WebIDL::ExceptionOr<ParsedMatrix> parse_dom_matrix_init_string(JS::Realm& realm,
// If parsedValue is failure, or any <transform-function> has <length> values without absolute length units, or any keyword other than none is used, then return failure. [CSS3-SYNTAX] [CSS3-TRANSFORMS]
auto transform_style_value = parse_css_value(CSS::Parser::ParsingParams {}, transform_list, CSS::PropertyID::Transform);
if (!transform_style_value || (transform_style_value->is_keyword() && transform_style_value->to_keyword() != CSS::Keyword::None))
return WebIDL::SyntaxError::create(realm, "Failed to parse CSS transform string."_string);
return WebIDL::SyntaxError::create(realm, "Failed to parse CSS transform string."_utf16);
auto parsed_value = CSS::ComputedProperties::transformations_for_style_value(*transform_style_value);
// 3. If parsedValue is none, set parsedValue to a <transform-list> containing a single identity matrix.
@ -983,7 +983,7 @@ WebIDL::ExceptionOr<ParsedMatrix> parse_dom_matrix_init_string(JS::Realm& realm,
for (auto const& transform : parsed_value) {
auto const& transform_matrix = transform.to_matrix({});
if (transform_matrix.is_error())
return WebIDL::SyntaxError::create(realm, "Failed to parse CSS transform string."_string);
return WebIDL::SyntaxError::create(realm, "Failed to parse CSS transform string."_utf16);
matrix = matrix * transform_matrix.value();
}

View File

@ -110,7 +110,7 @@ WebIDL::ExceptionOr<void> BroadcastChannel::post_message(JS::Value message)
// 2. If this's closed flag is true, then throw an "InvalidStateError" DOMException.
if (m_closed_flag)
return WebIDL::InvalidStateError::create(realm(), "BroadcastChannel.postMessage() on a closed channel"_string);
return WebIDL::InvalidStateError::create(realm(), "BroadcastChannel.postMessage() on a closed channel"_utf16);
// 3. Let serialized be StructuredSerialize(message). Rethrow any exceptions.
auto serialized = TRY(structured_serialize(vm, message));

View File

@ -90,7 +90,7 @@ 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(), MUST(String::formatted("The radius provided ({}) is negative.", radius)));
return WebIDL::IndexSizeError::create(m_self->realm(), Utf16String::formatted("The radius provided ({}) is negative.", radius));
return ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise);
}
@ -103,9 +103,9 @@ WebIDL::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x,
// 2. If either radiusX or radiusY are negative, then throw an "IndexSizeError" DOMException.
if (radius_x < 0)
return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The major-axis radius provided ({}) is negative.", radius_x)));
return WebIDL::IndexSizeError::create(m_self->realm(), Utf16String::formatted("The major-axis radius provided ({}) is negative.", radius_x));
if (radius_y < 0)
return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The minor-axis radius provided ({}) is negative.", radius_y)));
return WebIDL::IndexSizeError::create(m_self->realm(), Utf16String::formatted("The minor-axis radius provided ({}) is negative.", radius_y));
// "If counterclockwise is false and endAngle startAngle is greater than or equal to 2π,
// or, if counterclockwise is true and startAngle endAngle is greater than or equal to 2π,
@ -198,7 +198,7 @@ WebIDL::ExceptionOr<void> CanvasPath::arc_to(double x1, double y1, double x2, do
// 3. If radius is negative, then throw an "IndexSizeError" DOMException.
if (radius < 0)
return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The radius provided ({}) is negative.", radius)));
return WebIDL::IndexSizeError::create(m_self->realm(), Utf16String::formatted("The radius provided ({}) is negative.", radius));
auto transform = active_transform();

View File

@ -20,9 +20,9 @@ WebIDL::ExceptionOr<GC::Ref<CanvasGradient>> CanvasGradient::create_radial(JS::R
{
// 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"_string);
return WebIDL::IndexSizeError::create(realm, "The r0 passed is less than 0"_utf16);
if (r1 < 0)
return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"_string);
return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"_utf16);
auto radial_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1));
return realm.create<CanvasGradient>(realm, *radial_gradient);
@ -61,14 +61,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"_string);
return WebIDL::IndexSizeError::create(realm(), "CanvasGradient color stop offset out of bounds"_utf16);
// 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"_string);
return WebIDL::SyntaxError::create(realm(), "Could not parse color for CanvasGradient"_utf16);
// 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()));

View File

@ -57,7 +57,7 @@ WebIDL::ExceptionOr<GC::Ptr<CanvasPattern>> CanvasPattern::create(JS::Realm& rea
// 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"_string);
return WebIDL::SyntaxError::create(realm, "Repetition value is not valid"_utf16);
// 6. Let pattern be a new CanvasPattern object with the image image and the repetition behavior given by repetition.
auto pattern = TRY_OR_THROW_OOM(realm.vm(), CanvasPatternPaintStyle::create(image, *repetition_value));

View File

@ -426,7 +426,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_d
{
// 1. If one or both of sw and sh are zero, then throw an "IndexSizeError" DOMException.
if (width == 0 || height == 0)
return WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero"_string);
return WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero"_utf16);
int abs_width = abs(width);
int abs_height = abs(height);
@ -459,11 +459,11 @@ WebIDL::ExceptionOr<GC::Ptr<ImageData>> CanvasRenderingContext2D::get_image_data
{
// 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"_string);
return WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero"_utf16);
// 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"_string);
return WebIDL::SecurityError::create(realm(), "CanvasRenderingContext2D is not origin-clean"_utf16);
// ImageData initialization requires positive width and height
// https://html.spec.whatwg.org/multipage/canvas.html#initialize-an-imagedata-object
@ -745,14 +745,14 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
[](GC::Root<OffscreenCanvas> const& offscreen_canvas) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// If image has either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException.
if (offscreen_canvas->width() == 0 || offscreen_canvas->height() == 0)
return WebIDL::InvalidStateError::create(offscreen_canvas->realm(), "OffscreenCanvas width or height is zero"_string);
return WebIDL::InvalidStateError::create(offscreen_canvas->realm(), "OffscreenCanvas width or height is zero"_utf16);
return Optional<CanvasImageSourceUsability> {};
},
// HTMLCanvasElement
[](GC::Root<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"_string);
return WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero"_utf16);
return Optional<CanvasImageSourceUsability> {};
},
@ -760,7 +760,7 @@ WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasI
// FIXME: VideoFrame
[](GC::Root<ImageBitmap> const& image_bitmap) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
if (image_bitmap->is_detached())
return WebIDL::InvalidStateError::create(image_bitmap->realm(), "Image bitmap is detached"_string);
return WebIDL::InvalidStateError::create(image_bitmap->realm(), "Image bitmap is detached"_utf16);
return Optional<CanvasImageSourceUsability> {};
}));
if (usability.has_value())

View File

@ -48,11 +48,11 @@ WebIDL::ExceptionOr<GC::Ref<CloseWatcher>> CloseWatcher::construct_impl(JS::Real
// NOTE: Not in spec explicitly, but this should account for detached iframes too. See /close-watcher/frame-removal.html WPT.
auto navigable = window.navigable();
if (navigable && navigable->has_been_destroyed())
return WebIDL::InvalidStateError::create(realm, "The iframe has been detached"_string);
return WebIDL::InvalidStateError::create(realm, "The iframe has been detached"_utf16);
// 1. If this's relevant global object's associated Document is not fully active, then return an "InvalidStateError" DOMException.
if (!window.associated_document().is_fully_active())
return WebIDL::InvalidStateError::create(realm, "The document is not fully active."_string);
return WebIDL::InvalidStateError::create(realm, "The document is not fully active."_utf16);
// 2. Let close_watcher be the result of establishing a close watcher
auto close_watcher = establish(window);

View File

@ -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(), MUST(String::formatted("Can't access property '{}' on cross-origin object", property_key))));
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), Utf16String::formatted("Can't access property '{}' on cross-origin object", property_key)));
}
// 7.2.3.3 IsPlatformObjectSameOrigin ( O ), https://html.spec.whatwg.org/multipage/nav-history-apis.html#isplatformobjectsameorigin-(-o-)
@ -207,7 +207,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(), MUST(String::formatted("Can't get property '{}' on cross-origin object", property_key))));
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), Utf16String::formatted("Can't get property '{}' on cross-origin object", property_key)));
// 7. Return ? Call(getter, Receiver).
return JS::call(vm, *getter, receiver);
@ -232,7 +232,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(), MUST(String::formatted("Can't set property '{}' on cross-origin object", property_key))));
return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), Utf16String::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-)

View File

@ -124,7 +124,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, MUST(String::formatted("'{}' is not a valid custom element name", name))));
return JS::throw_completion(WebIDL::SyntaxError::create(realm, Utf16String::formatted("'{}' is not a valid custom element name", name)));
// 3. If this's custom element definition set contains an item with name name, then throw a "NotSupportedError" DOMException.
auto existing_definition_with_name_iterator = m_custom_element_definitions.find_if([&name](auto const& definition) {
@ -132,7 +132,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, MUST(String::formatted("A custom element with name '{}' is already defined", name))));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, Utf16String::formatted("A custom element with name '{}' is already defined", name)));
// 4. If this's custom element definition set contains an item with constructor constructor, then throw a "NotSupportedError" DOMException.
auto existing_definition_with_constructor_iterator = m_custom_element_definitions.find_if([&constructor](auto const& definition) {
@ -140,7 +140,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"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "The given constructor is already in use by another custom element"_utf16));
// 5. Let localName be name.
String local_name = name;
@ -152,13 +152,13 @@ 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, MUST(String::formatted("'{}' is a custom element name, only non-custom elements can be extended", extends.value()))));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, Utf16String::formatted("'{}' is a custom element name, only non-custom elements can be extended", 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()))
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("'{}' is an unknown HTML element", extends.value()))));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, Utf16String::formatted("'{}' is an unknown HTML element", extends.value())));
// 3. Set localName to extends.
local_name = extends.value();
@ -166,7 +166,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
// 8. If this's element definition is running is true, then throw a "NotSupportedError" DOMException.
if (m_element_definition_is_running)
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"_string));
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"_utf16));
// 9. Set this's element definition is running to true.
m_element_definition_is_running = true;
@ -363,7 +363,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> CustomElementRegistry::when_define
// 1. If name is not a valid custom element name, then return a promise rejected with a "SyntaxError" DOMException.
if (!is_valid_custom_element_name(name))
return WebIDL::create_rejected_promise(realm, WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name", name))));
return WebIDL::create_rejected_promise(realm, WebIDL::SyntaxError::create(realm, Utf16String::formatted("'{}' is not a valid custom element name", name)));
// 2. If this's custom element definition set contains an item with name name, then return a promise resolved with that item's constructor.
auto existing_definition_iterator = m_custom_element_definitions.find_if([&name](GC::Root<CustomElementDefinition> const& definition) {

View File

@ -147,7 +147,7 @@ WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String c
if (current_character == '-' && character_index + 1 < name_view.length()) {
auto next_character = name_view[character_index + 1];
if (is_ascii_lower_alpha(next_character))
return WebIDL::SyntaxError::create(realm(), "Name cannot contain a '-' followed by a lowercase character."_string);
return WebIDL::SyntaxError::create(realm(), "Name cannot contain a '-' followed by a lowercase character."_utf16);
}
// 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.
@ -164,7 +164,7 @@ WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String c
// 4. If name is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
if (!DOM::is_valid_attribute_local_name(data_name))
return WebIDL::InvalidCharacterError::create(realm(), "Name is not a valid attribute local name."_string);
return WebIDL::InvalidCharacterError::create(realm(), "Name is not a valid attribute local name."_utf16);
// 5. Set an attribute value for the DOMStringMap's associated element using name and value.
TRY(m_associated_element->set_attribute(data_name, value));

View File

@ -66,10 +66,8 @@ WebIDL::ExceptionOr<GC::Ptr<DataTransferItem>> DataTransferItemList::add(String
// If there is already an item in the drag data store item list whose kind is text and whose type string is equal
// to the value of the method's second argument, converted to ASCII lowercase, then throw a "NotSupportedError"
// DOMException.
if (m_data_transfer->contains_item_with_type(DragDataStoreItem::Kind::Text, type)) {
auto error = MUST(String::formatted("There is already a DataTransferItem with type {}", type));
return WebIDL::NotSupportedError::create(realm, error);
}
if (m_data_transfer->contains_item_with_type(DragDataStoreItem::Kind::Text, type))
return WebIDL::NotSupportedError::create(realm, Utf16String::formatted("There is already a DataTransferItem with type {}", type));
// Otherwise, add an item to the drag data store item list whose kind is text, whose type string is equal to the
// value of the method's second argument, converted to ASCII lowercase, and whose data is the string given by the

View File

@ -54,7 +54,7 @@ WebIDL::ExceptionOr<void> ElementInternals::set_form_value(Variant<GC::Root<File
// 2. If element is not a form-associated custom element, then throw a "NotSupportedError" DOMException.
if (!element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
(void)value;
(void)state;
@ -78,10 +78,10 @@ WebIDL::ExceptionOr<GC::Ptr<HTMLFormElement>> ElementInternals::form() const
// On getting, it must throw a "NotSupportedError" DOMException if the target element is not a form-associated custom element.
// Otherwise, it must return the element's form owner, or null if there isn't one.
if (!m_target_element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
dbgln("FIXME: ElementInternals::form()");
return WebIDL::NotFoundError::create(realm(), "FIXME: ElementInternals::form()"_string);
return WebIDL::NotFoundError::create(realm(), "FIXME: ElementInternals::form()"_utf16);
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-setvalidity
@ -92,7 +92,7 @@ WebIDL::ExceptionOr<void> ElementInternals::set_validity(ValidityStateFlags cons
// 2. If element is not a form-associated custom element, then throw a "NotSupportedError" DOMException.
if (!element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
// 3. If flags contains one or more true values and message is not given or is the empty string, then throw a TypeError.
if (flags.has_one_or_more_true_values() && (!message.has_value() || message->is_empty())) {
@ -115,7 +115,7 @@ WebIDL::ExceptionOr<void> ElementInternals::set_validity(ValidityStateFlags cons
// 8. Otherwise, if anchor is not a shadow-including inclusive descendant of element, then throw a "NotFoundError" DOMException.
else if (!anchor.value()->is_shadow_including_inclusive_descendant_of(element)) {
return WebIDL::NotFoundError::create(realm(), "Anchor is not a shadow-including descendant of element"_string);
return WebIDL::NotFoundError::create(realm(), "Anchor is not a shadow-including descendant of element"_utf16);
}
// FIXME: 9. Set element's validation anchor to anchor.
@ -130,7 +130,7 @@ WebIDL::ExceptionOr<bool> ElementInternals::will_validate() const
// the target element is not a form-associated custom element. Otherwise, it must return true if the target element is a
// candidate for constraint validation, and false otherwise.
if (!m_target_element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
dbgln("FIXME: ElementInternals::will_validate()");
return true;
@ -143,10 +143,10 @@ WebIDL::ExceptionOr<GC::Ref<ValidityState const>> ElementInternals::validity() c
// the target element is not a form-associated custom element. Otherwise, it must return a ValidityState object that
// represents the validity states of the target element. This object is live.
if (!m_target_element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
dbgln("FIXME: ElementInternals::validity()");
return WebIDL::NotSupportedError::create(realm(), "FIXME: ElementInternals::validity()"_string);
return WebIDL::NotSupportedError::create(realm(), "FIXME: ElementInternals::validity()"_utf16);
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-validationmessage
@ -157,7 +157,7 @@ WebIDL::ExceptionOr<String> ElementInternals::validation_message() const
// 2. If element is not a form-associated custom element, then throw a "NotSupportedError" DOMException.
if (!element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
// FIXME: 3. Return element's validation message.
@ -173,7 +173,7 @@ WebIDL::ExceptionOr<bool> ElementInternals::check_validity() const
// 2. If element is not a form-associated custom element, then throw a "NotSupportedError" DOMException.
if (!element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
// FIXME: 3. Run the check validity steps on element.
@ -189,7 +189,7 @@ WebIDL::ExceptionOr<bool> ElementInternals::report_validity() const
// 2. If element is not a form-associated custom element, then throw a "NotSupportedError" DOMException.
if (!element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
// FIXME: 3. Run the report validity steps on element.
@ -204,10 +204,10 @@ WebIDL::ExceptionOr<GC::Ptr<DOM::NodeList>> ElementInternals::labels()
// On getting, it must throw a "NotSupportedError" DOMException if the target element is not a form-associated custom element.
// Otherwise, it must return that NodeList object, and that same value must always be returned.
if (!m_target_element->is_form_associated_custom_element())
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a form-associated custom element"_utf16);
dbgln("FIXME: ElementInternals::labels()");
return WebIDL::NotSupportedError::create(realm(), "FIXME: ElementInternals::labels()"_string);
return WebIDL::NotSupportedError::create(realm(), "FIXME: ElementInternals::labels()"_utf16);
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-states

View File

@ -47,7 +47,7 @@ WebIDL::ExceptionOr<GC::Ref<EventSource>> EventSource::construct_impl(JS::Realm&
// 4. If urlRecord is failure, then throw a "SyntaxError" DOMException.
if (!url_record.has_value())
return WebIDL::SyntaxError::create(realm, MUST(String::formatted("Invalid URL '{}'", url)));
return WebIDL::SyntaxError::create(realm, Utf16String::formatted("Invalid URL '{}'", url));
// 5. Set ev's url to urlRecord.
event_source->m_url = url_record.release_value();

View File

@ -478,7 +478,7 @@ WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_selection_start_
if (is<HTMLInputElement>(html_element)) {
auto& input_element = static_cast<HTMLInputElement&>(html_element);
if (!input_element.selection_or_range_applies())
return WebIDL::InvalidStateError::create(html_element.realm(), "setSelectionStart does not apply to this input type"_string);
return WebIDL::InvalidStateError::create(html_element.realm(), "setSelectionStart does not apply to this input type"_utf16);
}
// 2. Let end be the value of this element's selectionEnd attribute.
@ -531,7 +531,7 @@ WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_selection_end_bi
if (is<HTMLInputElement>(html_element)) {
auto& input_element = static_cast<HTMLInputElement&>(html_element);
if (!input_element.selection_or_range_applies())
return WebIDL::InvalidStateError::create(html_element.realm(), "setSelectionEnd does not apply to this input type"_string);
return WebIDL::InvalidStateError::create(html_element.realm(), "setSelectionEnd does not apply to this input type"_utf16);
}
// 2. Set the selection range with the value of this element's selectionStart attribute, the
@ -584,7 +584,7 @@ WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_selection_direct
if (is<HTMLInputElement>(html_element)) {
auto const& input_element = static_cast<HTMLInputElement const&>(html_element);
if (!input_element.selection_direction_applies())
return WebIDL::InvalidStateError::create(input_element.realm(), "selectionDirection does not apply to element"_string);
return WebIDL::InvalidStateError::create(input_element.realm(), "selectionDirection does not apply to element"_utf16);
}
set_the_selection_range(m_selection_start, m_selection_end, string_to_selection_direction(direction));
@ -605,7 +605,7 @@ WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_range_text_bindi
// 1. If this element is an input element, and setRangeText() does not apply to this element,
// throw an "InvalidStateError" DOMException.
if (is<HTMLInputElement>(html_element) && !static_cast<HTMLInputElement&>(html_element).selection_or_range_applies())
return WebIDL::InvalidStateError::create(html_element.realm(), "setRangeText does not apply to this input type"_string);
return WebIDL::InvalidStateError::create(html_element.realm(), "setRangeText does not apply to this input type"_utf16);
return set_range_text(replacement, start, end, selection_mode);
}
@ -624,7 +624,7 @@ WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_range_text(Utf16
// 4. If start is greater than end, then throw an "IndexSizeError" DOMException.
if (start > end)
return WebIDL::IndexSizeError::create(html_element.realm(), "The start argument must be less than or equal to the end argument"_string);
return WebIDL::IndexSizeError::create(html_element.realm(), "The start argument must be less than or equal to the end argument"_utf16);
// 5. If start is greater than the length of the relevant value of the text control, then set it to the length of the relevant value of the text control.
auto the_relevant_value = relevant_value();
@ -731,7 +731,7 @@ WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_selection_range(
// element, throw an "InvalidStateError" DOMException.
auto& html_element = form_associated_element_to_html_element();
if (is<HTMLInputElement>(html_element) && !static_cast<HTMLInputElement&>(html_element).selection_or_range_applies())
return WebIDL::InvalidStateError::create(html_element.realm(), "setSelectionRange does not apply to this input type"_string);
return WebIDL::InvalidStateError::create(html_element.realm(), "setSelectionRange does not apply to this input type"_utf16);
// 2. Set the selection range with start, end, and direction.
set_the_selection_range(start, end, string_to_selection_direction(direction));

View File

@ -110,7 +110,7 @@ WebIDL::ExceptionOr<void> HTMLDialogElement::show()
// 2. If this has an open attribute, then throw an "InvalidStateError" DOMException.
if (has_attribute(AttributeNames::open))
return WebIDL::InvalidStateError::create(realm(), "Dialog already open"_string);
return WebIDL::InvalidStateError::create(realm(), "Dialog already open"_utf16);
// 3. If the result of firing an event named beforetoggle, using ToggleEvent,
// with the cancelable attribute initialized to true, the oldState attribute initialized to "closed",
@ -185,19 +185,19 @@ WebIDL::ExceptionOr<void> HTMLDialogElement::show_a_modal_dialog(HTMLDialogEleme
// 2. If subject has an open attribute, then throw an "InvalidStateError" DOMException.
if (subject.has_attribute(AttributeNames::open))
return WebIDL::InvalidStateError::create(realm, "Dialog already open"_string);
return WebIDL::InvalidStateError::create(realm, "Dialog already open"_utf16);
// 3. If subject's node document is not fully active, then throw an "InvalidStateError" DOMException.
if (!subject.document().is_fully_active())
return WebIDL::InvalidStateError::create(realm, "Document is not fully active"_string);
return WebIDL::InvalidStateError::create(realm, "Document is not fully active"_utf16);
// 4. If subject is not connected, then throw an "InvalidStateError" DOMException.
if (!subject.is_connected())
return WebIDL::InvalidStateError::create(realm, "Dialog not connected"_string);
return WebIDL::InvalidStateError::create(realm, "Dialog not connected"_utf16);
// 5. If subject is in the popover showing state, then throw an "InvalidStateError" DOMException.
if (subject.popover_visibility_state() == PopoverVisibilityState::Showing)
return WebIDL::InvalidStateError::create(realm, "Dialog already open as popover"_string);
return WebIDL::InvalidStateError::create(realm, "Dialog already open as popover"_utf16);
// 6. If the result of firing an event named beforetoggle, using ToggleEvent,
// with the cancelable attribute initialized to true, the oldState attribute initialized to "closed",

View File

@ -193,7 +193,7 @@ WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(StringView content_e
MUST(set_attribute(HTML::AttributeNames::contenteditable, "false"_string));
return {};
}
return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', 'plaintext-only' or 'inherit'"_string);
return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', 'plaintext-only' or 'inherit'"_utf16);
}
// https://html.spec.whatwg.org/multipage/dom.html#set-the-inner-text-steps
@ -230,7 +230,7 @@ WebIDL::ExceptionOr<void> HTMLElement::set_outer_text(Utf16View const& value)
{
// 1. If this's parent is null, then throw a "NoModificationAllowedError" DOMException.
if (!parent())
return WebIDL::NoModificationAllowedError::create(realm(), "setOuterText: parent is null"_string);
return WebIDL::NoModificationAllowedError::create(realm(), "setOuterText: parent is null"_utf16);
// 2. Let next be this's next sibling.
auto* next = next_sibling();
@ -1123,26 +1123,26 @@ WebIDL::ExceptionOr<GC::Ref<ElementInternals>> HTMLElement::attach_internals()
{
// 1. If this's is value is not null, then throw a "NotSupportedError" DOMException.
if (is_value().has_value())
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to a customized built-in element"_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to a customized built-in element"_utf16);
// 2. Let definition be the result of looking up a custom element definition given this's node document, its namespace, its local name, and null as the is value.
auto definition = document().lookup_custom_element_definition(namespace_uri(), local_name(), is_value());
// 3. If definition is null, then throw an "NotSupportedError" DOMException.
if (!definition)
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to an element that is not a custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to an element that is not a custom element"_utf16);
// 4. If definition's disable internals is true, then throw a "NotSupportedError" DOMException.
if (definition->disable_internals())
return WebIDL::NotSupportedError::create(realm(), "ElementInternals are disabled for this custom element"_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals are disabled for this custom element"_utf16);
// 5. If this's attached internals is non-null, then throw an "NotSupportedError" DOMException.
if (m_attached_internals)
return WebIDL::NotSupportedError::create(realm(), "ElementInternals already attached"_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals already attached"_utf16);
// 6. If this's custom element state is not "precustomized" or "custom", then throw a "NotSupportedError" DOMException.
if (!first_is_one_of(custom_element_state(), DOM::CustomElementState::Precustomized, DOM::CustomElementState::Custom))
return WebIDL::NotSupportedError::create(realm(), "Custom element is in an invalid state to attach ElementInternals"_string);
return WebIDL::NotSupportedError::create(realm(), "Custom element is in an invalid state to attach ElementInternals"_utf16);
// 7. Set this's attached internals to a new ElementInternals instance whose target element is this.
auto internals = ElementInternals::create(realm(), *this);
@ -1205,7 +1205,7 @@ WebIDL::ExceptionOr<bool> HTMLElement::check_popover_validity(ExpectedToBeShowin
if (ignore_dom_state == IgnoreDomState::No && !popover().has_value()) {
// 1.1. If throwExceptions is true, then throw a "NotSupportedError" DOMException.
if (throw_exceptions == ThrowExceptions::Yes)
return WebIDL::NotSupportedError::create(realm(), "Element is not a popover"_string);
return WebIDL::NotSupportedError::create(realm(), "Element is not a popover"_utf16);
// 1.2. Return false.
return false;
}
@ -1233,7 +1233,7 @@ WebIDL::ExceptionOr<bool> HTMLElement::check_popover_validity(ExpectedToBeShowin
|| (ignore_dom_state == IgnoreDomState::No && expected_document && &document() != expected_document)
|| (is<HTMLDialogElement>(*this) && as<HTMLDialogElement>(*this).is_modal())) {
if (throw_exceptions == ThrowExceptions::Yes)
return WebIDL::InvalidStateError::create(realm(), "Element is not in a valid state to show a popover"_string);
return WebIDL::InvalidStateError::create(realm(), "Element is not in a valid state to show a popover"_utf16);
return false;
}
@ -1380,7 +1380,7 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
if (original_type != popover()) {
// 1. If throwExceptions is true, then throw an "InvalidStateError" DOMException.
if (throw_exceptions == ThrowExceptions::Yes)
return WebIDL::InvalidStateError::create(realm(), "Element is not in a valid state to show a popover"_string);
return WebIDL::InvalidStateError::create(realm(), "Element is not in a valid state to show a popover"_utf16);
// 2. Return.
return {};

View File

@ -380,7 +380,7 @@ WebIDL::ExceptionOr<void> HTMLFormElement::request_submit(GC::Ptr<Element> submi
// 2. If submitter's form owner is not this form element, then throw a "NotFoundError" DOMException.
if (form_associated_element->form() != this)
return WebIDL::NotFoundError::create(realm(), "The submitter is not owned by this form element"_string);
return WebIDL::NotFoundError::create(realm(), "The submitter is not owned by this form element"_utf16);
}
// 2. Otherwise, set submitter to this form element.
else {

View File

@ -352,7 +352,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> HTMLImageElement::decode() const
if (this->document().is_fully_active())
return false;
auto exception = WebIDL::EncodingError::create(realm, "Node document not fully active"_string);
auto exception = WebIDL::EncodingError::create(realm, "Node document not fully active"_utf16);
HTML::TemporaryExecutionContext context(realm);
WebIDL::reject_promise(realm, promise, exception);
return true;
@ -362,7 +362,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> HTMLImageElement::decode() const
if (this->current_request().state() != ImageRequest::State::Broken)
return false;
auto exception = WebIDL::EncodingError::create(realm, "Current request state is broken"_string);
auto exception = WebIDL::EncodingError::create(realm, "Current request state is broken"_utf16);
HTML::TemporaryExecutionContext context(realm);
WebIDL::reject_promise(realm, promise, exception);
return true;
@ -379,8 +379,8 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> HTMLImageElement::decode() const
// 3. Otherwise, in parallel wait for one of the following cases to occur, and perform the corresponding actions:
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(heap(), [this, promise, &realm, &global] {
Platform::EventLoopPlugin::the().spin_until(GC::create_function(heap(), [this, promise, &realm, &global] {
auto queue_reject_task = [promise, &realm, &global](String const& message) {
queue_global_task(Task::Source::DOMManipulation, global, GC::create_function(realm.heap(), [&realm, promise, message = String(message)] {
auto queue_reject_task = [promise, &realm, &global](Utf16String message) {
queue_global_task(Task::Source::DOMManipulation, global, GC::create_function(realm.heap(), [&realm, promise, message = move(message)] {
auto exception = WebIDL::EncodingError::create(realm, message);
HTML::TemporaryExecutionContext context(realm);
WebIDL::reject_promise(realm, promise, exception);
@ -390,7 +390,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> HTMLImageElement::decode() const
// -> This img element's node document stops being fully active
if (!document().is_fully_active()) {
// Queue a global task on the DOM manipulation task source with global to reject promise with an "EncodingError" DOMException.
queue_reject_task("Node document not fully active"_string);
queue_reject_task("Node document not fully active"_utf16);
return true;
}
@ -399,14 +399,14 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> HTMLImageElement::decode() const
// -> FIXME: This img element's current request changes or is mutated
if (false) {
// Queue a global task on the DOM manipulation task source with global to reject promise with an "EncodingError" DOMException.
queue_reject_task("Current request changed or was mutated"_string);
queue_reject_task("Current request changed or was mutated"_utf16);
return true;
}
// -> This img element's current request's state becomes broken
if (state == ImageRequest::State::Broken) {
// Queue a global task on the DOM manipulation task source with global to reject promise with an "EncodingError" DOMException.
queue_reject_task("Current request state is broken"_string);
queue_reject_task("Current request state is broken"_utf16);
return true;
}

View File

@ -417,7 +417,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::show_picker()
// 1. If this is not mutable, then throw an "InvalidStateError" DOMException.
if (!is_mutable())
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_string);
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_utf16);
// 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.
@ -425,14 +425,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.value())
&& m_type != TypeAttributeState::FileUpload && m_type != TypeAttributeState::Color) {
return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"_string);
return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"_utf16);
}
// 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"_string);
return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"_utf16);
}
// 4. Show the picker, if applicable, for this.
@ -727,7 +727,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_value(Utf16String const& value)
case ValueAttributeMode::Filename:
// 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"_string);
return WebIDL::InvalidStateError::create(realm, "Setting value of input type file to non-empty string"_utf16);
m_selected_files = nullptr;
break;
@ -2141,7 +2141,7 @@ WebIDL::UnsignedLong HTMLInputElement::size() const
WebIDL::ExceptionOr<void> HTMLInputElement::set_size(WebIDL::UnsignedLong value)
{
if (value == 0)
return WebIDL::IndexSizeError::create(realm(), "Size must be greater than zero"_string);
return WebIDL::IndexSizeError::create(realm(), "Size must be greater than zero"_utf16);
if (value > 2147483647)
value = 20;
return set_attribute(HTML::AttributeNames::size, String::number(value));
@ -2683,7 +2683,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_value_as_date(Optional<GC::Root<
{
// On setting, if the valueAsDate attribute does not apply, as defined for the input element's type attribute's current state, then throw an "InvalidStateError" DOMException;
if (!value_as_date_applies())
return WebIDL::InvalidStateError::create(realm(), "valueAsDate: Invalid input type used"_string);
return WebIDL::InvalidStateError::create(realm(), "valueAsDate: Invalid input type used"_utf16);
// otherwise, if the new value is not null and not a Date object throw a TypeError exception;
if (value.has_value() && !is<JS::Date>(**value))
@ -2726,7 +2726,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_value_as_number(double value)
// Otherwise, if the valueAsNumber attribute does not apply, as defined for the input element's type attribute's current state, then throw an "InvalidStateError" DOMException.
if (!value_as_number_applies())
return WebIDL::InvalidStateError::create(realm(), "valueAsNumber: Invalid input type used"_string);
return WebIDL::InvalidStateError::create(realm(), "valueAsNumber: Invalid input type used"_utf16);
// Otherwise, if the new value is a Not-a-Number (NaN) value, then set the value of the element to the empty string.
if (value == NAN) {
@ -2756,12 +2756,12 @@ WebIDL::ExceptionOr<void> HTMLInputElement::step_up_or_down(bool is_down, WebIDL
{
// 1. If the stepDown() and stepUp() methods do not apply, as defined for the input element's type attribute's current state, then throw an "InvalidStateError" DOMException.
if (!step_up_or_down_applies())
return WebIDL::InvalidStateError::create(realm(), MUST(String::formatted("{}: Invalid input type used", is_down ? "stepDown()" : "stepUp()")));
return WebIDL::InvalidStateError::create(realm(), Utf16String::formatted("{}: Invalid input type used", is_down ? "stepDown()" : "stepUp()"));
// 2. If the element has no allowed value step, then throw an "InvalidStateError" DOMException.
auto maybe_allowed_value_step = allowed_value_step();
if (!maybe_allowed_value_step.has_value())
return WebIDL::InvalidStateError::create(realm(), "element has no allowed value step"_string);
return WebIDL::InvalidStateError::create(realm(), "element has no allowed value step"_utf16);
double allowed_value_step = *maybe_allowed_value_step;
// 3. If the element has a minimum and a maximum and the minimum is greater than the maximum, then return.

View File

@ -361,8 +361,8 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::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 exception = WebIDL::NotSupportedError::create(realm, m_error->message());
return WebIDL::create_rejected_promise_from_exception(realm, move(exception));
auto exception = WebIDL::NotSupportedError::create(realm, Utf16String::from_utf8(m_error->message()));
return WebIDL::create_rejected_promise_from_exception(realm, exception);
}
// 3. Let promise be a new promise and append promise to the list of pending play promises.
@ -413,7 +413,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"_string);
return WebIDL::IndexSizeError::create(realm(), "Volume must be in the range 0.0 to 1.0, inclusive"_utf16);
m_volume = volume;
volume_or_muted_attribute_changed();
@ -566,7 +566,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::load_element()
// 2. Take pending play promises and reject pending play promises with the result and an "AbortError" DOMException.
auto promises = take_pending_play_promises();
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback was aborted"_string);
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback was aborted"_utf16);
}
// 7. If seeking is true, set it to false.
@ -1312,7 +1312,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::handle_media_source_failure(Span<GC:
dispatch_event(DOM::Event::create(realm, HTML::EventNames::error));
// 6. Reject pending play promises with promises and a "NotSupportedError" DOMException.
reject_pending_play_promises<WebIDL::NotSupportedError>(promises, "Media is not supported"_string);
reject_pending_play_promises<WebIDL::NotSupportedError>(promises, "Media is not supported"_utf16);
// 7. Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
m_delaying_the_load_event.clear();
@ -1538,7 +1538,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::pause_element()
dispatch_event(DOM::Event::create(realm, HTML::EventNames::pause));
// 3. Reject pending play promises with promises and an "AbortError" DOMException.
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback was paused"_string);
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback was paused"_utf16);
});
// 4. Set the official playback position to the current playback position.
@ -1733,7 +1733,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::set_playback_rate(double new_value)
// 1. If the given value is not supported by the user agent, then throw a "NotSupportedError" DOMException.
// FIXME: We need to support playback rates other than 1 for this to be even remotely useful.
if (new_value != 1.0)
return WebIDL::NotSupportedError::create(realm(), "Playback rates other than 1 are not supported."_string);
return WebIDL::NotSupportedError::create(realm(), "Playback rates other than 1 are not supported."_utf16);
// When the defaultPlaybackRate or playbackRate attributes change value (either by being set by script or by being changed directly by the user agent, e.g. in response to user
// control), the user agent must queue a media element task given the media element to fire an event named ratechange at the media element.
@ -1867,7 +1867,7 @@ void HTMLMediaElement::reached_end_of_media_playback()
// 3. Take pending play promises and reject pending play promises with the result and an "AbortError" DOMException.
auto promises = take_pending_play_promises();
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback has ended"_string);
reject_pending_play_promises<WebIDL::AbortError>(promises, "Media playback has ended"_utf16);
}
});

View File

@ -231,7 +231,7 @@ private:
// https://html.spec.whatwg.org/multipage/media.html#reject-pending-play-promises
template<typename ErrorType>
void reject_pending_play_promises(ReadonlySpan<GC::Ref<WebIDL::Promise>> promises, String message)
void reject_pending_play_promises(ReadonlySpan<GC::Ref<WebIDL::Promise>> promises, Utf16String message)
{
auto& realm = this->realm();

View File

@ -88,7 +88,7 @@ WebIDL::ExceptionOr<void> HTMLOptionsCollection::set_value_of_indexed_property(u
}
if (!unconverted_option.is_object() || !is<HTMLOptionElement>(unconverted_option.as_object())) {
return WebIDL::TypeMismatchError::create(realm(), "The value provided is not an HTMLOptionElement"_string);
return WebIDL::TypeMismatchError::create(realm(), "The value provided is not an HTMLOptionElement"_utf16);
}
auto& option = static_cast<HTMLOptionElement&>(unconverted_option.as_object());
@ -133,11 +133,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."_string);
return WebIDL::HierarchyRequestError::create(realm(), "The provided element is an ancestor of the root select element."_utf16);
// 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."_string);
return WebIDL::NotFoundError::create(realm(), "The 'before' element is not a descendant of the root select element."_utf16);
// 3. If element and before are the same element, then return.
if (before_element && (resolved_element.ptr() == before_element.ptr()))

View File

@ -495,18 +495,18 @@ WebIDL::ExceptionOr<void> HTMLSelectElement::show_picker()
// 1. If this is not mutable, then throw an "InvalidStateError" DOMException.
if (!enabled())
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_string);
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_utf16);
// 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 is a select element, then throw a "SecurityError" DOMException.
if (!relevant_settings_object(*this).origin().is_same_origin(relevant_settings_object(*this).top_level_origin.value())) {
return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"_string);
return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"_utf16);
}
// 3. If this's relevant global object does not have transient activation, then throw a "NotAllowedError" DOMException.
auto& global_object = relevant_global_object(*this);
if (!as<HTML::Window>(global_object).has_transient_activation()) {
return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"_string);
return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"_utf16);
}
// FIXME: 4. If this is a select element, and this is not being rendered, then throw a "NotSupportedError" DOMException.

View File

@ -228,7 +228,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"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Element is not thead"_utf16);
// 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,
@ -326,7 +326,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"_string);
return WebIDL::HierarchyRequestError::create(realm(), "Element is not tfoot"_utf16);
// 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,
@ -438,7 +438,7 @@ WebIDL::ExceptionOr<GC::Ref<HTMLTableRowElement>> HTMLTableElement::insert_row(W
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"_string);
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_utf16);
}
auto& tr = static_cast<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
if (rows_length == 0 && !has_child_of_type<HTMLTableRowElement>()) {
@ -465,7 +465,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::delete_row(WebIDL::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"_string);
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"_utf16);
// 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) {

View File

@ -151,7 +151,7 @@ WebIDL::ExceptionOr<GC::Ref<HTMLTableCellElement>> HTMLTableRowElement::insert_c
// 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"_string);
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells"_utf16);
// 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)));
@ -176,7 +176,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"_string);
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of cells"_utf16);
// 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) {

View File

@ -62,7 +62,7 @@ WebIDL::ExceptionOr<GC::Ref<HTMLTableRowElement>> HTMLTableSectionElement::inser
// 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"_string);
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_utf16);
// 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)));
@ -86,7 +86,7 @@ WebIDL::ExceptionOr<void> HTMLTableSectionElement::delete_row(WebIDL::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"_string);
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"_utf16);
// 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) {

View File

@ -61,7 +61,7 @@ WebIDL::ExceptionOr<u64> History::length() const
{
// 1. If this's relevant global object's associated Document is not fully active, then throw a "SecurityError" DOMException.
if (!as<Window>(relevant_global_object(*this)).associated_document().is_fully_active())
return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."_string);
return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."_utf16);
// 2. Return this's length.
return m_length;
@ -72,7 +72,7 @@ WebIDL::ExceptionOr<JS::Value> History::state() const
{
// 1. If this's relevant global object's associated Document is not fully active, then throw a "SecurityError" DOMException.
if (!as<Window>(relevant_global_object(*this)).associated_document().is_fully_active())
return WebIDL::SecurityError::create(realm(), "Cannot perform state on a document that isn't fully active."_string);
return WebIDL::SecurityError::create(realm(), "Cannot perform state on a document that isn't fully active."_utf16);
// 2. Return this's state.
return m_state;
@ -91,7 +91,7 @@ WebIDL::ExceptionOr<void> History::delta_traverse(WebIDL::Long delta)
// 2. If document is not fully active, then throw a "SecurityError" DOMException.
if (!document.is_fully_active())
return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."_string);
return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."_utf16);
// 3. If delta is 0, then reload document's node navigable, and return.
if (delta == 0) {
@ -178,7 +178,7 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value d
// 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."_string);
return WebIDL::SecurityError::create(realm(), "Cannot perform pushState or replaceState on a document that isn't fully active."_utf16);
// 3. Optionally, throw a "SecurityError" DOMException. (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
@ -201,14 +201,14 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value d
// 2. If that fails, then throw a "SecurityError" DOMException.
if (!parsed_url.has_value())
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_string);
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_utf16);
// 3. Set newURL to the resulting URL record.
new_url = parsed_url.release_value();
// 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"_string);
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_utf16);
}
// 7. Let navigation be history's relevant global object's navigation API.
@ -236,7 +236,7 @@ WebIDL::ExceptionOr<Bindings::ScrollRestoration> History::scroll_restoration() c
// 1. If this's relevant global object's associated Document is not fully active, then throw a "SecurityError" DOMException.
auto& this_relevant_global_object = as<Window>(relevant_global_object(*this));
if (!this_relevant_global_object.associated_document().is_fully_active())
return WebIDL::SecurityError::create(realm(), "Cannot obtain scroll restoration mode for a document that isn't fully active."_string);
return WebIDL::SecurityError::create(realm(), "Cannot obtain scroll restoration mode for a document that isn't fully active."_utf16);
// 2. Return this's relevant global object's navigable's active session history entry's scroll restoration mode.
auto scroll_restoration_mode = this_relevant_global_object.navigable()->active_session_history_entry()->scroll_restoration_mode();
@ -255,7 +255,7 @@ WebIDL::ExceptionOr<void> History::set_scroll_restoration(Bindings::ScrollRestor
// 1. If this's relevant global object's associated Document is not fully active, then throw a "SecurityError" DOMException.
auto& this_relevant_global_object = as<Window>(relevant_global_object(*this));
if (!this_relevant_global_object.associated_document().is_fully_active())
return WebIDL::SecurityError::create(realm(), "Cannot set scroll restoration mode for a document that isn't fully active."_string);
return WebIDL::SecurityError::create(realm(), "Cannot set scroll restoration mode for a document that isn't fully active."_utf16);
// 2. Set this's relevant global object's navigable's active session history entry's scroll restoration mode to the given value.
auto active_session_history_entry = this_relevant_global_object.navigable()->active_session_history_entry();

View File

@ -34,7 +34,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> ImageData::create(JS::Realm& realm, u32
{
// 1. If one or both of sw and sh are zero, then throw an "IndexSizeError" DOMException.
if (sw == 0 || sh == 0)
return WebIDL::IndexSizeError::create(realm, "The source width and height must be greater than zero."_string);
return WebIDL::IndexSizeError::create(realm, "The source width and height must be greater than zero."_utf16);
// 2. Initialize this given sw, sh, and settings set to settings.
// 3. Initialize the image data of this to transparent black.
@ -61,7 +61,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> ImageData::create(JS::Realm& realm, GC::
// 2. If length is not a nonzero integral multiple of four, then throw an "InvalidStateError" DOMException.
if (length == 0 || length % 4 != 0)
return WebIDL::InvalidStateError::create(realm, "Source data must have a non-sero length that is a multiple of four."_string);
return WebIDL::InvalidStateError::create(realm, "Source data must have a non-sero length that is a multiple of four."_utf16);
// 3. Let length be length divided by four.
length = length / 4;
@ -70,14 +70,14 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> ImageData::create(JS::Realm& realm, GC::
// NOTE: At this step, the length is guaranteed to be greater than zero (otherwise the second step above would have aborted the steps),
// so if sw is zero, this step will throw the exception and return.
if (sw == 0 || length % sw != 0)
return WebIDL::IndexSizeError::create(realm, "Source width must be a multiple of source data's length."_string);
return WebIDL::IndexSizeError::create(realm, "Source width must be a multiple of source data's length."_utf16);
// 5. Let height be length divided by sw.
auto height = length / sw;
// 6. If sh was given and its value is not equal to height, then throw an "IndexSizeError" DOMException.
if (sh.has_value() && sh.value() != height)
return WebIDL::IndexSizeError::create(realm, "Source height must be equal to the calculated height of the data."_string);
return WebIDL::IndexSizeError::create(realm, "Source height must be equal to the calculated height of the data."_utf16);
// 7. Initialize this given sw, sh, settings set to settings, and source set to data.
// FIXME: This seems to be a spec issue, sh is an optional but height always have a value.
@ -102,7 +102,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> ImageData::initialize(JS::Realm& realm,
size *= pixels_per_row;
size *= sizeof(u32);
if (size.has_overflow())
return WebIDL::IndexSizeError::create(realm, "The specified image size could not created"_string);
return WebIDL::IndexSizeError::create(realm, "The specified image size could not created"_utf16);
// 2. Otherwise (source was not given), initialize the data attribute of imageData to a new Uint8ClampedArray object.
// The Uint8ClampedArray object must use a new Canvas Pixel ArrayBuffer for its storage, and must have a zero start

View File

@ -123,7 +123,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 2. Return this's url, serialized.
return url().serialize();
@ -144,7 +144,7 @@ WebIDL::ExceptionOr<void> Location::set_href(String const& new_href)
// 3. If url is failure, then throw a "SyntaxError" DOMException.
if (!url.has_value())
return WebIDL::SyntaxError::create(realm, MUST(String::formatted("Invalid URL '{}'", new_href)));
return WebIDL::SyntaxError::create(realm, Utf16String::formatted("Invalid URL '{}'", new_href));
// 4. Location-object navigate this to url.
TRY(navigate(url.release_value()));
@ -158,7 +158,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 2. Return the serialization of this's url's origin.
return url().origin().serialize();
@ -172,7 +172,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 2. Return this's url's scheme, followed by ":".
return TRY_OR_THROW_OOM(vm, String::formatted("{}:", url().scheme()));
@ -189,7 +189,7 @@ WebIDL::ExceptionOr<void> Location::set_protocol(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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -199,7 +199,7 @@ WebIDL::ExceptionOr<void> Location::set_protocol(String const& value)
// 5. If possibleFailure is failure, then throw a "SyntaxError" DOMException.
if (!possible_failure.has_value())
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Failed to set protocol. '{}' is an invalid protocol", value)));
return WebIDL::SyntaxError::create(realm(), Utf16String::formatted("Failed to set protocol. '{}' is an invalid protocol", value));
// 6. if copyURL's scheme is not an HTTP(S) scheme, then terminate these steps.
if (!(copy_url.scheme() == "http"sv || copy_url.scheme() == "https"sv))
@ -219,7 +219,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 2. Let url be this's url.
auto url = this->url();
@ -246,7 +246,7 @@ WebIDL::ExceptionOr<void> Location::set_host(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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -270,7 +270,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
auto url = this->url();
@ -292,7 +292,7 @@ WebIDL::ExceptionOr<void> Location::set_hostname(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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -316,7 +316,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
auto url = this->url();
@ -338,7 +338,7 @@ WebIDL::ExceptionOr<void> Location::set_port(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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -368,7 +368,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 2. Return the result of URL path serializing this Location object's url.
return url().serialize_path();
@ -384,7 +384,7 @@ WebIDL::ExceptionOr<void> Location::set_pathname(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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -413,7 +413,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
auto url = this->url();
@ -437,7 +437,7 @@ WebIDL::ExceptionOr<void> Location::set_search(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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -473,7 +473,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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
auto url = this->url();
@ -495,7 +495,7 @@ WebIDL::ExceptionOr<void> Location::set_hash(StringView 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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 3. Let copyURL be a copy of this's url.
auto copy_url = this->url();
@ -548,7 +548,7 @@ WebIDL::ExceptionOr<void> Location::replace(String const& url)
// 2. Parse url relative to the entry settings object. If that failed, throw a "SyntaxError" DOMException.
auto replace_url = entry_settings_object().parse_url(url);
if (!replace_url.has_value())
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url)));
return WebIDL::SyntaxError::create(realm(), Utf16String::formatted("Invalid URL '{}'", url));
// 3. Location-object navigate this to the resulting URL record given "replace".
TRY(navigate(replace_url.release_value(), Bindings::NavigationHistoryBehavior::Replace));
@ -566,12 +566,12 @@ WebIDL::ExceptionOr<void> Location::assign(String const& url)
// 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"_string);
return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_utf16);
// 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.has_value())
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url)));
return WebIDL::SyntaxError::create(realm(), Utf16String::formatted("Invalid URL '{}'", url));
// 4. Location-object navigate this to the resulting URL record.
TRY(navigate(assign_url.release_value()));
@ -655,7 +655,7 @@ JS::ThrowCompletionOr<bool> Location::internal_define_own_property(JS::PropertyK
}
// 2. Throw a "SecurityError" DOMException.
return throw_completion(WebIDL::SecurityError::create(realm(), MUST(String::formatted("Can't define property '{}' on cross-origin object", property_key))));
return throw_completion(WebIDL::SecurityError::create(realm(), Utf16String::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
@ -692,7 +692,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(), MUST(String::formatted("Can't delete property '{}' on cross-origin object", property_key))));
return throw_completion(WebIDL::SecurityError::create(realm(), Utf16String::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

View File

@ -245,7 +245,7 @@ WebIDL::ExceptionOr<void> MessagePort::message_port_post_message_steps(GC::Ptr<M
// 2. If transfer contains this MessagePort, then throw a "DataCloneError" DOMException.
for (auto const& handle : transfer) {
if (handle == this)
return WebIDL::DataCloneError::create(realm, "Cannot transfer a MessagePort to itself"_string);
return WebIDL::DataCloneError::create(realm, "Cannot transfer a MessagePort to itself"_utf16);
}
// 3. Let doomed be false.

View File

@ -1504,7 +1504,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
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"_string);
return WebIDL::SecurityError::create(realm, "Source document's node navigable is not allowed to navigate"_utf16);
}
// 2 Return.

View File

@ -85,11 +85,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"_string);
return WebIDL::SecurityError::create(realm, "NavigateEvent cannot be intercepted"_utf16);
// 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"_string);
return WebIDL::InvalidStateError::create(realm, "NavigationEvent is not dispatched yet"_utf16);
// 4. Assert: this's interception state is either "none" or "intercepted".
VERIFY(m_interception_state == InterceptionState::None || m_interception_state == InterceptionState::Intercepted);
@ -143,7 +143,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"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot scroll NavigationEvent that is not committed"_utf16);
// 3. Process scroll behavior given this.
process_scroll_behavior();
@ -160,15 +160,15 @@ WebIDL::ExceptionOr<void> NavigateEvent::perform_shared_checks()
// then throw an "InvalidStateError" DOMException.
auto& associated_document = as<HTML::Window>(relevant_global_object(*this)).associated_document();
if (!associated_document.is_fully_active())
return WebIDL::InvalidStateError::create(realm(), "Document is not fully active"_string);
return WebIDL::InvalidStateError::create(realm(), "Document is not fully active"_utf16);
// 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"_string);
return WebIDL::SecurityError::create(realm(), "NavigateEvent is not trusted"_utf16);
// 3. If event's canceled flag is set, then throw an "InvalidStateError" DOMException.
if (this->cancelled())
return WebIDL::InvalidStateError::create(realm(), "NavigateEvent already cancelled"_string);
return WebIDL::InvalidStateError::create(realm(), "NavigateEvent already cancelled"_utf16);
return {};
}

View File

@ -134,7 +134,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"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot update current NavigationHistoryEntry when there is no current entry"_utf16);
// 3. Let serializedState be StructuredSerializeForStorage(options["state"]), rethrowing any exceptions.
auto serialized_state = TRY(structured_serialize_for_storage(vm(), options.state));
@ -231,7 +231,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.has_value())
return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL"_string));
return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL"_utf16));
// 2. Let document be this's relevant global object's associated Document.
auto& document = as<HTML::Window>(relevant_global_object(*this)).associated_document();
@ -239,7 +239,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.value(), document))
return early_error_result(WebIDL::NotSupportedError::create(realm, "Navigation must be a replace, but push was requested"_string));
return early_error_result(WebIDL::NotSupportedError::create(realm, "Navigation must be a replace, but push was requested"_utf16));
// 4. Let state be options["state"], if it exists; otherwise, undefined.
auto state = options.state.value_or(JS::js_undefined());
@ -257,11 +257,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_utf16));
// 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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_utf16));
// 8. Let info be options["info"], if it exists; otherwise, undefined.
auto info = options.info.value_or(JS::js_undefined());
@ -287,7 +287,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"_string));
return early_error_result(WebIDL::AbortError::create(realm, "Navigation aborted"_utf16));
}
// 12. Return a navigation API method tracker-derived result for apiMethodTracker.
@ -330,11 +330,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_utf16));
// 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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_utf16));
// 7. Let info be options["info"], if it exists; otherwise, undefined.
auto info = options.info.value_or(JS::js_undefined());
@ -357,7 +357,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: no current session history entry"_utf16));
// 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.
@ -365,7 +365,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: key not found in session history list"_utf16));
// 3. Return the result of performing a navigation API traversal given this, key, and options.
return perform_a_navigation_api_traversal(key, options);
@ -379,7 +379,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate back: no previous session history entry"_utf16));
// 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();
@ -397,7 +397,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate forward: no next session history entry"_utf16));
// 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();
@ -624,11 +624,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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_utf16));
// 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"_string));
return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_utf16));
// 4. Let current be the current entry of navigation.
auto current = current_entry();
@ -681,7 +681,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
auto& reject_realm = relevant_realm(*this);
TemporaryExecutionContext execution_context { reject_realm };
WebIDL::reject_promise(reject_realm, api_method_tracker->finished_promise,
WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"_string));
WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"_utf16));
}));
// 2. Abort these steps.
@ -712,7 +712,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
if (result == TraversableNavigable::HistoryStepResult::CanceledByBeforeUnload) {
queue_global_task(Task::Source::NavigationAndTraversal, global, GC::create_function(heap(), [this, api_method_tracker, &realm] {
TemporaryExecutionContext execution_context { realm };
reject_the_finished_promise(api_method_tracker, WebIDL::AbortError::create(realm, "Navigation cancelled by beforeunload"_string));
reject_the_finished_promise(api_method_tracker, WebIDL::AbortError::create(realm, "Navigation cancelled by beforeunload"_utf16));
}));
}
@ -722,7 +722,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
if (result == TraversableNavigable::HistoryStepResult::InitiatorDisallowed) {
queue_global_task(Task::Source::NavigationAndTraversal, global, GC::create_function(heap(), [this, api_method_tracker, &realm] {
TemporaryExecutionContext execution_context { realm };
reject_the_finished_promise(api_method_tracker, WebIDL::SecurityError::create(realm, "Navigation disallowed from this origin"_string));
reject_the_finished_promise(api_method_tracker, WebIDL::SecurityError::create(realm, "Navigation disallowed from this origin"_utf16));
}));
}
}));
@ -752,7 +752,7 @@ void Navigation::abort_the_ongoing_navigation(GC::Ptr<WebIDL::DOMException> erro
// 5. If error was not given, then let error be a new "AbortError" DOMException created in navigation's relevant realm.
if (!error)
error = WebIDL::AbortError::create(realm, "Navigation aborted"_string);
error = WebIDL::AbortError::create(realm, "Navigation aborted"_utf16);
VERIFY(error);

View File

@ -361,7 +361,7 @@ bool is_valid_floating_point_number(Utf16String const& string)
WebIDL::ExceptionOr<String> convert_non_negative_integer_to_string(JS::Realm& realm, WebIDL::Long value)
{
if (value < 0)
return WebIDL::IndexSizeError::create(realm, "The attribute is limited to only non-negative numbers"_string);
return WebIDL::IndexSizeError::create(realm, "The attribute is limited to only non-negative numbers"_utf16);
return String::number(value);
}

View File

@ -37,7 +37,7 @@ WebIDL::ExceptionOr<GC::Ref<OffscreenCanvas>> OffscreenCanvas::construct_impl(
auto bitmap_or_error = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize { width, height });
if (bitmap_or_error.is_error()) {
return WebIDL::InvalidStateError::create(realm, MUST(String::formatted("Error in allocating bitmap: {}", bitmap_or_error.error())));
return WebIDL::InvalidStateError::create(realm, Utf16String::formatted("Error in allocating bitmap: {}", bitmap_or_error.error()));
}
bitmap = bitmap_or_error.release_value();
}
@ -230,7 +230,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageBitmap>> OffscreenCanvas::transfer_to_image_bit
// 2. If this OffscreenCanvas object's context mode is set to none, then throw an "InvalidStateError" DOMException.
if (m_context.has<Empty>()) {
return WebIDL::InvalidStateError::create(realm(), "OffscreenCanvas has no context"_string);
return WebIDL::InvalidStateError::create(realm(), "OffscreenCanvas has no context"_utf16);
}
// 3. Let image be a newly created ImageBitmap object that references the same underlying bitmap data as this OffscreenCanvas object's bitmap.
@ -273,7 +273,7 @@ GC::Ref<WebIDL::Promise> OffscreenCanvas::convert_to_blob(Optional<ImageEncodeOp
// 3. If this OffscreenCanvas object's bitmap has no pixels (i.e., either its horizontal dimension or its vertical dimension is zero) then return a promise rejected with an "IndexSizeError" DOMException.
if (size.height() == 0 or size.width() == 0) {
auto error = WebIDL::IndexSizeError::create(realm(), "OffscreenCanvas has invalid dimensions. The bitmap has no pixels"_string);
auto error = WebIDL::IndexSizeError::create(realm(), "OffscreenCanvas has invalid dimensions. The bitmap has no pixels"_utf16);
return WebIDL::create_rejected_promise_from_exception(realm(), error);
}
@ -304,14 +304,14 @@ GC::Ref<WebIDL::Promise> OffscreenCanvas::convert_to_blob(Optional<ImageEncodeOp
// 1. If file is null, then reject result with an "EncodingError" DOMException.
if (!file_result.has_value()) {
auto error = WebIDL::EncodingError::create(realm(), "Failed to convert OffscreenCanvas to Blob"_string);
auto error = WebIDL::EncodingError::create(realm(), "Failed to convert OffscreenCanvas to Blob"_utf16);
WebIDL::reject_promise(realm(), result_promise, error);
} else {
// 1. If result is non-null, resolve result with a new Blob object, created in the relevant realm of this OffscreenCanvas object, representing file. [FILEAPI]
auto type = String::from_utf8(file_result->mime_type);
if (type.is_error()) {
auto error = WebIDL::EncodingError::create(realm(), MUST(String::formatted("OOM Error while converting string in OffscreenCanvas to blob: {}"_string, type.error())));
auto error = WebIDL::EncodingError::create(realm(), Utf16String::formatted("OOM Error while converting string in OffscreenCanvas to blob: {}", type.error()));
WebIDL::reject_promise(realm(), result_promise, error);
return;
}

View File

@ -142,17 +142,17 @@ void OffscreenCanvasRenderingContext2D::fill(Path2D&, StringView)
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata
WebIDL::ExceptionOr<GC::Ref<ImageData>> OffscreenCanvasRenderingContext2D::create_image_data(int, int, Optional<ImageDataSettings> const&) const
{
return WebIDL::NotSupportedError::create(realm(), "(STUBBED) OffscreenCanvasRenderingContext2D::create_image_data(int, int)"_string);
return WebIDL::NotSupportedError::create(realm(), "(STUBBED) OffscreenCanvasRenderingContext2D::create_image_data(int, int)"_utf16);
}
WebIDL::ExceptionOr<GC::Ref<ImageData>> OffscreenCanvasRenderingContext2D::create_image_data(ImageData const&) const
{
return WebIDL::NotSupportedError::create(realm(), "(STUBBED) OffscreenCanvasRenderingContext2D::create_image_data(ImageData&)"_string);
return WebIDL::NotSupportedError::create(realm(), "(STUBBED) OffscreenCanvasRenderingContext2D::create_image_data(ImageData&)"_utf16);
}
WebIDL::ExceptionOr<GC::Ptr<ImageData>> OffscreenCanvasRenderingContext2D::get_image_data(int, int, int, int, Optional<ImageDataSettings> const&) const
{
return WebIDL::NotSupportedError::create(realm(), "(STUBBED) OffscreenCanvasRenderingContext2D::get_image_data()"_string);
return WebIDL::NotSupportedError::create(realm(), "(STUBBED) OffscreenCanvasRenderingContext2D::get_image_data()"_utf16);
}
void OffscreenCanvasRenderingContext2D::put_image_data(ImageData&, float, float)

View File

@ -124,7 +124,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, GC::Ptr<JS::Envi
clean_up_after_running_script(realm);
// 2. Throw a "NetworkError" DOMException.
return throw_completion(WebIDL::NetworkError::create(realm, "Script error."_string));
return throw_completion(WebIDL::NetworkError::create(realm, "Script error."_utf16));
}
// 3. Otherwise, rethrow errors is false. Perform the following steps:

View File

@ -49,7 +49,7 @@ void report_exception_to_console(JS::Value value, JS::Realm& realm, ErrorInPromi
dbgln("\033[31;1mUnhandled JavaScript exception{}:\033[0m {}", error_in_promise == ErrorInPromise::Yes ? " (in promise)" : "", value);
}
console.report_exception(*JS::Error::create(realm, value.to_string_without_side_effects()), error_in_promise == ErrorInPromise::Yes);
console.report_exception(*JS::Error::create(realm, value.to_utf16_string_without_side_effects()), error_in_promise == ErrorInPromise::Yes);
}
// https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception

View File

@ -528,7 +528,7 @@ WebIDL::ExceptionOr<GC::Ref<ClassicScript>> fetch_a_classic_worker_imported_scri
if (body_bytes.template has<Empty>() || body_bytes.template has<Fetch::Infrastructure::FetchAlgorithms::ConsumeBodyFailureTag>()
|| !Fetch::Infrastructure::is_ok_status(response->status())
|| !response->header_list()->extract_mime_type().has_value() || !response->header_list()->extract_mime_type()->is_javascript()) {
return WebIDL::NetworkError::create(realm, "Network error"_string);
return WebIDL::NetworkError::create(realm, "Network error"_utf16);
}
// 8. Let sourceText be the result of UTF-8 decoding bodyBytes.

View File

@ -116,7 +116,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(realm);
promise->reject(WebIDL::QuotaExceededError::create(realm, "Failed to evaluate module script"_string).ptr());
promise->reject(WebIDL::QuotaExceededError::create(realm, "Failed to evaluate module script"_utf16).ptr());
evaluation_promise = promise;
} else {

View File

@ -47,7 +47,7 @@ WebIDL::ExceptionOr<GC::Ref<SharedWorker>> SharedWorker::construct_impl(JS::Real
// 5. If urlRecord is failure, then throw a "SyntaxError" DOMException.
if (!url.has_value())
return WebIDL::SyntaxError::create(realm, "SharedWorker constructed with invalid URL"_string);
return WebIDL::SyntaxError::create(realm, "SharedWorker constructed with invalid URL"_utf16);
// 7. Let outside port be a new MessagePort in outside settings's realm.
// NOTE: We do this first so that we can store the port as a GC::Ref.

Some files were not shown because too many files have changed in this diff Show More