IsHTMLDDA.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Contrib/Test262/IsHTMLDDA.h>
  7. #include <LibJS/Runtime/GlobalObject.h>
  8. namespace JS::Test262 {
  9. IsHTMLDDA::IsHTMLDDA(JS::GlobalObject& global_object)
  10. // NativeFunction without prototype is currently not possible (only due to the lack of a ctor that supports it)
  11. : NativeFunction("IsHTMLDDA", *global_object.function_prototype())
  12. {
  13. }
  14. ThrowCompletionOr<Value> IsHTMLDDA::call()
  15. {
  16. auto& vm = this->vm();
  17. if (vm.argument_count() == 0)
  18. return js_null();
  19. if (vm.argument(0).is_string() && vm.argument(0).as_string().string().is_empty())
  20. return js_null();
  21. // Not sure if this really matters, INTERPRETING.md simply says:
  22. // * IsHTMLDDA - (present only in implementations that can provide it) an object that:
  23. // a. has an [[IsHTMLDDA]] internal slot, and
  24. // b. when called with no arguments or with the first argument "" (an empty string) returns null.
  25. return js_undefined();
  26. }
  27. ThrowCompletionOr<Object*> IsHTMLDDA::construct(FunctionObject&)
  28. {
  29. // Not sure if we need to support construction, but ¯\_(ツ)_/¯
  30. auto& vm = this->vm();
  31. auto& global_object = this->global_object();
  32. return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, "IsHTMLDDA");
  33. }
  34. }