@@ -34,6 +34,7 @@ public class EndpointHtmlRendererTest
3434{
3535 private const string MarkerPrefix = "<!--Blazor:" ;
3636 private const string PrerenderedComponentPattern = "^<!--Blazor:(?<preamble>.*?)-->(?<content>.+?)<!--Blazor:(?<epilogue>.*?)-->$" ;
37+ private const string WebAssemblyOptionsPattern = "^<!--Blazor-WebAssembly:(.*?)-->" ;
3738 private const string ComponentPattern = "^<!--Blazor:(.*?)-->$" ;
3839
3940 private static readonly IDataProtectionProvider _dataprotectorProvider = new EphemeralDataProtectionProvider ( ) ;
@@ -57,6 +58,7 @@ public async Task CanRender_ParameterlessComponent_ClientMode()
5758 var result = await renderer . PrerenderComponentAsync ( httpContext , typeof ( SimpleComponent ) , new InteractiveWebAssemblyRenderMode ( prerender : false ) , ParameterView . Empty ) ;
5859 await renderer . Dispatcher . InvokeAsync ( ( ) => result . WriteTo ( writer , HtmlEncoder . Default ) ) ;
5960 var content = writer . ToString ( ) ;
61+ content = AssertAndStripWebAssemblyOptions ( content ) ;
6062 var match = Regex . Match ( content , ComponentPattern ) ;
6163
6264 // Assert
@@ -80,6 +82,7 @@ public async Task CanPrerender_ParameterlessComponent_ClientMode()
8082 var result = await renderer . PrerenderComponentAsync ( httpContext , typeof ( SimpleComponent ) , RenderMode . InteractiveWebAssembly , ParameterView . Empty ) ;
8183 await renderer . Dispatcher . InvokeAsync ( ( ) => result . WriteTo ( writer , HtmlEncoder . Default ) ) ;
8284 var content = writer . ToString ( ) ;
85+ content = AssertAndStripWebAssemblyOptions ( content ) ;
8386 var match = Regex . Match ( content , PrerenderedComponentPattern , RegexOptions . Multiline ) ;
8487
8588 // Assert
@@ -160,6 +163,7 @@ public async Task CanRender_ComponentWithNullParameters_ClientMode()
160163 } ) ) ;
161164 await renderer . Dispatcher . InvokeAsync ( ( ) => result . WriteTo ( writer , HtmlEncoder . Default ) ) ;
162165 var content = writer . ToString ( ) ;
166+ content = AssertAndStripWebAssemblyOptions ( content ) ;
163167 var match = Regex . Match ( content , ComponentPattern ) ;
164168
165169 // Assert
@@ -244,6 +248,7 @@ public async Task CanPrerender_ComponentWithNullParameters_ClientMode()
244248 } ) ) ;
245249 await renderer . Dispatcher . InvokeAsync ( ( ) => result . WriteTo ( writer , HtmlEncoder . Default ) ) ;
246250 var content = writer . ToString ( ) ;
251+ content = AssertAndStripWebAssemblyOptions ( content ) ;
247252 var match = Regex . Match ( content , PrerenderedComponentPattern , RegexOptions . Multiline ) ;
248253
249254 // Assert
@@ -1167,6 +1172,8 @@ public async Task DoesNotEmitNestedRenderModeBoundaries()
11671172 var numMarkers = Regex . Matches ( content , MarkerPrefix ) . Count ;
11681173 Assert . Equal ( 2 , numMarkers ) ; // A start and an end marker
11691174
1175+ content = AssertAndStripWebAssemblyOptions ( content ) ;
1176+
11701177 var match = Regex . Match ( content , PrerenderedComponentPattern , RegexOptions . Singleline ) ;
11711178 Assert . True ( match . Success ) ;
11721179 var preamble = match . Groups [ "preamble" ] . Value ;
@@ -1498,6 +1505,14 @@ await renderer.Dispatcher.InvokeAsync(() => renderer.RenderRootComponentAsync(
14981505 }
14991506 }
15001507
1508+ private string AssertAndStripWebAssemblyOptions ( string content )
1509+ {
1510+ var wasmOptionsMatch = Regex . Match ( content , WebAssemblyOptionsPattern ) ;
1511+ Assert . True ( wasmOptionsMatch . Success ) ;
1512+ content = content . Substring ( wasmOptionsMatch . Groups [ 0 ] . Length ) ;
1513+ return content ;
1514+ }
1515+
15011516 private class NamedEventHandlerComponent : ComponentBase
15021517 {
15031518 [ Parameter ]
0 commit comments