Backed out changeset 28e66324f0be (bug 1851216) for bc failure on browser_translations_remote_settings.js

This commit is contained in:
Narcis Beleuzu 2023-09-07 00:52:55 +03:00
parent 8ad240e7c4
commit 67e97e0d91
2 changed files with 4 additions and 81 deletions

View File

@ -199,42 +199,6 @@ export class TranslationsParent extends JSWindowActorParent {
*/
static #previousDetectedLanguages = null;
/**
* Used to determine if we should schedule a sync from RemoteSettings.
* This is done once per TranslationsParent process, and is handled
* during requestIdleCallback.
*/
static #shouldSyncRemoteSettings = true;
/**
* Schedules a requestIdleCallback to sync from Remote Settings
* the first time this function is called, and does nothing on
* all subsequent calls.
*/
#maybeScheduleRemoteSettingsSync() {
// Never schedule a sync if we are running tests: Remote Settings isn't available.
if (
TranslationsParent.isInAutomation() ||
TranslationsParent.#isTranslationsEngineMocked
) {
return;
}
if (TranslationsParent.#shouldSyncRemoteSettings) {
// Only do this once per TranslationsParent process.
TranslationsParent.#shouldSyncRemoteSettings = false;
this.browsingContext.top.currentWindowGlobal.requestIdleCallback(
async () => {
await Promise.all([
TranslationsParent.#getLanguageIdModelRemoteClient().sync(),
TranslationsParent.#getTranslationsWasmRemoteClient().sync(),
TranslationsParent.#getTranslationModelsRemoteClient().sync(),
]);
}
);
}
}
actorCreated() {
this.languageState = new TranslationsLanguageState(
this,
@ -242,8 +206,6 @@ export class TranslationsParent extends JSWindowActorParent {
);
TranslationsParent.#previousDetectedLanguages = null;
this.#maybeScheduleRemoteSettingsSync();
if (TranslationsParent.#translateOnPageReload) {
// The actor was recreated after a page reload, start the translation.
const { fromLanguage, toLanguage } =
@ -1223,19 +1185,8 @@ export class TranslationsParent extends JSWindowActorParent {
return [];
}
const retrievedRecords = await remoteSettingsClient.get({
// Pull the records from the network if empty.
// Pull the records from the network.
syncIfEmpty: true,
// Do not load the JSON dump if it is newer.
//
// The JSON dump comes from the Prod RemoteSettings channel
// so we shouldn't ever have an issue with the Prod server
// being older than the JSON dump itself (this is good).
//
// However, setting this to true will prevent us from
// testing RemoteSettings on the Dev and Stage
// environments if they happen to be older than the
// most recent JSON dump from Prod.
loadDumpIfNewer: false,
// Don't verify the signature if the client is mocked.
verifySignature: VERIFY_SIGNATURES_FROM_FS,
// Apply any filters for retrieving the records.

View File

@ -23,11 +23,6 @@ const firefoxMajorVersion = firefoxFullVersion.match(/\d+/);
// which is of the form `${firefoxMajorVersion}.a1`.
const firefoxAlphaZeroVersion = `${firefoxMajorVersion}.a0`;
// Used for self-built or automated testing builds.
// https://remote-settings.readthedocs.io/en/latest/target-filters.html#env.channel
const defaultChannel = "default";
const releaseChannel = "release";
/**
* Creates a local RemoteSettingsClient for use within tests.
*
@ -42,13 +37,10 @@ async function createRemoteSettingsClient(mockedKey) {
}
// The following test ensures the capabilities of `filter_expression` in remote settings
// to successfully discriminate against the Firefox channel and version when retrieving records.
// to successfully discriminate against the Firefox version when retrieving records.
//
// The channel filters are used to ship models to only particular channels, for example
// shipping a new language model to only Firefox Nightly before Firefox Beta or Release.
//
// The version filters are used when making major breaking changes that would require particular
// records to only show up in certain versions of Firefox, such as actual code changes that no
// This is used when making major breaking changes that would require particular records
// to only show up in certain versions of Firefox, such as actual code changes that no
// longer allow compatibility with given records.
//
// Some examples might be:
@ -92,18 +84,6 @@ add_task(async function test_filter_current_firefox_version() {
name: `env.version > ${firefoxAlphaZeroVersion}`,
filter_expression: `env.version|versionCompare('${firefoxAlphaZeroVersion}') > 0`,
},
{
name: `channel == ${defaultChannel} && env.version > ${firefoxAlphaZeroVersion}`,
filter_expression: `env.channel == "${defaultChannel}" && env.version|versionCompare('${firefoxAlphaZeroVersion}') > 0`,
},
{
name: `channel == ${releaseChannel} || env.version > ${firefoxAlphaZeroVersion}`,
filter_expression: `env.channel == "${releaseChannel}" || env.version|versionCompare('${firefoxAlphaZeroVersion}') > 0`,
},
{
name: `channel == ${defaultChannel} || env.version < 1`,
filter_expression: `env.channel == "${defaultChannel}" || env.version|versionCompare('1') < 0`,
},
];
for (let record of expectedPresentRecords) {
client.db.create(record);
@ -116,14 +96,6 @@ add_task(async function test_filter_current_firefox_version() {
name: `env.version < 1`,
filter_expression: `env.version|versionCompare('1') < 0`,
},
{
name: `channel == ${releaseChannel} && env.version > ${firefoxAlphaZeroVersion}`,
filter_expression: `env.channel == "${releaseChannel}" && env.version|versionCompare('${firefoxAlphaZeroVersion}') > 0`,
},
{
name: `channel == ${defaultChannel} && env.version < 1`,
filter_expression: `env.channel == "${defaultChannel}" && env.version|versionCompare('1') < 0`,
},
];
for (let record of expectedAbsentRecords) {
client.db.create(record);