Remove more references to JSRuntime.Current
This commit is contained in:
parent
511538a19e
commit
6a57218e14
|
|
@ -49,22 +49,6 @@ namespace Microsoft.AspNetCore.Blazor.Hosting.Test
|
|||
Assert.True(startup.ConfigureCalled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BrowserHost_StartAsync_SetsJSRuntime()
|
||||
{
|
||||
// Arrange
|
||||
var builder = new WebAssemblyHostBuilder();
|
||||
builder.UseBlazorStartup<MockStartup>();
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
// Act
|
||||
await host.StartAsync();
|
||||
|
||||
// Assert
|
||||
Assert.IsType<MonoWebAssemblyJSRuntime>(JSRuntime.Current);
|
||||
}
|
||||
|
||||
private class MockStartup : IBlazorStartup
|
||||
{
|
||||
public bool ConfigureCalled { get; set; }
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ namespace Microsoft.AspNetCore.Blazor.E2EPerformance
|
|||
{
|
||||
public static class BenchmarkEvent
|
||||
{
|
||||
public static void Send(string name)
|
||||
public static void Send(IJSRuntime jsRuntime, string name)
|
||||
{
|
||||
((IJSInProcessRuntime)JSRuntime.Current).Invoke<object>(
|
||||
((IJSInProcessRuntime)jsRuntime).Invoke<object>(
|
||||
"receiveBenchmarkEvent",
|
||||
name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
@page "/"
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
Hello, world!
|
||||
|
||||
@functions {
|
||||
protected override void OnAfterRender()
|
||||
{
|
||||
BenchmarkEvent.Send("Rendered index.cshtml");
|
||||
BenchmarkEvent.Send(JSRuntime, "Rendered index.cshtml");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@page "/json"
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<h2>JSON performance</h2>
|
||||
|
||||
|
|
@ -37,7 +38,7 @@
|
|||
|
||||
protected override void OnAfterRender()
|
||||
{
|
||||
BenchmarkEvent.Send("Finished JSON processing");
|
||||
BenchmarkEvent.Send(JSRuntime, "Finished JSON processing");
|
||||
}
|
||||
|
||||
string serializedValue;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@page "/renderlist"
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<h2>Render List</h2>
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ Number of items: <input id="num-items" type="number" bind=@numItems />
|
|||
|
||||
protected override void OnAfterRender()
|
||||
{
|
||||
BenchmarkEvent.Send("Finished rendering list");
|
||||
BenchmarkEvent.Send(JSRuntime, "Finished rendering list");
|
||||
}
|
||||
|
||||
static IEnumerable<WeatherForecast> GenerateForecasts(int count)
|
||||
|
|
@ -71,4 +72,4 @@ Number of items: <input id="num-items" type="number" bind=@numItems />
|
|||
public int TemperatureF { get; set; }
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue