test-web: Reset viewport size after each test

This commit is contained in:
Luke Wilde
2026-02-13 16:30:04 +00:00
committed by Luke Wilde
parent 66d5bff914
commit 6491c6bb90
Notes: github-actions[bot] 2026-02-23 18:45:46 +00:00
3 changed files with 16 additions and 2 deletions

View File

@@ -173,6 +173,16 @@ void HeadlessWebView::initialize_client(CreateNewClient create_new_client)
client().async_update_screen_rects(m_client_state.page_index, { { screen_rect } }, 0);
}
void HeadlessWebView::reset_viewport_size(Web::DevicePixelSize size)
{
m_viewport_size = size;
client().async_set_window_size(m_client_state.page_index, m_viewport_size);
client().async_set_viewport(m_client_state.page_index, m_viewport_size, m_device_pixel_ratio);
client().async_did_update_window_rect(m_client_state.page_index);
}
void HeadlessWebView::update_zoom()
{
ViewImplementation::update_zoom();

View File

@@ -20,6 +20,8 @@ public:
static NonnullOwnPtr<HeadlessWebView> create(Core::AnonymousBuffer theme, Web::DevicePixelSize window_size);
static NonnullOwnPtr<HeadlessWebView> create_child(HeadlessWebView&, u64 page_index);
void reset_viewport_size(Web::DevicePixelSize);
void disconnect_child_crash_handlers()
{
// Disconnect crash handlers so child crashes don't propagate to parent.

View File

@@ -1309,9 +1309,11 @@ static ErrorOr<int> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePix
// Disconnect child crash handlers so old child crashes don't affect the next test
view->disconnect_child_crash_handlers();
// Don't try to reset zoom if WebContent crashed - it's gone
if (test_result != TestResult::Crashed)
// Don't try to reset state if WebContent crashed - it's gone
if (test_result != TestResult::Crashed) {
view->reset_zoom();
view->reset_viewport_size(window_size);
}
auto& test = tests[test_index];
if (test.timeout_timer) {