Skip to content

Commit

Permalink
[release/9.0] [browser] Fix fingerprinting and loadAllSatelliteResour…
Browse files Browse the repository at this point in the history
…ces=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]>
  • Loading branch information
3 people authored Sep 25, 2024
1 parent bad31df commit faf43ae
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 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,19 +24,35 @@ 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().ToLowerInvariant() }
));

var expectedOutput = new List<Action<string>>();
if (!loadAllSatelliteResources)
{
// If we are loading all satellite, we don't have a way to test resources without satellite assemblies being loaded.
// So there messages are should be present only when we are lazily loading satellites.
expectedOutput.Add(m => Assert.Equal("default: hello", m));
expectedOutput.Add(m => Assert.Equal("es-ES without satellite: hello", m));
}

expectedOutput.Add(m => Assert.Equal("default: hello", m));
expectedOutput.Add(m => Assert.Equal("es-ES with satellite: hola", m));

Assert.Collection(
result.TestOutput,
m => Assert.Equal("default: hello", m),
m => Assert.Equal("es-ES without satellite: hello", m),
m => Assert.Equal("default: hello", m),
m => Assert.Equal("es-ES with satellite: hola", m)
expectedOutput.ToArray()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
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)
{
ResourceLibrary.ResourceAccessor.Read(TestOutput.WriteLine, false);
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 @@ -27,6 +27,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 @@ -132,7 +137,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 faf43ae

Please sign in to comment.