Skip to content

Commit 6a57218

Browse files
committed
Remove more references to JSRuntime.Current
1 parent 511538a commit 6a57218

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

src/Components/Blazor/Blazor/test/Hosting/WebAssemblyHostTest.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,6 @@ public async Task BrowserHost_StartAsync_RunsConfigureMethod()
4949
Assert.True(startup.ConfigureCalled);
5050
}
5151

52-
[Fact]
53-
public async Task BrowserHost_StartAsync_SetsJSRuntime()
54-
{
55-
// Arrange
56-
var builder = new WebAssemblyHostBuilder();
57-
builder.UseBlazorStartup<MockStartup>();
58-
59-
var host = builder.Build();
60-
61-
// Act
62-
await host.StartAsync();
63-
64-
// Assert
65-
Assert.IsType<MonoWebAssemblyJSRuntime>(JSRuntime.Current);
66-
}
67-
6852
private class MockStartup : IBlazorStartup
6953
{
7054
public bool ConfigureCalled { get; set; }

src/Components/Blazor/testassets/Microsoft.AspNetCore.Blazor.E2EPerformance/BenchmarkEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace Microsoft.AspNetCore.Blazor.E2EPerformance
77
{
88
public static class BenchmarkEvent
99
{
10-
public static void Send(string name)
10+
public static void Send(IJSRuntime jsRuntime, string name)
1111
{
12-
((IJSInProcessRuntime)JSRuntime.Current).Invoke<object>(
12+
((IJSInProcessRuntime)jsRuntime).Invoke<object>(
1313
"receiveBenchmarkEvent",
1414
name);
1515
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
@page "/"
2+
@inject IJSRuntime JSRuntime
23

34
Hello, world!
45

56
@functions {
67
protected override void OnAfterRender()
78
{
8-
BenchmarkEvent.Send("Rendered index.cshtml");
9+
BenchmarkEvent.Send(JSRuntime, "Rendered index.cshtml");
910
}
1011
}

src/Components/Blazor/testassets/Microsoft.AspNetCore.Blazor.E2EPerformance/Pages/Json.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/json"
2+
@inject IJSRuntime JSRuntime
23

34
<h2>JSON performance</h2>
45

@@ -37,7 +38,7 @@
3738

3839
protected override void OnAfterRender()
3940
{
40-
BenchmarkEvent.Send("Finished JSON processing");
41+
BenchmarkEvent.Send(JSRuntime, "Finished JSON processing");
4142
}
4243

4344
string serializedValue;

src/Components/Blazor/testassets/Microsoft.AspNetCore.Blazor.E2EPerformance/Pages/RenderList.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/renderlist"
2+
@inject IJSRuntime JSRuntime
23

34
<h2>Render List</h2>
45

@@ -47,7 +48,7 @@ Number of items: <input id="num-items" type="number" bind=@numItems />
4748

4849
protected override void OnAfterRender()
4950
{
50-
BenchmarkEvent.Send("Finished rendering list");
51+
BenchmarkEvent.Send(JSRuntime, "Finished rendering list");
5152
}
5253

5354
static IEnumerable<WeatherForecast> GenerateForecasts(int count)
@@ -71,4 +72,4 @@ Number of items: <input id="num-items" type="number" bind=@numItems />
7172
public int TemperatureF { get; set; }
7273
public string Summary { get; set; }
7374
}
74-
}
75+
}

0 commit comments

Comments
 (0)