@@ -15,7 +15,6 @@ public class TestRenderer : Renderer, ITestRenderer
1515 private static readonly MethodInfo GetRequiredComponentStateMethod = RendererType . GetMethod ( "GetRequiredComponentState" , BindingFlags . Instance | BindingFlags . NonPublic ) ! ;
1616
1717 private readonly object renderTreeUpdateLock = new ( ) ;
18- private readonly SynchronizationContext ? usersSyncContext = SynchronizationContext . Current ;
1918 private readonly Dictionary < int , IRenderedFragmentBase > renderedComponents = new ( ) ;
2019 private readonly List < RootComponent > rootComponents = new ( ) ;
2120 private readonly ILogger < TestRenderer > logger ;
@@ -264,7 +263,7 @@ protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
264263 {
265264 var renderEvent = new RenderEvent ( ) ;
266265 PrepareRenderEvent ( renderBatch ) ;
267- InvokeApplyRenderEvent ( ) ;
266+ ApplyRenderEvent ( renderEvent ) ;
268267
269268 return Task . CompletedTask ;
270269
@@ -332,31 +331,6 @@ void LoadChangesIntoRenderEvent(int componentId)
332331 }
333332 }
334333 }
335-
336- void InvokeApplyRenderEvent ( )
337- {
338- if ( usersSyncContext is not null && usersSyncContext != SynchronizationContext . Current )
339- {
340- // The users' sync context, typically one established by
341- // xUnit or another testing framework is used to update any
342- // rendered fragments/dom trees and trigger WaitForX handlers.
343- // This ensures that changes to DOM observed inside a WaitForX handler
344- // will also be visible outside a WaitForX handler, since
345- // they will be running in the same sync context. The theory is that
346- // this should mitigate the issues where Blazor's dispatcher/thread is used
347- // to verify an assertion inside a WaitForX handler, and another thread is
348- // used again to access the DOM/repeat the assertion, where the change
349- // may not be visible yet (another theory about why that may happen is different
350- // CPU cache updates not happening immediately).
351- //
352- // There is no guarantee a caller/test framework has set a sync context.
353- usersSyncContext . Send ( _ => ApplyRenderEvent ( renderEvent ) , null ) ;
354- }
355- else
356- {
357- ApplyRenderEvent ( renderEvent ) ;
358- }
359- }
360334 }
361335
362336 private void ApplyRenderEvent ( RenderEvent renderEvent )
0 commit comments