ladybird/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
Timothy Flynn 115baa7e32 LibJS+Everywhere: Make PrimitiveString and Utf16String fallible
This makes construction of Utf16String fallible in OOM conditions. The
immediate impact is that PrimitiveString must then be fallible as well,
as it may either transcode UTF-8 to UTF-16, or create a UTF-16 string
from ropes.

There are a couple of places where it is very non-trivial to propagate
the error further. A FIXME has been added to those locations.
2023-01-08 12:13:15 +01:00

32 lines
1 KiB
C++

/*
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Contrib/Test262/IsHTMLDDA.h>
#include <LibJS/Runtime/GlobalObject.h>
namespace JS::Test262 {
IsHTMLDDA::IsHTMLDDA(Realm& realm)
// NativeFunction without prototype is currently not possible (only due to the lack of a ctor that supports it)
: NativeFunction("IsHTMLDDA", *realm.intrinsics().function_prototype())
{
}
ThrowCompletionOr<Value> IsHTMLDDA::call()
{
auto& vm = this->vm();
if (vm.argument_count() == 0)
return js_null();
if (vm.argument(0).is_string() && TRY(vm.argument(0).as_string().deprecated_string()).is_empty())
return js_null();
// Not sure if this really matters, INTERPRETING.md simply says:
// * IsHTMLDDA - (present only in implementations that can provide it) an object that:
// a. has an [[IsHTMLDDA]] internal slot, and
// b. when called with no arguments or with the first argument "" (an empty string) returns null.
return js_undefined();
}
}