ExecuteScript.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/Heap/HeapFunction.h>
  11. #include <LibJS/Runtime/Value.h>
  12. #include <LibWeb/Forward.h>
  13. namespace Web::WebDriver {
  14. enum class ExecuteScriptResultType {
  15. PromiseResolved,
  16. PromiseRejected,
  17. Timeout,
  18. JavaScriptError,
  19. BrowsingContextDiscarded,
  20. };
  21. struct ExecuteScriptResult {
  22. ExecuteScriptResultType type;
  23. JS::Value value;
  24. };
  25. struct ExecuteScriptResultSerialized {
  26. ExecuteScriptResultType type;
  27. JsonValue value;
  28. };
  29. using OnScriptComplete = JS::HeapFunction<void(ExecuteScriptResultSerialized)>;
  30. void execute_script(HTML::BrowsingContext const&, ByteString body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms, JS::NonnullGCPtr<OnScriptComplete> on_complete);
  31. void execute_async_script(HTML::BrowsingContext const&, ByteString body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms, JS::NonnullGCPtr<OnScriptComplete> on_complete);
  32. }