@@ -335,7 +335,54 @@ TEST_F(DartSecondaryIsolateTest, CanLaunchSecondaryIsolates) {
335335 // root isolate will be auto-shutdown
336336}
337337
338- TEST_F (DartIsolateTest, CanReceiveArguments) {
338+ static thread_local bool is_engine_worker = false ;
339+
340+ TEST_F (DartSecondaryIsolateTest, VMTasksRunOnEngineThreads) {
341+ AddNativeCallback (" NotifyNative" ,
342+ CREATE_NATIVE_ENTRY (([this ](Dart_NativeArguments args) {
343+ LatchCountDown ();
344+ })));
345+ AddNativeCallback (" PassMessage" ,
346+ CREATE_NATIVE_ENTRY (([this ](Dart_NativeArguments args) {
347+ // Child isolate is running on concurrent message loop
348+ // worker.
349+ ASSERT_TRUE (is_engine_worker);
350+ LatchCountDown ();
351+ })));
352+ auto settings = CreateSettingsForFixture ();
353+ settings.root_isolate_shutdown_callback = [this ]() {
354+ RootIsolateShutdownSignal ();
355+ };
356+ settings.isolate_shutdown_callback = [this ]() { ChildShutdownSignal (); };
357+ auto vm_ref = DartVMRef::Create (settings);
358+
359+ auto loop = vm_ref->GetConcurrentMessageLoop ();
360+ fml::CountDownLatch latch (loop->GetWorkerCount ());
361+ vm_ref->GetConcurrentMessageLoop ()->PostTaskToAllWorkers ([&] {
362+ is_engine_worker = true ;
363+ latch.CountDown ();
364+ });
365+ latch.Wait ();
366+
367+ auto thread = CreateNewThread ();
368+ TaskRunners task_runners (GetCurrentTestName (), //
369+ thread, //
370+ thread, //
371+ thread, //
372+ thread //
373+ );
374+ auto isolate = RunDartCodeInIsolate (vm_ref, settings, task_runners,
375+ " testCanLaunchSecondaryIsolate" , {},
376+ GetDefaultKernelFilePath ());
377+ ASSERT_TRUE (isolate);
378+ ASSERT_EQ (isolate->get ()->GetPhase (), DartIsolate::Phase::Running);
379+ ChildShutdownWait (); // wait for child isolate to shutdown first
380+ ASSERT_FALSE (RootIsolateIsSignaled ());
381+ LatchWait (); // wait for last NotifyNative called by main isolate
382+ // root isolate will be auto-shutdown
383+ }
384+
385+ TEST_F (DartIsolateTest, CanRecieveArguments) {
339386 AddNativeCallback (" NotifyNative" ,
340387 CREATE_NATIVE_ENTRY (([this ](Dart_NativeArguments args) {
341388 ASSERT_TRUE (tonic::DartConverter<bool >::FromDart (
0 commit comments