From f5c9ad1c10bd75703951c183df8150e76562e4bc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 16 Mar 2025 20:45:02 -0500 Subject: [PATCH] LibJS: Change PropertyKey(ByteString) to PropertyKey(String) ...and deal with the fallout. --- .../LibJS/Runtime/AbstractOperations.cpp | 2 +- .../LibJS/Runtime/Intl/DurationFormat.cpp | 2 +- Libraries/LibJS/Runtime/JSONObject.cpp | 86 +++++++++---------- Libraries/LibJS/Runtime/JSONObject.h | 16 ++-- Libraries/LibJS/Runtime/PropertyKey.h | 4 +- Libraries/LibJS/Runtime/ShadowRealm.cpp | 6 +- Libraries/LibJS/Runtime/ShadowRealm.h | 2 +- .../LibJS/Runtime/ShadowRealmPrototype.cpp | 4 +- Libraries/LibTest/JavaScriptTestRunner.h | 8 +- .../LibTest/JavaScriptTestRunnerMain.cpp | 2 +- Libraries/LibWeb/Crypto/SubtleCrypto.cpp | 2 +- Libraries/LibWeb/HTML/StructuredSerialize.cpp | 2 +- Libraries/LibWeb/WebAssembly/Instance.cpp | 8 +- Libraries/LibWeb/WebAssembly/WebAssembly.cpp | 4 +- .../LibWeb/WebIDL/AbstractOperations.cpp | 2 +- Services/WebContent/WebDriverConnection.cpp | 2 +- Utilities/js.cpp | 4 +- 17 files changed, 78 insertions(+), 78 deletions(-) diff --git a/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Libraries/LibJS/Runtime/AbstractOperations.cpp index aca91c05c69..ece1d8f3ac6 100644 --- a/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1363,7 +1363,7 @@ ThrowCompletionOr 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()); diff --git a/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index 788c43cf631..7543bedc8a3 100644 --- a/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -264,7 +264,7 @@ ThrowCompletionOr 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). diff --git a/Libraries/LibJS/Runtime/JSONObject.cpp b/Libraries/LibJS/Runtime/JSONObject.cpp index 3ec595d17d9..c8c343c958b 100644 --- a/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Libraries/LibJS/Runtime/JSONObject.cpp @@ -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> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space) +ThrowCompletionOr> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space) { auto& realm = *vm.current_realm(); @@ -61,18 +61,18 @@ ThrowCompletionOr> 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 list; + Vector list; for (size_t i = 0; i < replacer_length; ++i) { auto replacer_value = TRY(replacer_object.get(i)); - Optional item; + Optional 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(value_object) || is(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> 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> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder) +ThrowCompletionOr> 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> 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> JSONObject::serialize_json_property(VM& } // 12. Return undefined. - return Optional {}; + return Optional {}; } // 25.5.2.4 SerializeJSONObject ( state, value ), https://tc39.es/ecma262/#sec-serializejsonobject -ThrowCompletionOr JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object) +ThrowCompletionOr JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object) { if (state.seen_objects.contains(&object)) return vm.throw_completion(ErrorType::JsonCircular); state.seen_objects.set(&object); - ByteString previous_indent = state.indent; - state.indent = ByteString::formatted("{}{}", state.indent, state.gap); - Vector property_strings; + String previous_indent = state.indent; + state.indent = MUST(String::formatted("{}{}", state.indent, state.gap)); + Vector property_strings; auto process_property = [&](PropertyKey const& key) -> ThrowCompletionOr { 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 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 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 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 JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object) +ThrowCompletionOr JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object) { if (state.seen_objects.contains(&object)) return vm.throw_completion(ErrorType::JsonCircular); state.seen_objects.set(&object); - ByteString previous_indent = state.indent; - state.indent = ByteString::formatted("{}{}", state.indent, state.gap); - Vector property_strings; + String previous_indent = state.indent; + state.indent = MUST(String::formatted("{}{}", state.indent, state.gap)); + Vector property_strings; auto length = TRY(length_of_array_like(vm, object)); @@ -308,7 +308,7 @@ ThrowCompletionOr 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 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 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 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())); } } diff --git a/Libraries/LibJS/Runtime/JSONObject.h b/Libraries/LibJS/Runtime/JSONObject.h index fd1f0cfbcd6..dc3eba84d7d 100644 --- a/Libraries/LibJS/Runtime/JSONObject.h +++ b/Libraries/LibJS/Runtime/JSONObject.h @@ -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> stringify_impl(VM&, Value value, Value replacer, Value space); + static ThrowCompletionOr> 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 replacer_function; HashTable> seen_objects; - ByteString indent { ByteString::empty() }; - ByteString gap; - Optional> property_list; + String indent; + String gap; + Optional> property_list; }; // Stringify helpers - static ThrowCompletionOr> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder); - static ThrowCompletionOr serialize_json_object(VM&, StringifyState&, Object&); - static ThrowCompletionOr serialize_json_array(VM&, StringifyState&, Object&); - static ByteString quote_json_string(ByteString); + static ThrowCompletionOr> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder); + static ThrowCompletionOr serialize_json_object(VM&, StringifyState&, Object&); + static ThrowCompletionOr serialize_json_array(VM&, StringifyState&, Object&); + static String quote_json_string(String); // Parse helpers static Object* parse_json_object(VM&, JsonObject const&); diff --git a/Libraries/LibJS/Runtime/PropertyKey.h b/Libraries/LibJS/Runtime/PropertyKey.h index 26fd5acbc13..c91a4568e50 100644 --- a/Libraries/LibJS/Runtime/PropertyKey.h +++ b/Libraries/LibJS/Runtime/PropertyKey.h @@ -56,8 +56,8 @@ public: { } - PropertyKey(ByteString const& string) - : PropertyKey(DeprecatedFlyString(string)) + PropertyKey(String const& string) + : PropertyKey(DeprecatedFlyString(string.to_byte_string())) { } diff --git a/Libraries/LibJS/Runtime/ShadowRealm.cpp b/Libraries/LibJS/Runtime/ShadowRealm.cpp index 28fdd97f47e..7157dda97d6 100644 --- a/Libraries/LibJS/Runtime/ShadowRealm.cpp +++ b/Libraries/LibJS/Runtime/ShadowRealm.cpp @@ -87,7 +87,7 @@ ThrowCompletionOr 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 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 shadow_realm_import_value(VM& vm, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm) +ThrowCompletionOr 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 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. diff --git a/Libraries/LibJS/Runtime/ShadowRealm.h b/Libraries/LibJS/Runtime/ShadowRealm.h index efd2734c457..c3a8b85ee3f 100644 --- a/Libraries/LibJS/Runtime/ShadowRealm.h +++ b/Libraries/LibJS/Runtime/ShadowRealm.h @@ -35,7 +35,7 @@ private: ThrowCompletionOr copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional prefix = {}, Optional arg_count = {}); ThrowCompletionOr perform_shadow_realm_eval(VM&, StringView source_text, Realm& caller_realm, Realm& eval_realm); -ThrowCompletionOr shadow_realm_import_value(VM&, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm); +ThrowCompletionOr shadow_realm_import_value(VM&, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm); ThrowCompletionOr get_wrapped_value(VM&, Realm& caller_realm, Value); NonnullOwnPtr get_shadow_realm_context(Realm& shadow_realm, bool strict_eval); diff --git a/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp index b1623b24f24..82f3ba620e1 100644 --- a/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp +++ b/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp @@ -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); } } diff --git a/Libraries/LibTest/JavaScriptTestRunner.h b/Libraries/LibTest/JavaScriptTestRunner.h index ab130f66f50..8c51977e4b2 100644 --- a/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Libraries/LibTest/JavaScriptTestRunner.h @@ -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 (*function)(JS::VM&); size_t length { 0 }; }; -extern HashMap s_exposed_global_functions; +extern HashMap s_exposed_global_functions; extern ByteString g_test_root_fragment; extern ByteString g_test_root; extern int g_test_argc; diff --git a/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index 3d135eb5f0c..bbe276a6098 100644 --- a/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -21,7 +21,7 @@ namespace JS { RefPtr<::JS::VM> g_vm; bool g_collect_on_every_allocation = false; ByteString g_currently_running_test; -HashMap s_exposed_global_functions; +HashMap s_exposed_global_functions; Function g_main_hook; HashMap> g_extra_args; IntermediateRunFileResult (*g_run_file)(ByteString const&, JS::Realm&, JS::ExecutionContext&) = nullptr; diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index f904e7f4203..c52b13c8ea6 100644 --- a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -843,7 +843,7 @@ GC::Ref 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(); } diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp index 6c273c4ac1a..bcdfe6e1e00 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -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); diff --git a/Libraries/LibWeb/WebAssembly/Instance.cpp b/Libraries/LibWeb/WebAssembly/Instance.cpp index c16d10fd70f..a1382a727d4 100644 --- a/Libraries/LibWeb/WebAssembly/Instance.cpp +++ b/Libraries/LibWeb/WebAssembly/Instance.cpp @@ -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> object = cache.get_global_instance(address); @@ -66,7 +66,7 @@ void Instance::initialize(JS::Realm& realm) object = realm.create(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> 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> 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); }); } diff --git a/Libraries/LibWeb/WebAssembly/WebAssembly.cpp b/Libraries/LibWeb/WebAssembly/WebAssembly.cpp index 847ed351602..c61b2e99f03 100644 --- a/Libraries/LibWeb/WebAssembly/WebAssembly.cpp +++ b/Libraries/LibWeb/WebAssembly/WebAssembly.cpp @@ -172,7 +172,7 @@ JS::ThrowCompletionOr> 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> 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(); diff --git a/Libraries/LibWeb/WebIDL/AbstractOperations.cpp b/Libraries/LibWeb/WebIDL/AbstractOperations.cpp index 31ed6824615..6e59e0d9edd 100644 --- a/Libraries/LibWeb/WebIDL/AbstractOperations.cpp +++ b/Libraries/LibWeb/WebIDL/AbstractOperations.cpp @@ -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()) { diff --git a/Services/WebContent/WebDriverConnection.cpp b/Services/WebContent/WebDriverConnection.cpp index 0a0305100f6..373f7ff3f14 100644 --- a/Services/WebContent/WebDriverConnection.cpp +++ b/Services/WebContent/WebDriverConnection.cpp @@ -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. diff --git a/Utilities/js.cpp b/Utilities/js.cpp index 10a1c00ff0e..494aaafe836 100644 --- a/Utilities/js.cpp +++ b/Utilities/js.cpp @@ -294,9 +294,9 @@ static JS::ThrowCompletionOr 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; }