1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* This test case verifies the functionality of the translate-selection context menu item
* when the selected text is not in the user's preferred language. The menu item should be
* localized to translate to the target language matching the user's top preferred language
* when the selected text is detected to be in a different language.
*/
add_task(
async function test_translate_selection_menuitem_when_selected_text_is_not_preferred_language() {
const { cleanup, runInPage } = await loadTestPage({
page: SPANISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.select.enable", true]],
});
await FullPageTranslationsTestUtils.assertTranslationsButton(
{ button: true, circleArrows: false, locale: false, icon: true },
"The button is available."
);
await FullPageTranslationsTestUtils.assertPageIsUntranslated(runInPage);
await SelectTranslationsTestUtils.assertContextMenuTranslateSelectionItem(
runInPage,
{
selectSpanishParagraph: true,
openAtSpanishParagraph: true,
expectMenuItemVisible: true,
expectedTargetLanguage: "en",
},
"The translate-selection context menu item should display a target language " +
"when the selected text is not the preferred language."
);
await cleanup();
}
);
/**
* This test case verifies the functionality of the translate-selection context menu item
* when the selected text is detected to be in the user's preferred language. The menu item
* should not be localized to display a target language when the selected text matches the
* user's top preferred language.
*/
add_task(
async function test_translate_selection_menuitem_when_selected_text_is_preferred_language() {
const { cleanup, runInPage } = await loadTestPage({
page: ENGLISH_PAGE_URL,
languagePairs: LANGUAGE_PAIRS,
prefs: [["browser.translations.select.enable", true]],
});
await FullPageTranslationsTestUtils.assertTranslationsButton(
{ button: false },
"The button is available."
);
await SelectTranslationsTestUtils.assertContextMenuTranslateSelectionItem(
runInPage,
{
selectFirstParagraph: true,
openAtFirstParagraph: true,
expectMenuItemVisible: true,
expectedTargetLanguage: null,
},
"The translate-selection context menu item should not display a target language " +
"when the selected text is in the preferred language."
);
await cleanup();
}
);
|