tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a912e1d7cb4241958b2b9b44689b7693beebc6b8
parent 2d981f7a96ab01ece0481b996cade7e2038d265c
Author: Erik Nordin <enordin@mozilla.com>
Date:   Fri,  3 Oct 2025 19:26:49 +0000

Bug 1991761 - Pass architecture arg to Translations e2e tests r=translations-reviewers,gregtatum

This patch updates the Translations end-to-end test arguments
to take an argument for the model architecture to test.

This is a partial patch that will not work as written,
but will work with the subsequent changes in the stack.

Differential Revision: https://phabricator.services.mozilla.com/D266892

Diffstat:
Mbrowser/components/translations/tests/browser/browser_translations_e2e_full_page_translate_with_lexical_shortlist.js | 2++
Mbrowser/components/translations/tests/browser/browser_translations_e2e_full_page_translate_without_lexical_shortlist.js | 2++
Mbrowser/components/translations/tests/browser/head.js | 10++++++++++
Mtoolkit/components/translations/tests/browser/shared-head.js | 11+++++++----
4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/browser/components/translations/tests/browser/browser_translations_e2e_full_page_translate_with_lexical_shortlist.js b/browser/components/translations/tests/browser/browser_translations_e2e_full_page_translate_with_lexical_shortlist.js @@ -12,6 +12,7 @@ add_task( async function test_lazy_full_page_translate_end_to_end_with_lexical_shortlist() { const { cleanup, runInPage } = await loadTestPage({ endToEndTest: true, + architecture: "tiny", page: SPANISH_PAGE_URL, languagePairs: LANGUAGE_PAIRS, prefs: [["browser.translations.useLexicalShortlist", true]], @@ -53,6 +54,7 @@ add_task( async function test_content_eager_full_page_translate_end_to_end_with_lexical_shortlist() { const { cleanup, runInPage } = await loadTestPage({ endToEndTest: true, + architecture: "tiny", page: SPANISH_PAGE_URL, languagePairs: LANGUAGE_PAIRS, contentEagerMode: true, diff --git a/browser/components/translations/tests/browser/browser_translations_e2e_full_page_translate_without_lexical_shortlist.js b/browser/components/translations/tests/browser/browser_translations_e2e_full_page_translate_without_lexical_shortlist.js @@ -12,6 +12,7 @@ add_task( async function test_lazy_full_page_translate_end_to_end_with_lexical_shortlist() { const { cleanup, runInPage } = await loadTestPage({ endToEndTest: true, + architecture: "tiny", page: SPANISH_PAGE_URL, languagePairs: LANGUAGE_PAIRS, prefs: [["browser.translations.useLexicalShortlist", false]], @@ -53,6 +54,7 @@ add_task( async function test_content_eager_full_page_translate_end_to_end_with_lexical_shortlist() { const { cleanup, runInPage } = await loadTestPage({ endToEndTest: true, + architecture: "tiny", page: SPANISH_PAGE_URL, languagePairs: LANGUAGE_PAIRS, contentEagerMode: true, diff --git a/browser/components/translations/tests/browser/head.js b/browser/components/translations/tests/browser/head.js @@ -683,6 +683,7 @@ class TranslationsBencher { * @param {string} options.page - The URL of the page to test. * @param {string} options.sourceLanguage - The BCP-47 language tag for the source language. * @param {string} options.targetLanguage - The BCP-47 language tag for the target language. + * @param {("tiny"|"base-memory"|"base")} options.architecture - The architecture of the model. * @param {number} options.speedBenchCount - The number of speed-sampling runs to perform. * @param {number} options.memoryBenchCount - The number of memory-sampling runs to perform. * @param {number} [options.memorySampleInterval] - The interval in milliseconds between memory usage samples. @@ -693,6 +694,7 @@ class TranslationsBencher { page, sourceLanguage, targetLanguage, + architecture, speedBenchCount, memoryBenchCount, memorySampleInterval = 10, @@ -743,6 +745,7 @@ class TranslationsBencher { journal, sourceLanguage, targetLanguage, + architecture, memoryBenchCount, memorySampleInterval, }); @@ -752,6 +755,7 @@ class TranslationsBencher { journal, sourceLanguage, targetLanguage, + architecture, wordCount, tokenCount, speedBenchCount, @@ -769,6 +773,7 @@ class TranslationsBencher { * @param {TranslationsBencher.Journal} options.journal - The shared metrics journal. * @param {string} options.sourceLanguage - The BCP-47 language tag for the source language. * @param {string} options.targetLanguage - The BCP-47 language tag for the target language. + * @param {("tiny"|"base-memory"|"base")} options.architecture - The architecture of the model. * @param {number} options.memoryBenchCount - The number of runs to perform for memory sampling. * @param {number} options.memorySampleInterval - The interval in milliseconds between memory samples. * @@ -779,6 +784,7 @@ class TranslationsBencher { journal, sourceLanguage, targetLanguage, + architecture, memoryBenchCount, memorySampleInterval, }) { @@ -790,6 +796,7 @@ class TranslationsBencher { { fromLang: sourceLanguage, toLang: "en" }, { fromLang: "en", toLang: targetLanguage }, ], + architecture, prefs: [["browser.translations.logLevel", "Error"]], contentEagerMode: true, }); @@ -894,6 +901,7 @@ class TranslationsBencher { * @param {TranslationsBencher.Journal} options.journal - The shared metrics journal. * @param {string} options.sourceLanguage - The BCP-47 language tag for the source language. * @param {string} options.targetLanguage - The BCP-47 language tag for the target language. + * @param {("tiny"|"base-memory"|"base")} options.architecture - The architecture of the model. * @param {number} options.wordCount - The total word count of the page. * @param {number} options.tokenCount - The total token count of the page. * @param {number} options.speedBenchCount - The number of runs to perform for speed sampling. @@ -905,6 +913,7 @@ class TranslationsBencher { journal, sourceLanguage, targetLanguage, + architecture, wordCount, tokenCount, speedBenchCount, @@ -917,6 +926,7 @@ class TranslationsBencher { { fromLang: sourceLanguage, toLang: "en" }, { fromLang: "en", toLang: targetLanguage }, ], + architecture, prefs: [["browser.translations.logLevel", "Error"]], contentEagerMode: true, }); diff --git a/toolkit/components/translations/tests/browser/shared-head.js b/toolkit/components/translations/tests/browser/shared-head.js @@ -1220,7 +1220,7 @@ async function pathExists(path) { * * @returns {Promise<object>} - An object containing the removeMocks function and remoteClients. */ -async function createFileSystemRemoteSettings(languagePairs) { +async function createFileSystemRemoteSettings(languagePairs, architecture) { const { removeMocks, remoteClients } = await createAndMockRemoteSettings({ languagePairs, useMockedTranslator: false, @@ -1255,12 +1255,14 @@ async function createFileSystemRemoteSettings(languagePairs) { const download = async record => { const recordPath = normalizePathForOS( - `${artifactDirectory}/${record.name}.zst` + record.name === "bergamot-translator" + ? `${artifactDirectory}/${record.name}.zst` + : `${artifactDirectory}/${architecture}.${record.name}.zst` ); if (!(await pathExists(recordPath))) { throw new Error(` - The record ${record.name} was not found in ${artifactDirectory} specified by MOZ_FETCHES_DIR. + The record ${record.name} was not found in ${artifactDirectory} specified by MOZ_FETCHES_DIR at the expected path: ${recordPath} If you are running a Translations end-to-end test locally, you will need to download the required artifacts to MOZ_FETCHES_DIR. To configure MOZ_FETCHES_DIR to run Translations end-to-end tests locally, please run toolkit/components/translations/tests/scripts/download-translations-artifacts.py `); @@ -1390,6 +1392,7 @@ async function loadTestPage({ systemLocales = ["en"], appLocales, webLanguages, + architecture, contentEagerMode = false, win = window, }) { @@ -1444,7 +1447,7 @@ async function loadTestPage({ ); const result = endToEndTest - ? await createFileSystemRemoteSettings(languagePairs) + ? await createFileSystemRemoteSettings(languagePairs, architecture) : await createAndMockRemoteSettings({ languagePairs, autoDownloadFromRemoteSettings,