Skip to content

Commit 5d8525c

Browse files
authored
Remove await for WASM platform.callEntryPoint (#31997)
* Remove await for WASM `platform.callEntryPoint` Also added an E2E test. Addresses #31971 Insertion into preview 4: #31978 * Update src/Components/test/E2ETest/Tests/StandaloneAppTest.cs
1 parent 7e9a049 commit 5d8525c

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/Components/Web.JS/src/Boot.WebAssembly.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async function boot(options?: Partial<WebAssemblyStartOptions>): Promise<void> {
119119
}
120120

121121
// Start up the application
122-
await platform.callEntryPoint(resourceLoader.bootConfig.entryAssembly);
122+
platform.callEntryPoint(resourceLoader.bootConfig.entryAssembly);
123123
}
124124

125125
function invokeJSFromDotNet(callInfo: Pointer, arg0: any, arg1: any, arg2: any): any {

src/Components/WebAssembly/testassets/StandaloneApp/wwwroot/index.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
<a class="dismiss">🗙</a>
1919
</div>
2020

21-
<script src="_framework/blazor.webassembly.js"></script>
21+
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
22+
<script>
23+
(function(){
24+
Blazor.start().then(function () {
25+
window['__aspnetcore__testing__blazor_wasm__started__'] = true;
26+
});
27+
})();
28+
</script>
2229
</body>
2330
</html>

src/Components/test/E2ETest/Tests/StandaloneAppTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ public void HasFetchDataPage()
108108
}
109109
}
110110

111+
[Fact]
112+
public void IsStarted()
113+
{
114+
// Read from property
115+
var jsExecutor = (IJavaScriptExecutor)Browser;
116+
117+
var isStarted = jsExecutor.ExecuteScript("return window['__aspnetcore__testing__blazor_wasm__started__'];");
118+
if (isStarted is null)
119+
{
120+
throw new InvalidOperationException("Blazor wasm started value not set");
121+
}
122+
123+
// Confirm server has started
124+
Assert.True((bool)isStarted);
125+
}
126+
111127
private void WaitUntilLoaded()
112128
{
113129
var app = Browser.Exists(By.TagName("app"));

0 commit comments

Comments
 (0)