Skip to content

Commit

Permalink
[browser] Fix fingerprinting and loadAllSatelliteResources=true (#108190
Browse files Browse the repository at this point in the history
)
  • Loading branch information
maraf authored Sep 24, 2024
1 parent b7b3d73 commit 6de7e2c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ export function prepareAssets () {
if (config.loadAllSatelliteResources && resources.satelliteResources) {
for (const culture in resources.satelliteResources) {
for (const name in resources.satelliteResources[culture]) {
assetsToLoad.push({
addAsset({
name,
hash: resources.satelliteResources[culture][name],
behavior: "resource",
culture
});
}, !resources.coreAssembly);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ public SatelliteLoadingTests(ITestOutputHelper output, SharedBuildPerTestClassFi
{
}

[Fact, TestCategory("no-fingerprinting")]
public async Task LoadSatelliteAssembly()
[Theory, TestCategory("no-fingerprinting")]
[InlineData(false)]
[InlineData(true)]
public async Task LoadSatelliteAssembly(bool loadAllSatelliteResources)
{
CopyTestAsset("WasmBasicTestApp", "SatelliteLoadingTests", "App");
BuildProject("Debug");

var result = await RunSdkStyleAppForBuild(new(Configuration: "Debug", TestScenario: "SatelliteAssembliesTest"));
var result = await RunSdkStyleAppForBuild(new(
Configuration: "Debug",
TestScenario: "SatelliteAssembliesTest",
BrowserQueryString: new Dictionary<string, string> { ["loadAllSatelliteResources"] = loadAllSatelliteResources.ToString() }
));
Assert.Collection(
result.TestOutput,
m => Assert.Equal("default: hello", m),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
public partial class SatelliteAssembliesTest
{
[JSExport]
public static async Task Run()
public static async Task Run(bool loadSatelliteAssemblies)
{
ResourceLibrary.ResourceAccessor.Read(TestOutput.WriteLine, false);

await LoadSatelliteAssemblies(new[] { "es-ES" });
if (loadSatelliteAssemblies)
await LoadSatelliteAssemblies(new[] { "es-ES" });

ResourceLibrary.ResourceAccessor.Read(TestOutput.WriteLine, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ dotnet

// Modify runtime start based on test case
switch (testCase) {
case "SatelliteAssembliesTest":
if (params.get("loadAllSatelliteResources") === "true") {
dotnet.withConfig({ loadAllSatelliteResources: true });
}
break;
case "AppSettingsTest":
dotnet.withApplicationEnvironment(params.get("applicationEnvironment"));
break;
Expand Down Expand Up @@ -141,7 +146,7 @@ const assemblyExtension = Object.keys(config.resources.coreAssembly)[0].endsWith
try {
switch (testCase) {
case "SatelliteAssembliesTest":
await exports.SatelliteAssembliesTest.Run();
await exports.SatelliteAssembliesTest.Run(params.get("loadAllSatelliteResources") !== "true");
exit(0);
break;
case "LazyLoadingTest":
Expand Down

0 comments on commit 6de7e2c

Please sign in to comment.