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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_about_translations_language_directions() {
await openAboutTranslations({
languagePairs: [
// English (en) is LTR and Arabic (ar) is RTL.
{ fromLang: "en", toLang: "ar", isBeta: true },
{ fromLang: "ar", toLang: "en", isBeta: true },
],
runInPage: async ({ selectors }) => {
const { document, window } = content;
Cu.waiveXrays(window).DEBOUNCE_DELAY = 5; // Make the timer run faster for tests.
await ContentTaskUtils.waitForCondition(() => {
return document.body.hasAttribute("ready");
}, "Waiting for the document to be ready.");
/** @type {HTMLSelectElement} */
const fromSelect = document.querySelector(selectors.fromLanguageSelect);
/** @type {HTMLSelectElement} */
const toSelect = document.querySelector(selectors.toLanguageSelect);
/** @type {HTMLTextAreaElement} */
const translationTextarea = document.querySelector(
selectors.translationTextarea
);
/** @type {HTMLDivElement} */
const translationResult = document.querySelector(
selectors.translationResult
);
fromSelect.value = "en";
fromSelect.dispatchEvent(new Event("input"));
toSelect.value = "ar";
toSelect.dispatchEvent(new Event("input"));
translationTextarea.value = "This text starts as LTR.";
translationTextarea.dispatchEvent(new Event("input"));
is(
window.getComputedStyle(translationTextarea).direction,
"ltr",
"The English input is LTR"
);
is(
window.getComputedStyle(translationResult).direction,
"rtl",
"The Arabic results are RTL"
);
toSelect.value = "";
toSelect.dispatchEvent(new Event("input"));
fromSelect.value = "ar";
fromSelect.dispatchEvent(new Event("input"));
toSelect.value = "en";
toSelect.dispatchEvent(new Event("input"));
translationTextarea.value = "This text starts as RTL.";
translationTextarea.dispatchEvent(new Event("input"));
is(
window.getComputedStyle(translationTextarea).direction,
"rtl",
"The Arabic input is RTL"
);
is(
window.getComputedStyle(translationResult).direction,
"ltr",
"The English results are LTR"
);
},
});
});
|