@@ -32,9 +32,13 @@ public override async Task InitializeAsync()
32
32
Browser . Equal ( "Redirections" , ( ) => _originalH1Element . Text ) ;
33
33
}
34
34
35
- [ Fact ]
36
- public void RedirectStreamingGetToInternal ( )
35
+ [ Theory ]
36
+ [ InlineData ( true ) ]
37
+ [ InlineData ( false ) ]
38
+ public void RedirectStreamingGetToInternal ( bool disableThrowNavigationException )
37
39
{
40
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
41
+
38
42
Browser . Exists ( By . LinkText ( "Streaming GET with internal redirection" ) ) . Click ( ) ;
39
43
AssertElementRemoved ( _originalH1Element ) ;
40
44
Browser . Equal ( "Scroll to hash" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
@@ -47,16 +51,23 @@ public void RedirectStreamingGetToInternal()
47
51
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
48
52
}
49
53
50
- [ Fact ]
51
- public void RedirectStreamingGetToExternal ( )
54
+ [ Theory ]
55
+ [ InlineData ( true ) ]
56
+ [ InlineData ( false ) ]
57
+ public void RedirectStreamingGetToExternal ( bool disableThrowNavigationException )
52
58
{
59
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
53
60
Browser . Exists ( By . LinkText ( "Streaming GET with external redirection" ) ) . Click ( ) ;
54
61
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
55
62
}
56
63
57
- [ Fact ]
58
- public void RedirectStreamingPostToInternal ( )
64
+ [ Theory ]
65
+ [ InlineData ( true ) ]
66
+ [ InlineData ( false ) ]
67
+ public void RedirectStreamingPostToInternal ( bool disableThrowNavigationException )
59
68
{
69
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
70
+
60
71
Browser . Exists ( By . CssSelector ( "#form-streaming-internal button" ) ) . Click ( ) ;
61
72
AssertElementRemoved ( _originalH1Element ) ;
62
73
Browser . Equal ( "Scroll to hash" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
@@ -69,16 +80,23 @@ public void RedirectStreamingPostToInternal()
69
80
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
70
81
}
71
82
72
- [ Fact ]
73
- public void RedirectStreamingPostToExternal ( )
83
+ [ Theory ]
84
+ [ InlineData ( true ) ]
85
+ [ InlineData ( false ) ]
86
+ public void RedirectStreamingPostToExternal ( bool disableThrowNavigationException )
74
87
{
88
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
75
89
Browser . Exists ( By . CssSelector ( "#form-streaming-external button" ) ) . Click ( ) ;
76
90
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
77
91
}
78
92
79
- [ Fact ]
80
- public void RedirectEnhancedGetToInternal ( )
93
+ [ Theory ]
94
+ [ InlineData ( true ) ]
95
+ [ InlineData ( false ) ]
96
+ public void RedirectEnhancedGetToInternal ( bool disableThrowNavigationException )
81
97
{
98
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
99
+
82
100
// Note that for enhanced nav we can't preserve the hash part of the URL, as it
83
101
// gets discarded when the browser follows a 'fetch' redirection. This is not solvable
84
102
// unless we are willing to make the server return extra information so that the
@@ -95,16 +113,23 @@ public void RedirectEnhancedGetToInternal()
95
113
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
96
114
}
97
115
98
- [ Fact ]
99
- public void RedirectEnhancedGetToExternal ( )
116
+ [ Theory ]
117
+ [ InlineData ( true ) ]
118
+ [ InlineData ( false ) ]
119
+ public void RedirectEnhancedGetToExternal ( bool disableThrowNavigationException )
100
120
{
121
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
101
122
Browser . Exists ( By . LinkText ( "Enhanced GET with external redirection" ) ) . Click ( ) ;
102
123
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
103
124
}
104
125
105
- [ Fact ]
106
- public void RedirectEnhancedPostToInternal ( )
126
+ [ Theory ]
127
+ [ InlineData ( true ) ]
128
+ [ InlineData ( false ) ]
129
+ public void RedirectEnhancedPostToInternal ( bool disableThrowNavigationException )
107
130
{
131
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
132
+
108
133
// See above for why enhanced nav doesn't support preserving the hash
109
134
Browser . Exists ( By . CssSelector ( "#form-enhanced-internal button" ) ) . Click ( ) ;
110
135
Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -116,16 +141,23 @@ public void RedirectEnhancedPostToInternal()
116
141
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
117
142
}
118
143
119
- [ Fact ]
120
- public void RedirectEnhancedPostToExternal ( )
144
+ [ Theory ]
145
+ [ InlineData ( true ) ]
146
+ [ InlineData ( false ) ]
147
+ public void RedirectEnhancedPostToExternal ( bool disableThrowNavigationException )
121
148
{
149
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
122
150
Browser . Exists ( By . CssSelector ( "#form-enhanced-external button" ) ) . Click ( ) ;
123
151
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
124
152
}
125
153
126
- [ Fact ]
127
- public void RedirectStreamingEnhancedGetToInternal ( )
154
+ [ Theory ]
155
+ [ InlineData ( true ) ]
156
+ [ InlineData ( false ) ]
157
+ public void RedirectStreamingEnhancedGetToInternal ( bool disableThrowNavigationException )
128
158
{
159
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
160
+
129
161
// See above for why enhanced nav doesn't support preserving the hash
130
162
Browser . Exists ( By . LinkText ( "Streaming enhanced GET with internal redirection" ) ) . Click ( ) ;
131
163
Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -137,16 +169,25 @@ public void RedirectStreamingEnhancedGetToInternal()
137
169
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
138
170
}
139
171
140
- [ Fact ]
141
- public void RedirectStreamingEnhancedGetToExternal ( )
172
+ [ Theory ]
173
+ [ InlineData ( true ) ]
174
+ [ InlineData ( false ) ]
175
+ public void RedirectStreamingEnhancedGetToExternal ( bool disableThrowNavigationException )
142
176
{
177
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
178
+
143
179
Browser . Exists ( By . LinkText ( "Streaming enhanced GET with external redirection" ) ) . Click ( ) ;
144
180
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
145
181
}
182
+
146
183
147
- [ Fact ]
148
- public void RedirectStreamingEnhancedPostToInternal ( )
184
+ [ Theory ]
185
+ [ InlineData ( true ) ]
186
+ [ InlineData ( false ) ]
187
+ public void RedirectStreamingEnhancedPostToInternal ( bool disableThrowNavigationException )
149
188
{
189
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
190
+
150
191
// See above for why enhanced nav doesn't support preserving the hash
151
192
Browser . Exists ( By . CssSelector ( "#form-streaming-enhanced-internal button" ) ) . Click ( ) ;
152
193
Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -158,16 +199,24 @@ public void RedirectStreamingEnhancedPostToInternal()
158
199
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
159
200
}
160
201
161
- [ Fact ]
162
- public void RedirectStreamingEnhancedPostToExternal ( )
202
+ [ Theory ]
203
+ [ InlineData ( true ) ]
204
+ [ InlineData ( false ) ]
205
+ public void RedirectStreamingEnhancedPostToExternal ( bool disableThrowNavigationException )
163
206
{
207
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
208
+
164
209
Browser . Exists ( By . CssSelector ( "#form-streaming-enhanced-external button" ) ) . Click ( ) ;
165
210
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
166
211
}
167
212
168
- [ Fact ]
169
- public void RedirectEnhancedNonBlazorGetToInternal ( )
213
+ [ Theory ]
214
+ [ InlineData ( true ) ]
215
+ [ InlineData ( false ) ]
216
+ public void RedirectEnhancedNonBlazorGetToInternal ( bool disableThrowNavigationException )
170
217
{
218
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
219
+
171
220
// See above for why enhanced nav doesn't support preserving the hash
172
221
Browser . Exists ( By . LinkText ( "Enhanced GET to non-Blazor endpoint with internal redirection" ) ) . Click ( ) ;
173
222
Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -179,16 +228,24 @@ public void RedirectEnhancedNonBlazorGetToInternal()
179
228
Assert . EndsWith ( "/subdir/redirect" , Browser . Url ) ;
180
229
}
181
230
182
- [ Fact ]
183
- public void RedirectEnhancedNonBlazorGetToExternal ( )
231
+ [ Theory ]
232
+ [ InlineData ( true ) ]
233
+ [ InlineData ( false ) ]
234
+ public void RedirectEnhancedNonBlazorGetToExternal ( bool disableThrowNavigationException )
184
235
{
236
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
237
+
185
238
Browser . Exists ( By . LinkText ( "Enhanced GET to non-Blazor endpoint with external redirection" ) ) . Click ( ) ;
186
239
Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
187
240
}
188
241
189
- [ Fact ]
190
- public void RedirectEnhancedNonBlazorPostToInternal ( )
242
+ [ Theory ]
243
+ [ InlineData ( true ) ]
244
+ [ InlineData ( false ) ]
245
+ public void RedirectEnhancedNonBlazorPostToInternal ( bool disableThrowNavigationException )
191
246
{
247
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
248
+
192
249
// See above for why enhanced nav doesn't support preserving the hash
193
250
Browser . Exists ( By . CssSelector ( "#form-nonblazor-enhanced-internal button" ) ) . Click ( ) ;
194
251
Browser . Equal ( "Scroll to hash" , ( ) => _originalH1Element . Text ) ;
@@ -205,9 +262,13 @@ public void RedirectEnhancedNonBlazorPostToInternal()
205
262
// response to something like a 200 that the 'fetch' is allowed to read (embedding the
206
263
// destination URL).
207
264
208
- [ Fact ]
209
- public void RedirectEnhancedGetToInternalWithErrorBoundary ( )
265
+ [ Theory ]
266
+ [ InlineData ( true ) ]
267
+ [ InlineData ( false ) ]
268
+ public void RedirectEnhancedGetToInternalWithErrorBoundary ( bool disableThrowNavigationException )
210
269
{
270
+ AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
271
+
211
272
// This test verifies that redirection works even if an ErrorBoundary wraps
212
273
// a component throwing a NavigationException.
213
274
0 commit comments