Skip to content

Commit dea0857

Browse files
authored
Fix cobalt_browsertests not execute test code (#8623)
This CL fixes an issue where cobalt_browsertests were not executing their test bodies on Starboard. **Root Cause**: On Starboard (similar to Android and iOS), ShellMainDelegate::RunProcess initializes the BrowserMainRunner but returns 0 early, skipping the call to BrowserMainRunner::Run(). * The test body (ui_task) is normally executed within BrowserMainLoop::InterceptMainMessageLoopRun. * On standard platforms, InterceptMainMessageLoopRun is called during Run(). * Since Run() is skipped on Starboard, the test body was never executed. **Fix**: Updated BrowserMainLoop::CreateStartupTasks to include BUILDFLAG(IS_STARBOARD). * This explicitly schedules InterceptMainMessageLoopRun as a startup task. * This ensures the ui_task is executed synchronously during BrowserMainRunner::Initialize(), matching the behavior required by ShellMainDelegate for these platforms. **Additional Changes**: * Added assertions to ContentMainRunnerImplBrowserTest.StartupSequence in content_main_runner_impl_browsertest.cc to verify that FeatureList, ThreadPoolInstance, and ContentClient are correctly initialized after startup. Issue: 433354983
1 parent 475649f commit dea0857

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

cobalt/testing/browser_tests/content_main_runner_impl_browsertest.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ class ContentMainRunnerImplBrowserTest : public ContentBrowserTest {
297297

298298
IN_PROC_BROWSER_TEST_F(ContentMainRunnerImplBrowserTest, StartupSequence) {
299299
// All of the work is done in SetUp().
300+
EXPECT_TRUE(base::FeatureList::GetInstance());
301+
EXPECT_TRUE(base::ThreadPoolInstance::Get());
302+
EXPECT_TRUE(GetContentClientForTesting());
300303
}
301304

302305
} // namespace

content/browser/browser_main_loop.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,10 @@ void BrowserMainLoop::CreateStartupTasks() {
895895
// is entered and startup tasks are run asynchronously from it.
896896
// InterceptMainMessageLoopRun() thus needs to be forced instead of happening
897897
// from MainMessageLoopRun().
898-
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
898+
// Make the Starboard same behavior like Android but only in non-release
899+
// builds for cobalt_browsertests.
900+
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || \
901+
(!defined(OFFICIAL_BUILD) && BUILDFLAG(IS_STARBOARD))
899902
StartupTask intercept_main_message_loop_run = base::BindOnce(
900903
[](BrowserMainLoop* self) {
901904
// Lambda to ignore the return value and always keep a clean exit code

0 commit comments

Comments
 (0)