ExecuteScript.h 952 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/JsonValue.h>
  9. #include <LibJS/Forward.h>
  10. #include <LibJS/Runtime/Value.h>
  11. #include <LibWeb/Forward.h>
  12. namespace Web::WebDriver {
  13. enum class ExecuteScriptResultType {
  14. PromiseResolved,
  15. PromiseRejected,
  16. Timeout,
  17. JavaScriptError,
  18. BrowsingContextDiscarded,
  19. };
  20. struct ExecuteScriptResult {
  21. ExecuteScriptResultType type;
  22. JS::Value value;
  23. };
  24. struct ExecuteScriptResultSerialized {
  25. ExecuteScriptResultType type;
  26. JsonValue value;
  27. };
  28. ExecuteScriptResultSerialized execute_script(Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
  29. ExecuteScriptResultSerialized execute_async_script(Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
  30. }