@@ -32,9 +32,13 @@ public override async Task InitializeAsync()
3232 Browser . Equal ( "Redirections" , ( ) => _originalH1Element . Text ) ;
3333 }
3434
35- [ Fact ]
36- public void RedirectStreamingGetToInternal ( )
35+ [ Theory ]
36+ [ InlineData ( true ) ]
37+ [ InlineData ( false ) ]
38+ public void RedirectStreamingGetToInternal ( bool disableThrowNavigationException )
3739 {
40+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
41+
3842 Browser . Exists ( By . LinkText ( "Streaming GET with internal redirection" ) ) . Click ( ) ;
3943 AssertElementRemoved ( _originalH1Element ) ;
4044 Browser . Equal ( "Scroll to hash" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
@@ -47,16 +51,23 @@ public void RedirectStreamingGetToInternal()
4751 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
4852 }
4953
50- [ Fact ]
51- public void RedirectStreamingGetToExternal ( )
54+ [ Theory ]
55+ [ InlineData ( true ) ]
56+ [ InlineData ( false ) ]
57+ public void RedirectStreamingGetToExternal ( bool disableThrowNavigationException )
5258 {
59+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
5360 Browser . Exists ( By . LinkText ( "Streaming GET with external redirection" ) ) . Click ( ) ;
5461 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
5562 }
5663
57- [ Fact ]
58- public void RedirectStreamingPostToInternal ( )
64+ [ Theory ]
65+ [ InlineData ( true ) ]
66+ [ InlineData ( false ) ]
67+ public void RedirectStreamingPostToInternal ( bool disableThrowNavigationException )
5968 {
69+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
70+
6071 Browser . Exists ( By . CssSelector ( "#form-streaming-internal button" ) ) . Click ( ) ;
6172 AssertElementRemoved ( _originalH1Element ) ;
6273 Browser . Equal ( "Scroll to hash" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
@@ -69,16 +80,23 @@ public void RedirectStreamingPostToInternal()
6980 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
7081 }
7182
72- [ Fact ]
73- public void RedirectStreamingPostToExternal ( )
83+ [ Theory ]
84+ [ InlineData ( true ) ]
85+ [ InlineData ( false ) ]
86+ public void RedirectStreamingPostToExternal ( bool disableThrowNavigationException )
7487 {
88+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
7589 Browser . Exists ( By . CssSelector ( "#form-streaming-external button" ) ) . Click ( ) ;
7690 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
7791 }
7892
79- [ Fact ]
80- public void RedirectEnhancedGetToInternal ( )
93+ [ Theory ]
94+ [ InlineData ( true ) ]
95+ [ InlineData ( false ) ]
96+ public void RedirectEnhancedGetToInternal ( bool disableThrowNavigationException )
8197 {
98+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
99+
82100 // Note that for enhanced nav we can't preserve the hash part of the URL, as it
83101 // gets discarded when the browser follows a 'fetch' redirection. This is not solvable
84102 // unless we are willing to make the server return extra information so that the
@@ -95,16 +113,23 @@ public void RedirectEnhancedGetToInternal()
95113 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
96114 }
97115
98- [ Fact ]
99- public void RedirectEnhancedGetToExternal ( )
116+ [ Theory ]
117+ [ InlineData ( true ) ]
118+ [ InlineData ( false ) ]
119+ public void RedirectEnhancedGetToExternal ( bool disableThrowNavigationException )
100120 {
121+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
101122 Browser . Exists ( By . LinkText ( "Enhanced GET with external redirection" ) ) . Click ( ) ;
102123 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
103124 }
104125
105- [ Fact ]
106- public void RedirectEnhancedPostToInternal ( )
126+ [ Theory ]
127+ [ InlineData ( true ) ]
128+ [ InlineData ( false ) ]
129+ public void RedirectEnhancedPostToInternal ( bool disableThrowNavigationException )
107130 {
131+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
132+
108133 // See above for why enhanced nav doesn't support preserving the hash
109134 Browser . Exists ( By . CssSelector ( "#form-enhanced-internal button" ) ) . Click ( ) ;
110135 Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -116,16 +141,23 @@ public void RedirectEnhancedPostToInternal()
116141 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
117142 }
118143
119- [ Fact ]
120- public void RedirectEnhancedPostToExternal ( )
144+ [ Theory ]
145+ [ InlineData ( true ) ]
146+ [ InlineData ( false ) ]
147+ public void RedirectEnhancedPostToExternal ( bool disableThrowNavigationException )
121148 {
149+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
122150 Browser . Exists ( By . CssSelector ( "#form-enhanced-external button" ) ) . Click ( ) ;
123151 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
124152 }
125153
126- [ Fact ]
127- public void RedirectStreamingEnhancedGetToInternal ( )
154+ [ Theory ]
155+ [ InlineData ( true ) ]
156+ [ InlineData ( false ) ]
157+ public void RedirectStreamingEnhancedGetToInternal ( bool disableThrowNavigationException )
128158 {
159+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
160+
129161 // See above for why enhanced nav doesn't support preserving the hash
130162 Browser . Exists ( By . LinkText ( "Streaming enhanced GET with internal redirection" ) ) . Click ( ) ;
131163 Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -137,16 +169,25 @@ public void RedirectStreamingEnhancedGetToInternal()
137169 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
138170 }
139171
140- [ Fact ]
141- public void RedirectStreamingEnhancedGetToExternal ( )
172+ [ Theory ]
173+ [ InlineData ( true ) ]
174+ [ InlineData ( false ) ]
175+ public void RedirectStreamingEnhancedGetToExternal ( bool disableThrowNavigationException )
142176 {
177+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
178+
143179 Browser . Exists ( By . LinkText ( "Streaming enhanced GET with external redirection" ) ) . Click ( ) ;
144180 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
145181 }
182+
146183
147- [ Fact ]
148- public void RedirectStreamingEnhancedPostToInternal ( )
184+ [ Theory ]
185+ [ InlineData ( true ) ]
186+ [ InlineData ( false ) ]
187+ public void RedirectStreamingEnhancedPostToInternal ( bool disableThrowNavigationException )
149188 {
189+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
190+
150191 // See above for why enhanced nav doesn't support preserving the hash
151192 Browser . Exists ( By . CssSelector ( "#form-streaming-enhanced-internal button" ) ) . Click ( ) ;
152193 Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -158,16 +199,24 @@ public void RedirectStreamingEnhancedPostToInternal()
158199 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
159200 }
160201
161- [ Fact ]
162- public void RedirectStreamingEnhancedPostToExternal ( )
202+ [ Theory ]
203+ [ InlineData ( true ) ]
204+ [ InlineData ( false ) ]
205+ public void RedirectStreamingEnhancedPostToExternal ( bool disableThrowNavigationException )
163206 {
207+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
208+
164209 Browser . Exists ( By . CssSelector ( "#form-streaming-enhanced-external button" ) ) . Click ( ) ;
165210 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
166211 }
167212
168- [ Fact ]
169- public void RedirectEnhancedNonBlazorGetToInternal ( )
213+ [ Theory ]
214+ [ InlineData ( true ) ]
215+ [ InlineData ( false ) ]
216+ public void RedirectEnhancedNonBlazorGetToInternal ( bool disableThrowNavigationException )
170217 {
218+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
219+
171220 // See above for why enhanced nav doesn't support preserving the hash
172221 Browser . Exists ( By . LinkText ( "Enhanced GET to non-Blazor endpoint with internal redirection" ) ) . Click ( ) ;
173222 Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -179,16 +228,24 @@ public void RedirectEnhancedNonBlazorGetToInternal()
179228 Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
180229 }
181230
182- [ Fact ]
183- public void RedirectEnhancedNonBlazorGetToExternal ( )
231+ [ Theory ]
232+ [ InlineData ( true ) ]
233+ [ InlineData ( false ) ]
234+ public void RedirectEnhancedNonBlazorGetToExternal ( bool disableThrowNavigationException )
184235 {
236+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
237+
185238 Browser . Exists ( By . LinkText ( "Enhanced GET to non-Blazor endpoint with external redirection" ) ) . Click ( ) ;
186239 Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
187240 }
188241
189- [ Fact ]
190- public void RedirectEnhancedNonBlazorPostToInternal ( )
242+ [ Theory ]
243+ [ InlineData ( true ) ]
244+ [ InlineData ( false ) ]
245+ public void RedirectEnhancedNonBlazorPostToInternal ( bool disableThrowNavigationException )
191246 {
247+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
248+
192249 // See above for why enhanced nav doesn't support preserving the hash
193250 Browser . Exists ( By . CssSelector ( "#form-nonblazor-enhanced-internal button" ) ) . Click ( ) ;
194251 Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -205,9 +262,13 @@ public void RedirectEnhancedNonBlazorPostToInternal()
205262 // response to something like a 200 that the 'fetch' is allowed to read (embedding the
206263 // destination URL).
207264
208- [ Fact ]
209- public void RedirectEnhancedGetToInternalWithErrorBoundary ( )
265+ [ Theory ]
266+ [ InlineData ( true ) ]
267+ [ InlineData ( false ) ]
268+ public void RedirectEnhancedGetToInternalWithErrorBoundary ( bool disableThrowNavigationException )
210269 {
270+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
271+
211272 // This test verifies that redirection works even if an ErrorBoundary wraps
212273 // a component throwing a NavigationException.
213274
0 commit comments