LibJS + test-js: Get results from the global object directly

This is as the spec would require you to do it and necessary for changes
to come in the following commits.
This commit is contained in:
davidot 2021-09-18 16:31:50 +02:00 committed by Linus Groh
commit ce3f29a135
Notes: sideshowbarker 2024-07-18 03:18:31 +09:00
2 changed files with 15 additions and 11 deletions

View file

@ -237,8 +237,9 @@ inline AK::Result<NonnullRefPtr<JS::SourceTextModule>, ParserError> parse_module
inline Optional<JsonValue> get_test_results(JS::Interpreter& interpreter)
{
auto result = g_vm->get_variable("__TestResults__", interpreter.global_object());
auto json_string = JS::JSONObject::stringify_impl(interpreter.global_object(), result, JS::js_undefined(), JS::js_undefined());
auto results = interpreter.global_object().get("__TestResults__");
VERIFY(!results.is_empty());
auto json_string = JS::JSONObject::stringify_impl(interpreter.global_object(), results, JS::js_undefined(), JS::js_undefined());
auto json = JsonValue::from_string(json_string);
if (!json.has_value())
@ -382,7 +383,10 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
JSFileResult file_result { test_path.substring(m_test_root.length() + 1, test_path.length() - m_test_root.length() - 1) };
// Collect logged messages
auto& arr = interpreter->vm().get_variable("__UserOutput__", interpreter->global_object()).as_array();
auto user_output = interpreter->global_object().get("__UserOutput__");
VERIFY(!user_output.is_empty());
auto& arr = user_output.as_array();
for (auto& entry : arr.indexed_properties()) {
auto message = arr.get(entry.index());
file_result.logged_messages.append(message.to_string_without_side_effects());