Bug 1767171 - Prevent browser_asrouter_bug1761552.js from being intermittent r=emcminn

There is a race condition somewhere in the localization code between
registering a L10nFileSource and attempting to use it too soon. We don't
actually need to test that the translation of our string ID works as expected,
just that the correct translation file ends up in the correct place, so I've
removed the calls that do actual localization.

Differential Revision: https://phabricator.services.mozilla.com/D145514
This commit is contained in:
Barret Rennie 2022-05-20 03:08:36 +00:00
Родитель f32c9fbea0
Коммит 15e61ebcaa
1 изменённых файлов: 10 добавлений и 23 удалений

Просмотреть файл

@ -9,10 +9,10 @@ const { ASRouter, MessageLoaderUtils } = ChromeUtils.import(
const { PanelTestProvider } = ChromeUtils.import(
"resource://activity-stream/lib/PanelTestProvider.jsm"
);
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
const { RemoteL10n } = ChromeUtils.import(
"resource://activity-stream/lib/RemoteL10n.jsm"
);
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
const { RemoteSettings } = ChromeUtils.import(
"resource://services-settings/remote-settings.js"
);
@ -153,11 +153,16 @@ async function serveRemoteSettings() {
}
add_task(async function test_asrouter() {
const MS_LANGUAGE_PACKS_DIR = PathUtils.join(
PathUtils.localProfileDir,
"settings",
"main",
"ms-language-packs"
);
const sandbox = sinon.createSandbox();
const stop = await serveRemoteSettings();
await SpecialPowers.pushPrefEnv({
set: [
["browser.newtabpage.activity-stream.asrouter.useRemoteL10n", true],
[
"browser.newtabpage.activity-stream.asrouter.providers.cfr",
JSON.stringify({
@ -179,6 +184,8 @@ add_task(async function test_asrouter() {
await SpecialPowers.popPrefEnv();
await stop();
sandbox.restore();
await IOUtils.remove(MS_LANGUAGE_PACKS_DIR, { recursive: true });
RemoteL10n.reloadL10n();
});
// We can't stub Services.locale.appLocaleAsBCP47 directly because its an
@ -210,10 +217,7 @@ add_task(async function test_asrouter() {
);
const path = PathUtils.join(
PathUtils.localProfileDir,
"settings",
"main",
"ms-language-packs",
MS_LANGUAGE_PACKS_DIR,
"browser",
"newtab",
"asrouter.ftl"
@ -224,21 +228,4 @@ add_task(async function test_asrouter() {
FLUENT_CONTENT,
"asrouter.ftl content matches expected"
);
// Initialize RemoteL10n's DOMLocaliaztion to register the cfr source.
void RemoteL10n.l10n;
// We cannot use RemoteL10n.l10n.formatValue here directly because we cannot
// fool DOMLocalization into thinking we are actually the JP locale.
const jpLocalization = new Localization(
["browser/newtab/asrouter.ftl"],
false,
L10nRegistry.getInstance(),
[Services.locale.appLocaleAsBCP47]
);
Assert.equal(
await jpLocalization.formatValue("asrouter-test-string"),
"Test Test Test"
);
});