mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibJS: Change PropertyKey(ByteString) to PropertyKey(String)
...and deal with the fallout.
This commit is contained in:
parent
f7b4e7de6f
commit
f5c9ad1c10
17 changed files with 78 additions and 78 deletions
|
@ -1363,7 +1363,7 @@ ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf
|
|||
|
||||
// 2. Let groupName be the substring of templateRemainder from 2 to gtPos.
|
||||
auto group_name_view = template_remainder.substring_view(2, *greater_than_position - 2);
|
||||
auto group_name = MUST(group_name_view.to_byte_string(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
auto group_name = MUST(group_name_view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
|
||||
// 3. Assert: namedCaptures is an Object.
|
||||
VERIFY(named_captures.is_object());
|
||||
|
|
|
@ -264,7 +264,7 @@ ThrowCompletionOr<DurationFormat::DurationUnitOptions> get_duration_unit_options
|
|||
auto display_field = MUST(String::formatted("{}Display", unit_property_key));
|
||||
|
||||
// 6. Let display be ? GetOption(options, displayField, STRING, « "auto", "always" », displayDefault).
|
||||
auto display_value = TRY(get_option(vm, options, display_field.to_byte_string(), OptionType::String, { "auto"sv, "always"sv }, display_default));
|
||||
auto display_value = TRY(get_option(vm, options, display_field, OptionType::String, { "auto"sv, "always"sv }, display_default));
|
||||
auto display = DurationFormat::display_from_string(display_value.as_string().utf8_string());
|
||||
|
||||
// 7. Perform ? ValidateDurationUnitStyle(unit, style, display, prevStyle).
|
||||
|
|
|
@ -47,7 +47,7 @@ void JSONObject::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
|
||||
ThrowCompletionOr<Optional<ByteString>> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
|
||||
ThrowCompletionOr<Optional<String>> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -61,18 +61,18 @@ ThrowCompletionOr<Optional<ByteString>> JSONObject::stringify_impl(VM& vm, Value
|
|||
if (is_array) {
|
||||
auto& replacer_object = replacer.as_object();
|
||||
auto replacer_length = TRY(length_of_array_like(vm, replacer_object));
|
||||
Vector<ByteString> list;
|
||||
Vector<String> list;
|
||||
for (size_t i = 0; i < replacer_length; ++i) {
|
||||
auto replacer_value = TRY(replacer_object.get(i));
|
||||
Optional<ByteString> item;
|
||||
Optional<String> item;
|
||||
if (replacer_value.is_string()) {
|
||||
item = replacer_value.as_string().byte_string();
|
||||
item = replacer_value.as_string().utf8_string();
|
||||
} else if (replacer_value.is_number()) {
|
||||
item = MUST(replacer_value.to_byte_string(vm));
|
||||
item = MUST(replacer_value.to_string(vm));
|
||||
} else if (replacer_value.is_object()) {
|
||||
auto& value_object = replacer_value.as_object();
|
||||
if (is<StringObject>(value_object) || is<NumberObject>(value_object))
|
||||
item = TRY(replacer_value.to_byte_string(vm));
|
||||
item = TRY(replacer_value.to_string(vm));
|
||||
}
|
||||
if (item.has_value() && !list.contains_slow(*item)) {
|
||||
list.append(*item);
|
||||
|
@ -94,20 +94,20 @@ ThrowCompletionOr<Optional<ByteString>> JSONObject::stringify_impl(VM& vm, Value
|
|||
if (space.is_number()) {
|
||||
auto space_mv = MUST(space.to_integer_or_infinity(vm));
|
||||
space_mv = min(10, space_mv);
|
||||
state.gap = space_mv < 1 ? ByteString::empty() : ByteString::repeated(' ', space_mv);
|
||||
state.gap = space_mv < 1 ? String {} : MUST(String::repeated(' ', space_mv));
|
||||
} else if (space.is_string()) {
|
||||
auto string = space.as_string().byte_string();
|
||||
if (string.length() <= 10)
|
||||
auto string = space.as_string().utf8_string();
|
||||
if (string.bytes().size() <= 10)
|
||||
state.gap = string;
|
||||
else
|
||||
state.gap = string.substring(0, 10);
|
||||
state.gap = MUST(string.substring_from_byte_offset(0, 10));
|
||||
} else {
|
||||
state.gap = ByteString::empty();
|
||||
state.gap = String {};
|
||||
}
|
||||
|
||||
auto wrapper = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
MUST(wrapper->create_data_property_or_throw(ByteString::empty(), value));
|
||||
return serialize_json_property(vm, state, ByteString::empty(), wrapper);
|
||||
MUST(wrapper->create_data_property_or_throw(String {}, value));
|
||||
return serialize_json_property(vm, state, String {}, wrapper);
|
||||
}
|
||||
|
||||
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
|
||||
|
@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify)
|
|||
}
|
||||
|
||||
// 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty
|
||||
ThrowCompletionOr<Optional<ByteString>> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder)
|
||||
ThrowCompletionOr<Optional<String>> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder)
|
||||
{
|
||||
// 1. Let value be ? Get(holder, key).
|
||||
auto value = TRY(holder->get(key));
|
||||
|
@ -179,25 +179,25 @@ ThrowCompletionOr<Optional<ByteString>> JSONObject::serialize_json_property(VM&
|
|||
|
||||
// 5. If value is null, return "null".
|
||||
if (value.is_null())
|
||||
return "null"sv;
|
||||
return "null"_string;
|
||||
|
||||
// 6. If value is true, return "true".
|
||||
// 7. If value is false, return "false".
|
||||
if (value.is_boolean())
|
||||
return value.as_bool() ? "true"sv : "false"sv;
|
||||
return value.as_bool() ? "true"_string : "false"_string;
|
||||
|
||||
// 8. If Type(value) is String, return QuoteJSONString(value).
|
||||
if (value.is_string())
|
||||
return quote_json_string(value.as_string().byte_string());
|
||||
return quote_json_string(value.as_string().utf8_string());
|
||||
|
||||
// 9. If Type(value) is Number, then
|
||||
if (value.is_number()) {
|
||||
// a. If value is finite, return ! ToString(value).
|
||||
if (value.is_finite_number())
|
||||
return MUST(value.to_byte_string(vm));
|
||||
return MUST(value.to_string(vm));
|
||||
|
||||
// b. Return "null".
|
||||
return "null"sv;
|
||||
return "null"_string;
|
||||
}
|
||||
|
||||
// 10. If Type(value) is BigInt, throw a TypeError exception.
|
||||
|
@ -218,30 +218,30 @@ ThrowCompletionOr<Optional<ByteString>> JSONObject::serialize_json_property(VM&
|
|||
}
|
||||
|
||||
// 12. Return undefined.
|
||||
return Optional<ByteString> {};
|
||||
return Optional<String> {};
|
||||
}
|
||||
|
||||
// 25.5.2.4 SerializeJSONObject ( state, value ), https://tc39.es/ecma262/#sec-serializejsonobject
|
||||
ThrowCompletionOr<ByteString> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object)
|
||||
ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object)
|
||||
{
|
||||
if (state.seen_objects.contains(&object))
|
||||
return vm.throw_completion<TypeError>(ErrorType::JsonCircular);
|
||||
|
||||
state.seen_objects.set(&object);
|
||||
ByteString previous_indent = state.indent;
|
||||
state.indent = ByteString::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<ByteString> property_strings;
|
||||
String previous_indent = state.indent;
|
||||
state.indent = MUST(String::formatted("{}{}", state.indent, state.gap));
|
||||
Vector<String> property_strings;
|
||||
|
||||
auto process_property = [&](PropertyKey const& key) -> ThrowCompletionOr<void> {
|
||||
if (key.is_symbol())
|
||||
return {};
|
||||
auto serialized_property_string = TRY(serialize_json_property(vm, state, key, &object));
|
||||
if (serialized_property_string.has_value()) {
|
||||
property_strings.append(ByteString::formatted(
|
||||
property_strings.append(MUST(String::formatted(
|
||||
"{}:{}{}",
|
||||
quote_json_string(key.to_string()),
|
||||
quote_json_string(MUST(String::from_byte_string(key.to_string()))),
|
||||
state.gap.is_empty() ? "" : " ",
|
||||
serialized_property_string));
|
||||
serialized_property_string)));
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
@ -253,7 +253,7 @@ ThrowCompletionOr<ByteString> JSONObject::serialize_json_object(VM& vm, Stringif
|
|||
} else {
|
||||
auto property_list = TRY(object.enumerable_own_property_names(PropertyKind::Key));
|
||||
for (auto& property : property_list)
|
||||
TRY(process_property(property.as_string().byte_string()));
|
||||
TRY(process_property(property.as_string().utf8_string()));
|
||||
}
|
||||
StringBuilder builder;
|
||||
if (property_strings.is_empty()) {
|
||||
|
@ -271,7 +271,7 @@ ThrowCompletionOr<ByteString> JSONObject::serialize_json_object(VM& vm, Stringif
|
|||
} else {
|
||||
builder.append('\n');
|
||||
builder.append(state.indent);
|
||||
auto separator = ByteString::formatted(",\n{}", state.indent);
|
||||
auto separator = MUST(String::formatted(",\n{}", state.indent));
|
||||
for (auto& property_string : property_strings) {
|
||||
if (!first)
|
||||
builder.append(separator);
|
||||
|
@ -286,19 +286,19 @@ ThrowCompletionOr<ByteString> JSONObject::serialize_json_object(VM& vm, Stringif
|
|||
|
||||
state.seen_objects.remove(&object);
|
||||
state.indent = previous_indent;
|
||||
return builder.to_byte_string();
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
// 25.5.2.5 SerializeJSONArray ( state, value ), https://tc39.es/ecma262/#sec-serializejsonarray
|
||||
ThrowCompletionOr<ByteString> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object)
|
||||
ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object)
|
||||
{
|
||||
if (state.seen_objects.contains(&object))
|
||||
return vm.throw_completion<TypeError>(ErrorType::JsonCircular);
|
||||
|
||||
state.seen_objects.set(&object);
|
||||
ByteString previous_indent = state.indent;
|
||||
state.indent = ByteString::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<ByteString> property_strings;
|
||||
String previous_indent = state.indent;
|
||||
state.indent = MUST(String::formatted("{}{}", state.indent, state.gap));
|
||||
Vector<String> property_strings;
|
||||
|
||||
auto length = TRY(length_of_array_like(vm, object));
|
||||
|
||||
|
@ -308,7 +308,7 @@ ThrowCompletionOr<ByteString> JSONObject::serialize_json_array(VM& vm, Stringify
|
|||
for (size_t i = 0; i < length; ++i) {
|
||||
auto serialized_property_string = TRY(serialize_json_property(vm, state, i, &object));
|
||||
if (!serialized_property_string.has_value()) {
|
||||
property_strings.append("null"sv);
|
||||
property_strings.append("null"_string);
|
||||
} else {
|
||||
property_strings.append(serialized_property_string.release_value());
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ ThrowCompletionOr<ByteString> JSONObject::serialize_json_array(VM& vm, Stringify
|
|||
} else {
|
||||
builder.append("[\n"sv);
|
||||
builder.append(state.indent);
|
||||
auto separator = ByteString::formatted(",\n{}", state.indent);
|
||||
auto separator = MUST(String::formatted(",\n{}", state.indent));
|
||||
bool first = true;
|
||||
for (auto& property_string : property_strings) {
|
||||
if (!first)
|
||||
|
@ -347,11 +347,11 @@ ThrowCompletionOr<ByteString> JSONObject::serialize_json_array(VM& vm, Stringify
|
|||
|
||||
state.seen_objects.remove(&object);
|
||||
state.indent = previous_indent;
|
||||
return builder.to_byte_string();
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
// 25.5.2.2 QuoteJSONString ( value ), https://tc39.es/ecma262/#sec-quotejsonstring
|
||||
ByteString JSONObject::quote_json_string(ByteString string)
|
||||
String JSONObject::quote_json_string(String string)
|
||||
{
|
||||
// 1. Let product be the String value consisting solely of the code unit 0x0022 (QUOTATION MARK).
|
||||
StringBuilder builder;
|
||||
|
@ -402,7 +402,7 @@ ByteString JSONObject::quote_json_string(ByteString string)
|
|||
builder.append('"');
|
||||
|
||||
// 4. Return product.
|
||||
return builder.to_byte_string();
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
// 25.5.1 JSON.parse ( text [ , reviver ] ), https://tc39.es/ecma262/#sec-json.parse
|
||||
|
@ -410,7 +410,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto string = TRY(vm.argument(0).to_byte_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto reviver = vm.argument(1);
|
||||
|
||||
auto json = JsonValue::from_string(string);
|
||||
|
@ -419,7 +419,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
|
|||
Value unfiltered = parse_json_value(vm, json.value());
|
||||
if (reviver.is_function()) {
|
||||
auto root = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
auto root_name = ByteString::empty();
|
||||
auto root_name = String {};
|
||||
MUST(root->create_data_property_or_throw(root_name, unfiltered));
|
||||
return internalize_json_property(vm, root, root_name, reviver.as_function());
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ Object* JSONObject::parse_json_object(VM& vm, JsonObject const& json_object)
|
|||
auto& realm = *vm.current_realm();
|
||||
auto object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
json_object.for_each_member([&](auto& key, auto& value) {
|
||||
object->define_direct_property(key.to_byte_string(), parse_json_value(vm, value), default_attributes);
|
||||
object->define_direct_property(key, parse_json_value(vm, value), default_attributes);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ ThrowCompletionOr<Value> JSONObject::internalize_json_property(VM& vm, Object* h
|
|||
} else {
|
||||
auto property_list = TRY(value_object.enumerable_own_property_names(Object::PropertyKind::Key));
|
||||
for (auto& property_key : property_list)
|
||||
TRY(process_property(property_key.as_string().byte_string()));
|
||||
TRY(process_property(property_key.as_string().utf8_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
// The base implementation of stringify is exposed because it is used by
|
||||
// test-js to communicate between the JS tests and the C++ test runner.
|
||||
static ThrowCompletionOr<Optional<ByteString>> stringify_impl(VM&, Value value, Value replacer, Value space);
|
||||
static ThrowCompletionOr<Optional<String>> stringify_impl(VM&, Value value, Value replacer, Value space);
|
||||
|
||||
static Value parse_json_value(VM&, JsonValue const&);
|
||||
|
||||
|
@ -30,16 +30,16 @@ private:
|
|||
struct StringifyState {
|
||||
GC::Ptr<FunctionObject> replacer_function;
|
||||
HashTable<GC::Ptr<Object>> seen_objects;
|
||||
ByteString indent { ByteString::empty() };
|
||||
ByteString gap;
|
||||
Optional<Vector<ByteString>> property_list;
|
||||
String indent;
|
||||
String gap;
|
||||
Optional<Vector<String>> property_list;
|
||||
};
|
||||
|
||||
// Stringify helpers
|
||||
static ThrowCompletionOr<Optional<ByteString>> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder);
|
||||
static ThrowCompletionOr<ByteString> serialize_json_object(VM&, StringifyState&, Object&);
|
||||
static ThrowCompletionOr<ByteString> serialize_json_array(VM&, StringifyState&, Object&);
|
||||
static ByteString quote_json_string(ByteString);
|
||||
static ThrowCompletionOr<Optional<String>> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder);
|
||||
static ThrowCompletionOr<String> serialize_json_object(VM&, StringifyState&, Object&);
|
||||
static ThrowCompletionOr<String> serialize_json_array(VM&, StringifyState&, Object&);
|
||||
static String quote_json_string(String);
|
||||
|
||||
// Parse helpers
|
||||
static Object* parse_json_object(VM&, JsonObject const&);
|
||||
|
|
|
@ -56,8 +56,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
PropertyKey(ByteString const& string)
|
||||
: PropertyKey(DeprecatedFlyString(string))
|
||||
PropertyKey(String const& string)
|
||||
: PropertyKey(DeprecatedFlyString(string.to_byte_string()))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ ThrowCompletionOr<void> copy_name_and_length(VM& vm, FunctionObject& function, F
|
|||
target_name = PrimitiveString::create(vm, String {});
|
||||
|
||||
// 8. Perform SetFunctionName(F, targetName, prefix).
|
||||
function.set_function_name({ target_name.as_string().byte_string() }, move(prefix));
|
||||
function.set_function_name({ target_name.as_string().utf8_string() }, move(prefix));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex
|
|||
}
|
||||
|
||||
// 3.1.4 ShadowRealmImportValue ( specifierString: a String, exportNameString: a String, callerRealm: a Realm Record, evalRealm: a Realm Record, evalContext: an execution context, ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealmimportvalue
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm)
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -211,7 +211,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, ByteString specifier_
|
|||
auto referrer = GC::Ref { *eval_context->realm };
|
||||
|
||||
// 7. Perform HostLoadImportedModule(referrer, specifierString, empty, innerCapability).
|
||||
vm.host_load_imported_module(referrer, ModuleRequest { specifier_string }, nullptr, inner_capability);
|
||||
vm.host_load_imported_module(referrer, ModuleRequest { specifier_string.to_byte_string() }, nullptr, inner_capability);
|
||||
|
||||
// 7. Suspend evalContext and remove it from the execution context stack.
|
||||
// NOTE: We don't support this concept yet.
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
|
||||
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
|
||||
ThrowCompletionOr<Value> perform_shadow_realm_eval(VM&, StringView source_text, Realm& caller_realm, Realm& eval_realm);
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm);
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm);
|
||||
ThrowCompletionOr<Value> get_wrapped_value(VM&, Realm& caller_realm, Value);
|
||||
NonnullOwnPtr<ExecutionContext> get_shadow_realm_context(Realm& shadow_realm, bool strict_eval);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
|
|||
auto object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let specifierString be ? ToString(specifier).
|
||||
auto specifier_string = TRY(specifier.to_byte_string(vm));
|
||||
auto specifier_string = TRY(specifier.to_string(vm));
|
||||
|
||||
// 4. If Type(exportName) is not String, throw a TypeError exception.
|
||||
if (!export_name.is_string())
|
||||
|
@ -78,7 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
|
|||
auto& eval_realm = object->shadow_realm();
|
||||
|
||||
// 7. Return ShadowRealmImportValue(specifierString, exportName, callerRealm, evalRealm).
|
||||
return shadow_realm_import_value(vm, move(specifier_string), export_name.as_string().byte_string(), *caller_realm, eval_realm);
|
||||
return shadow_realm_import_value(vm, move(specifier_string), export_name.as_string().utf8_string(), *caller_realm, eval_realm);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,9 +58,9 @@
|
|||
} \
|
||||
} __testjs_register_##fn {};
|
||||
|
||||
#define TESTJS_GLOBAL_FUNCTION(function, exposed_name, ...) \
|
||||
JS_DECLARE_NATIVE_FUNCTION(function); \
|
||||
__TESTJS_REGISTER_GLOBAL_FUNCTION(#exposed_name, function, ##__VA_ARGS__); \
|
||||
#define TESTJS_GLOBAL_FUNCTION(function, exposed_name, ...) \
|
||||
JS_DECLARE_NATIVE_FUNCTION(function); \
|
||||
__TESTJS_REGISTER_GLOBAL_FUNCTION(#exposed_name##_string, function, ##__VA_ARGS__); \
|
||||
JS_DEFINE_NATIVE_FUNCTION(function)
|
||||
|
||||
#define TESTJS_MAIN_HOOK() \
|
||||
|
@ -117,7 +117,7 @@ struct FunctionWithLength {
|
|||
JS::ThrowCompletionOr<JS::Value> (*function)(JS::VM&);
|
||||
size_t length { 0 };
|
||||
};
|
||||
extern HashMap<ByteString, FunctionWithLength> s_exposed_global_functions;
|
||||
extern HashMap<String, FunctionWithLength> s_exposed_global_functions;
|
||||
extern ByteString g_test_root_fragment;
|
||||
extern ByteString g_test_root;
|
||||
extern int g_test_argc;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace JS {
|
|||
RefPtr<::JS::VM> g_vm;
|
||||
bool g_collect_on_every_allocation = false;
|
||||
ByteString g_currently_running_test;
|
||||
HashMap<ByteString, FunctionWithLength> s_exposed_global_functions;
|
||||
HashMap<String, FunctionWithLength> s_exposed_global_functions;
|
||||
Function<void()> g_main_hook;
|
||||
HashMap<bool*, Tuple<ByteString, ByteString, char>> g_extra_args;
|
||||
IntermediateRunFileResult (*g_run_file)(ByteString const&, JS::Realm&, JS::ExecutionContext&) = nullptr;
|
||||
|
|
|
@ -843,7 +843,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::wrap_key(Bindings::KeyFormat format, GC::
|
|||
}
|
||||
|
||||
// 3. Let bytes be the result of UTF-8 encoding json.
|
||||
bytes = maybe_json.release_value()->to_byte_buffer();
|
||||
bytes = MUST(ByteBuffer::copy(maybe_json.value()->bytes()));
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -1018,7 +1018,7 @@ public:
|
|||
auto deserialized_value = TRY(deserialize());
|
||||
|
||||
// 2. Let result be ! CreateDataProperty(value, entry.[[Key]], deserializedValue).
|
||||
auto result = MUST(object.create_data_property(key.to_byte_string(), deserialized_value));
|
||||
auto result = MUST(object.create_data_property(key, deserialized_value));
|
||||
|
||||
// 3. Assert: result is true.
|
||||
VERIFY(result);
|
||||
|
|
|
@ -58,7 +58,7 @@ void Instance::initialize(JS::Realm& realm)
|
|||
m_function_instances.set(address, *object);
|
||||
}
|
||||
|
||||
m_exports->define_direct_property(export_.name(), *object, JS::default_attributes);
|
||||
m_exports->define_direct_property(MUST(String::from_byte_string(export_.name())), *object, JS::default_attributes);
|
||||
},
|
||||
[&](Wasm::GlobalAddress const& address) {
|
||||
Optional<GC::Ptr<Global>> object = cache.get_global_instance(address);
|
||||
|
@ -66,7 +66,7 @@ void Instance::initialize(JS::Realm& realm)
|
|||
object = realm.create<Global>(realm, address);
|
||||
}
|
||||
|
||||
m_exports->define_direct_property(export_.name(), *object, JS::default_attributes);
|
||||
m_exports->define_direct_property(MUST(String::from_byte_string(export_.name())), *object, JS::default_attributes);
|
||||
},
|
||||
[&](Wasm::MemoryAddress const& address) {
|
||||
Optional<GC::Ptr<Memory>> object = m_memory_instances.get(address);
|
||||
|
@ -75,7 +75,7 @@ void Instance::initialize(JS::Realm& realm)
|
|||
m_memory_instances.set(address, *object);
|
||||
}
|
||||
|
||||
m_exports->define_direct_property(export_.name(), *object, JS::default_attributes);
|
||||
m_exports->define_direct_property(MUST(String::from_byte_string(export_.name())), *object, JS::default_attributes);
|
||||
},
|
||||
[&](Wasm::TableAddress const& address) {
|
||||
Optional<GC::Ptr<Table>> object = m_table_instances.get(address);
|
||||
|
@ -84,7 +84,7 @@ void Instance::initialize(JS::Realm& realm)
|
|||
m_table_instances.set(address, *object);
|
||||
}
|
||||
|
||||
m_exports->define_direct_property(export_.name(), *object, JS::default_attributes);
|
||||
m_exports->define_direct_property(MUST(String::from_byte_string(export_.name())), *object, JS::default_attributes);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS
|
|||
for (Wasm::Linker::Name const& import_name : linker.unresolved_imports()) {
|
||||
dbgln_if(LIBWEB_WASM_DEBUG, "Trying to resolve {}::{}", import_name.module, import_name.name);
|
||||
// 3.1. Let o be ? Get(importObject, moduleName).
|
||||
auto value_or_error = import_object->get(import_name.module);
|
||||
auto value_or_error = import_object->get(MUST(String::from_byte_string(import_name.module)));
|
||||
if (value_or_error.is_error())
|
||||
break;
|
||||
auto value = value_or_error.release_value();
|
||||
|
@ -182,7 +182,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS
|
|||
break;
|
||||
auto object = object_or_error.release_value();
|
||||
// 3.3. Let v be ? Get(o, componentName).
|
||||
auto import_or_error = object->get(import_name.name);
|
||||
auto import_or_error = object->get(MUST(String::from_byte_string(import_name.name)));
|
||||
if (import_or_error.is_error())
|
||||
break;
|
||||
auto import_ = import_or_error.release_value();
|
||||
|
|
|
@ -171,7 +171,7 @@ JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, String
|
|||
// 9. If ! IsCallable(O) is false, then:
|
||||
if (!object->is_function()) {
|
||||
// 1. Let getResult be Get(O, opName).
|
||||
auto get_result = object->get(operation_name.to_byte_string());
|
||||
auto get_result = object->get(operation_name);
|
||||
|
||||
// 2. If getResult is an abrupt completion, set completion to getResult and jump to the step labeled return.
|
||||
if (get_result.is_throw_completion()) {
|
||||
|
|
|
@ -1342,7 +1342,7 @@ Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_e
|
|||
// 5. Let property be the result of calling the Object.[[GetProperty]](name) on element.
|
||||
Web::HTML::TemporaryExecutionContext execution_context { current_browsing_context().active_document()->realm() };
|
||||
|
||||
if (auto property_or_error = element->get(name.to_byte_string()); !property_or_error.is_throw_completion()) {
|
||||
if (auto property_or_error = element->get(name); !property_or_error.is_throw_completion()) {
|
||||
auto property = property_or_error.release_value();
|
||||
|
||||
// 6. Let result be the value of property if not undefined, or null.
|
||||
|
|
|
@ -294,9 +294,9 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
|
|||
auto group_object = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||
for (auto const& key : config_file->keys(group)) {
|
||||
auto entry = config_file->read_entry(group, key);
|
||||
group_object->define_direct_property(key, JS::PrimitiveString::create(vm, move(entry)), JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable);
|
||||
group_object->define_direct_property(MUST(String::from_byte_string(key)), JS::PrimitiveString::create(vm, move(entry)), JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable);
|
||||
}
|
||||
object->define_direct_property(group, group_object, JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable);
|
||||
object->define_direct_property(MUST(String::from_byte_string(group)), group_object, JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue