Skip to content

Commit 16d0cf8

Browse files
committed
Add HeadOutlet to TestServer app, use meta tag for setting CSP in reconnect test
1 parent 380d237 commit 16d0cf8

File tree

4 files changed

+12
-29
lines changed

4 files changed

+12
-29
lines changed

src/Components/test/E2ETest/ServerExecutionTests/ServerReconnectionCustomUITest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests;
1616

17-
public class ServerReconnectionCustomUITest : ServerTestBase<BasicTestAppServerSiteFixture<ServerStartupWithCsp>>
17+
public class ServerReconnectionCustomUITest : ServerTestBase<BasicTestAppServerSiteFixture<ServerStartup>>
1818
{
1919
public ServerReconnectionCustomUITest(
2020
BrowserFixture browserFixture,
21-
BasicTestAppServerSiteFixture<ServerStartupWithCsp> serverFixture,
21+
BasicTestAppServerSiteFixture<ServerStartup> serverFixture,
2222
ITestOutputHelper output)
2323
: base(browserFixture, serverFixture, output)
2424
{
@@ -38,7 +38,7 @@ protected override void InitializeAsyncCore()
3838
/// JS fallback code (see 'DefaultReconnectDisplay.ts').
3939
/// </summary>
4040
[Fact]
41-
public void CustomReconnectUIIsDisplayed()
41+
public void ReconnectionUI_CustomDialog_IsDisplayed()
4242
{
4343
Browser.Exists(By.Id("increment")).Click();
4444

@@ -66,7 +66,7 @@ public void CustomReconnectUIIsDisplayed()
6666
/// Tests that when the custom reconnect UI is used, there are no style-related CSP errors.
6767
/// </summary>
6868
[Fact]
69-
public void StyleSrcCSPIsNotViolated()
69+
public void ReconnectionUI_WorksWith_StrictStyleCspPolicy()
7070
{
7171
var js = (IJavaScriptExecutor)Browser;
7272
js.ExecuteScript("Blazor._internal.forceCloseConnection()");

src/Components/test/testassets/BasicTestApp/Reconnection/ReconnectionComponent.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525

2626
@if (useCustomReconnectModal)
2727
{
28+
// We set stricter CSP for styles as we want to check that the application is CSP compliant
29+
// when using a custom reconnect modal.
30+
// (We know that it is not compliant with the JS-created default reconnect UI.)
31+
<HeadContent>
32+
<meta http-equiv="Content-Security-Policy" content="style-src 'self';">
33+
</HeadContent>
34+
2835
<dialog id="components-reconnect-modal">
2936
Rejoining the server...
3037
</dialog>

src/Components/test/testassets/Components.TestServer/Pages/_ServerHost.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<!-- Used by ExternalContentPackage -->
1313
<link href="_content/TestContentPackage/styles.css" rel="stylesheet" />
1414
<link href="Components.TestServer.styles.css" rel="stylesheet" />
15+
<component type="typeof(Microsoft.AspNetCore.Components.Web.HeadOutlet)" render-mode="Server" />
1516
</head>
1617
<body>
1718
<root><component type="typeof(BasicTestApp.Index)" render-mode="Server" /></root>

src/Components/test/testassets/Components.TestServer/ServerStartupWithCsp.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)