Skip to content

Commit faf43ae

Browse files
github-actions[bot]marafjeffschwMSFT
authored
[release/9.0] [browser] Fix fingerprinting and loadAllSatelliteResources=true (#108198)
* Set virtualPath for resource show loaded with loadAllSatelliteResources=true * WBT using loadAllSatelliteResources=true * Fix passing parameter to test added in #108190 * Update expected test outputs --------- Co-authored-by: Marek Fišera <[email protected]> Co-authored-by: Jeff Schwartz <[email protected]>
1 parent bad31df commit faf43ae

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

src/mono/browser/runtime/loader/assets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ export function prepareAssets () {
375375
if (config.loadAllSatelliteResources && resources.satelliteResources) {
376376
for (const culture in resources.satelliteResources) {
377377
for (const name in resources.satelliteResources[culture]) {
378-
assetsToLoad.push({
378+
addAsset({
379379
name,
380380
hash: resources.satelliteResources[culture][name],
381381
behavior: "resource",
382382
culture
383-
});
383+
}, !resources.coreAssembly);
384384
}
385385
}
386386
}

src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/SatelliteLoadingTests.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,35 @@ public SatelliteLoadingTests(ITestOutputHelper output, SharedBuildPerTestClassFi
2424
{
2525
}
2626

27-
[Fact, TestCategory("no-fingerprinting")]
28-
public async Task LoadSatelliteAssembly()
27+
[Theory, TestCategory("no-fingerprinting")]
28+
[InlineData(false)]
29+
[InlineData(true)]
30+
public async Task LoadSatelliteAssembly(bool loadAllSatelliteResources)
2931
{
3032
CopyTestAsset("WasmBasicTestApp", "SatelliteLoadingTests", "App");
3133
BuildProject("Debug");
3234

33-
var result = await RunSdkStyleAppForBuild(new(Configuration: "Debug", TestScenario: "SatelliteAssembliesTest"));
35+
var result = await RunSdkStyleAppForBuild(new(
36+
Configuration: "Debug",
37+
TestScenario: "SatelliteAssembliesTest",
38+
BrowserQueryString: new Dictionary<string, string> { ["loadAllSatelliteResources"] = loadAllSatelliteResources.ToString().ToLowerInvariant() }
39+
));
40+
41+
var expectedOutput = new List<Action<string>>();
42+
if (!loadAllSatelliteResources)
43+
{
44+
// If we are loading all satellite, we don't have a way to test resources without satellite assemblies being loaded.
45+
// So there messages are should be present only when we are lazily loading satellites.
46+
expectedOutput.Add(m => Assert.Equal("default: hello", m));
47+
expectedOutput.Add(m => Assert.Equal("es-ES without satellite: hello", m));
48+
}
49+
50+
expectedOutput.Add(m => Assert.Equal("default: hello", m));
51+
expectedOutput.Add(m => Assert.Equal("es-ES with satellite: hola", m));
52+
3453
Assert.Collection(
3554
result.TestOutput,
36-
m => Assert.Equal("default: hello", m),
37-
m => Assert.Equal("es-ES without satellite: hello", m),
38-
m => Assert.Equal("default: hello", m),
39-
m => Assert.Equal("es-ES with satellite: hola", m)
55+
expectedOutput.ToArray()
4056
);
4157
}
4258

src/mono/wasm/testassets/WasmBasicTestApp/App/SatelliteAssembliesTest.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
public partial class SatelliteAssembliesTest
99
{
1010
[JSExport]
11-
public static async Task Run()
11+
public static async Task Run(bool loadSatelliteAssemblies)
1212
{
13-
ResourceLibrary.ResourceAccessor.Read(TestOutput.WriteLine, false);
14-
15-
await LoadSatelliteAssemblies(new[] { "es-ES" });
13+
if (loadSatelliteAssemblies)
14+
{
15+
ResourceLibrary.ResourceAccessor.Read(TestOutput.WriteLine, false);
16+
await LoadSatelliteAssemblies(new[] { "es-ES" });
17+
}
1618

1719
ResourceLibrary.ResourceAccessor.Read(TestOutput.WriteLine, true);
1820
}

src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ dotnet
2727

2828
// Modify runtime start based on test case
2929
switch (testCase) {
30+
case "SatelliteAssembliesTest":
31+
if (params.get("loadAllSatelliteResources") === "true") {
32+
dotnet.withConfig({ loadAllSatelliteResources: true });
33+
}
34+
break;
3035
case "AppSettingsTest":
3136
dotnet.withApplicationEnvironment(params.get("applicationEnvironment"));
3237
break;
@@ -132,7 +137,7 @@ const assemblyExtension = Object.keys(config.resources.coreAssembly)[0].endsWith
132137
try {
133138
switch (testCase) {
134139
case "SatelliteAssembliesTest":
135-
await exports.SatelliteAssembliesTest.Run();
140+
await exports.SatelliteAssembliesTest.Run(params.get("loadAllSatelliteResources") !== "true");
136141
exit(0);
137142
break;
138143
case "LazyLoadingTest":

0 commit comments

Comments
 (0)