ladybird/Tests/LibWeb/test-web/TestWebView.h
Andreas Kling 0aaae1ac76 Tests/LibWeb: Cover UI-owned session history
Teach test-web to expose the UI-process history dump. Add focused
navigation tests for same-document traversal, fallback traversal, and
cross-document browser back and forward behavior. The expectations
assert document state and the UI-owned history snapshot.
2026-06-14 17:38:44 +02:00

44 lines
1.3 KiB
C++

/*
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "TestWeb.h"
#include <AK/Badge.h>
#include <AK/RefPtr.h>
#include <LibCore/Forward.h>
#include <LibCore/Promise.h>
#include <LibGfx/Forward.h>
#include <LibWeb/PixelUnits.h>
#include <LibWebView/HeadlessWebView.h>
namespace TestWeb {
class TestWebView final : public WebView::HeadlessWebView {
public:
static NonnullOwnPtr<TestWebView> create(Core::AnonymousBuffer theme, Web::DevicePixelSize window_size);
void clear_content_blockers();
NonnullRefPtr<Core::Promise<Empty>> reset_session_history();
pid_t web_content_pid() const;
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> take_screenshot();
TestPromise& test_promise() { return *m_test_promise; }
void reset_test_promise() { m_test_promise = TestPromise::construct(); }
void on_test_complete(TestCompletion);
private:
TestWebView(Core::AnonymousBuffer theme, Web::DevicePixelSize viewport_size);
virtual void did_receive_screenshot(Badge<WebView::WebContentClient>, Gfx::ShareableBitmap const& screenshot) override;
RefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> m_pending_screenshot;
NonnullRefPtr<TestPromise> m_test_promise;
};
}