mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
777eec095b
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This allows us to headlessly run WPT tests which involve dialogs.
57 lines
1.9 KiB
C++
57 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Badge.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <Ladybird/Headless/Test.h>
|
|
#include <LibCore/Forward.h>
|
|
#include <LibCore/Promise.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibWeb/Page/Page.h>
|
|
#include <LibWeb/PixelUnits.h>
|
|
#include <LibWebView/ViewImplementation.h>
|
|
|
|
namespace Ladybird {
|
|
|
|
class HeadlessWebView final : public WebView::ViewImplementation {
|
|
public:
|
|
static NonnullOwnPtr<HeadlessWebView> create(Core::AnonymousBuffer theme, Gfx::IntSize window_size);
|
|
static NonnullOwnPtr<HeadlessWebView> create_child(HeadlessWebView const&, u64 page_index);
|
|
|
|
void clear_content_filters();
|
|
|
|
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap>>> take_screenshot();
|
|
|
|
TestPromise& test_promise() { return *m_test_promise; }
|
|
void on_test_complete(TestCompletion);
|
|
|
|
private:
|
|
HeadlessWebView(Core::AnonymousBuffer theme, Gfx::IntSize viewport_size);
|
|
|
|
void update_zoom() override { }
|
|
void initialize_client(CreateNewClient) override;
|
|
|
|
virtual Web::DevicePixelSize viewport_size() const override { return m_viewport_size.to_type<Web::DevicePixels>(); }
|
|
virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override { return widget_position; }
|
|
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override { return content_position; }
|
|
|
|
virtual void did_receive_screenshot(Badge<WebView::WebContentClient>, Gfx::ShareableBitmap const& screenshot) override;
|
|
|
|
Core::AnonymousBuffer m_theme;
|
|
Gfx::IntSize m_viewport_size;
|
|
|
|
RefPtr<Core::Promise<RefPtr<Gfx::Bitmap>>> m_pending_screenshot;
|
|
|
|
NonnullRefPtr<TestPromise> m_test_promise;
|
|
|
|
Web::Page::PendingDialog m_pending_dialog { Web::Page::PendingDialog::None };
|
|
Optional<String> m_pending_prompt_text;
|
|
};
|
|
|
|
}
|