2022-11-02 18:02:19 +00:00
|
|
|
/*
|
2023-04-20 17:41:32 +01:00
|
|
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
2022-11-02 18:02:19 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
#include <AK/JsonValue.h>
|
|
|
|
#include <LibJS/Forward.h>
|
2024-09-13 07:42:24 -04:00
|
|
|
#include <LibJS/Heap/HeapFunction.h>
|
2022-11-02 18:02:19 +00:00
|
|
|
#include <LibJS/Runtime/Value.h>
|
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
namespace Web::WebDriver {
|
|
|
|
|
|
|
|
enum class ExecuteScriptResultType {
|
|
|
|
PromiseResolved,
|
|
|
|
PromiseRejected,
|
|
|
|
Timeout,
|
|
|
|
JavaScriptError,
|
2023-04-20 17:41:32 +01:00
|
|
|
BrowsingContextDiscarded,
|
2024-09-13 19:41:31 -04:00
|
|
|
StaleElement,
|
2022-11-02 18:02:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ExecuteScriptResult {
|
|
|
|
ExecuteScriptResultType type;
|
|
|
|
JS::Value value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ExecuteScriptResultSerialized {
|
|
|
|
ExecuteScriptResultType type;
|
|
|
|
JsonValue value;
|
|
|
|
};
|
|
|
|
|
2024-09-13 07:42:24 -04:00
|
|
|
using OnScriptComplete = JS::HeapFunction<void(ExecuteScriptResultSerialized)>;
|
|
|
|
|
2024-10-29 14:12:13 -04:00
|
|
|
JS::ThrowCompletionOr<JS::Value> execute_a_function_body(HTML::BrowsingContext const&, ByteString const& body, ReadonlySpan<JS::Value> parameters);
|
|
|
|
JS::ThrowCompletionOr<JS::Value> execute_a_function_body(HTML::Window const&, ByteString const& body, ReadonlySpan<JS::Value> parameters, JS::GCPtr<JS::Object> environment_override_object = {});
|
|
|
|
|
2024-09-14 08:04:15 -04:00
|
|
|
void execute_script(HTML::BrowsingContext const&, ByteString body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms, JS::NonnullGCPtr<OnScriptComplete> on_complete);
|
|
|
|
void execute_async_script(HTML::BrowsingContext const&, ByteString body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout_ms, JS::NonnullGCPtr<OnScriptComplete> on_complete);
|
2022-11-02 18:02:19 +00:00
|
|
|
|
|
|
|
}
|