From 7b7a3d79cb8ae6a891d8517c2eb773e89d7982f0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 23 Oct 2023 11:17:50 -0400 Subject: [PATCH] ceftests: More cleanup of TestHandler::OnTestTimeout --- tests/ceftests/test_handler.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/ceftests/test_handler.cc b/tests/ceftests/test_handler.cc index 2afe4262f..3c6062cfd 100644 --- a/tests/ceftests/test_handler.cc +++ b/tests/ceftests/test_handler.cc @@ -444,6 +444,9 @@ void TestHandler::ExecuteTest() { EXPECT_EQ(completion_state_->total(), 1); // Reset any state from the previous run. + if (test_timeout_called_) { + test_timeout_called_ = false; + } if (destroy_test_called_) { destroy_test_called_ = false; } @@ -498,13 +501,15 @@ void TestHandler::OnTestTimeout(int timeout_ms, bool treat_as_error) { EXPECT_FALSE(AllBrowsersClosed() && AllowTestCompletionWhenAllBrowsersClose()) << "Test timed out unexpectedly; should be complete"; + // Keep |this| alive until after the method completes. + CefRefPtr self(this); + // Close any remaining browsers. DestroyTest(); // Reset signal completion count. if (signal_completion_count_ > 0) { signal_completion_count_ = 0; - // May result in |this| being deleted. MaybeTestComplete(); } }