Capabilities.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/StringView.h>
  9. #include <LibWeb/WebDriver/Response.h>
  10. namespace Web::WebDriver {
  11. // https://w3c.github.io/webdriver/#dfn-page-load-strategy
  12. enum class PageLoadStrategy {
  13. None,
  14. Eager,
  15. Normal,
  16. };
  17. constexpr PageLoadStrategy page_load_strategy_from_string(StringView strategy)
  18. {
  19. if (strategy == "none"sv)
  20. return PageLoadStrategy::None;
  21. if (strategy == "eager"sv)
  22. return PageLoadStrategy::Eager;
  23. if (strategy == "normal"sv)
  24. return PageLoadStrategy::Normal;
  25. VERIFY_NOT_REACHED();
  26. }
  27. // https://w3c.github.io/webdriver/#dfn-unhandled-prompt-behavior
  28. enum class UnhandledPromptBehavior {
  29. Dismiss,
  30. Accept,
  31. DismissAndNotify,
  32. AcceptAndNotify,
  33. Ignore,
  34. };
  35. constexpr UnhandledPromptBehavior unhandled_prompt_behavior_from_string(StringView behavior)
  36. {
  37. if (behavior == "dismiss"sv)
  38. return UnhandledPromptBehavior::Dismiss;
  39. if (behavior == "accept"sv)
  40. return UnhandledPromptBehavior::Accept;
  41. if (behavior == "dismiss and notify"sv)
  42. return UnhandledPromptBehavior::DismissAndNotify;
  43. if (behavior == "accept and notify"sv)
  44. return UnhandledPromptBehavior::AcceptAndNotify;
  45. if (behavior == "ignore"sv)
  46. return UnhandledPromptBehavior::Ignore;
  47. VERIFY_NOT_REACHED();
  48. }
  49. struct LadybirdOptions {
  50. explicit LadybirdOptions(JsonObject const& capabilities);
  51. bool headless { false };
  52. };
  53. Response process_capabilities(JsonValue const& parameters);
  54. }