/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; /** * This test case tests the case of opening the SelectTranslationsPanel to a valid * language pair from a short selection of text, which should trigger a translation * on panel open. */ add_task( async function test_select_translations_panel_translate_sentence_on_open() { const { cleanup, runInPage, resolveDownloads } = await loadTestPage({ page: SELECT_TEST_PAGE_URL, languagePairs: LANGUAGE_PAIRS, prefs: [["browser.translations.select.enable", true]], }); await SelectTranslationsTestUtils.openPanel(runInPage, { selectFrenchSentence: true, openAtFrenchSentence: true, expectedFromLanguage: "fr", expectedToLanguage: "en", downloadHandler: resolveDownloads, onOpenPanel: SelectTranslationsTestUtils.assertPanelViewTranslated, }); await SelectTranslationsTestUtils.clickDoneButton(); await cleanup(); } ); /** * This test case tests the case of opening the SelectTranslationsPanel to a valid * language pair from hyperlink text, which should trigger a translation on panel open. */ add_task( async function test_select_translations_panel_translate_link_text_on_open() { const { cleanup, runInPage, resolveDownloads } = await loadTestPage({ page: SELECT_TEST_PAGE_URL, languagePairs: LANGUAGE_PAIRS, prefs: [["browser.translations.select.enable", true]], }); await SelectTranslationsTestUtils.openPanel(runInPage, { openAtSpanishHyperlink: true, expectedFromLanguage: "es", expectedToLanguage: "en", downloadHandler: resolveDownloads, onOpenPanel: SelectTranslationsTestUtils.assertPanelViewTranslated, }); await SelectTranslationsTestUtils.clickDoneButton(); await cleanup(); } ); /** * This test case tests the case of opening the SelectTranslationsPanel to a valid * language pair from a long selection of text, which should trigger a translation * on panel open. */ add_task( async function test_select_translations_panel_translate_long_text_on_open() { const { cleanup, runInPage, resolveDownloads } = await loadTestPage({ page: SELECT_TEST_PAGE_URL, languagePairs: LANGUAGE_PAIRS, prefs: [["browser.translations.select.enable", true]], }); await SelectTranslationsTestUtils.openPanel(runInPage, { selectFrenchSection: true, openAtFrenchSection: true, expectedFromLanguage: "fr", expectedToLanguage: "en", downloadHandler: resolveDownloads, onOpenPanel: SelectTranslationsTestUtils.assertPanelViewTranslated, }); await SelectTranslationsTestUtils.clickDoneButton(); await cleanup(); } );