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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
add_task(async function () {
await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
const contentDocument = gBrowser.contentDocument;
let dialogOverlay = content.gSubDialog._preloadDialog._overlay;
async function languagesSubdialogOpened() {
const promiseSubDialogLoaded = promiseLoadSubDialog(
"chrome://browser/content/preferences/dialogs/languages.xhtml"
);
contentDocument.getElementById("chooseLanguage").click();
const win = await promiseSubDialogLoaded;
dialogOverlay = content.gSubDialog._topDialog._overlay;
ok(!BrowserTestUtils.isHidden(dialogOverlay), "The dialog is visible.");
return win;
}
function acceptLanguagesSubdialog(win) {
const button = win.document.querySelector("dialog").getButton("accept");
button.doCommand();
}
ok(BrowserTestUtils.isHidden(dialogOverlay), "The dialog is invisible.");
let win = await languagesSubdialogOpened();
ok(
win.document.getElementById("spoofEnglish").hidden,
"The 'Request English' checkbox is hidden."
);
acceptLanguagesSubdialog(win);
ok(BrowserTestUtils.isHidden(dialogOverlay), "The dialog is invisible.");
await SpecialPowers.pushPrefEnv({
set: [["intl.accept_languages", "en-US,en-XX,foo"]],
});
win = await languagesSubdialogOpened();
let activeLanguages = win.document.getElementById("activeLanguages").children;
Assert.equal(
activeLanguages[0].id,
"en-us",
"The ID for 'en-US' locale code is correctly set."
);
Assert.equal(
activeLanguages[0].firstChild.value,
"English (United States) [en-us]",
"The name for known 'en-US' locale code is correctly resolved."
);
Assert.equal(
activeLanguages[1].id,
"en-xx",
"The ID for 'en-XX' locale code is correctly set."
);
Assert.equal(
activeLanguages[1].firstChild.value,
"English [en-xx]",
"The name for unknown 'en-XX' locale code is resolved using 'en'."
);
Assert.equal(
activeLanguages[2].firstChild.value,
" [foo]",
"The name for unknown 'foo' locale code is empty."
);
acceptLanguagesSubdialog(win);
await SpecialPowers.popPrefEnv();
await SpecialPowers.pushPrefEnv({
set: [
["privacy.resistFingerprinting", true],
["privacy.spoof_english", 0],
],
});
win = await languagesSubdialogOpened();
ok(
!win.document.getElementById("spoofEnglish").hidden,
"The 'Request English' checkbox isn't hidden."
);
ok(
!win.document.getElementById("spoofEnglish").checked,
"The 'Request English' checkbox isn't checked."
);
is(
win.Preferences.get("privacy.spoof_english").value,
0,
"The privacy.spoof_english pref is set to 0."
);
win.document.getElementById("spoofEnglish").checked = true;
win.document.getElementById("spoofEnglish").doCommand();
ok(
win.document.getElementById("spoofEnglish").checked,
"The 'Request English' checkbox is checked."
);
is(
win.Preferences.get("privacy.spoof_english").value,
2,
"The privacy.spoof_english pref is set to 2."
);
acceptLanguagesSubdialog(win);
win = await languagesSubdialogOpened();
ok(
!win.document.getElementById("spoofEnglish").hidden,
"The 'Request English' checkbox isn't hidden."
);
ok(
win.document.getElementById("spoofEnglish").checked,
"The 'Request English' checkbox is checked."
);
is(
win.Preferences.get("privacy.spoof_english").value,
2,
"The privacy.spoof_english pref is set to 2."
);
win.document.getElementById("spoofEnglish").checked = false;
win.document.getElementById("spoofEnglish").doCommand();
ok(
!win.document.getElementById("spoofEnglish").checked,
"The 'Request English' checkbox isn't checked."
);
is(
win.Preferences.get("privacy.spoof_english").value,
1,
"The privacy.spoof_english pref is set to 1."
);
acceptLanguagesSubdialog(win);
win = await languagesSubdialogOpened();
ok(
!win.document.getElementById("spoofEnglish").hidden,
"The 'Request English' checkbox isn't hidden."
);
ok(
!win.document.getElementById("spoofEnglish").checked,
"The 'Request English' checkbox isn't checked."
);
is(
win.Preferences.get("privacy.spoof_english").value,
1,
"The privacy.spoof_english pref is set to 1."
);
acceptLanguagesSubdialog(win);
await SpecialPowers.popPrefEnv();
await SpecialPowers.pushPrefEnv({
set: [["intl.accept_languages", "en-US"]],
});
win = await languagesSubdialogOpened();
is(
win.document.getElementById("remove").disabled,
false,
"The Remove button is enabled when any language is selected on the list"
);
win.document.getElementById("remove").doCommand();
is(
win.Preferences.get("intl.accept_languages").value,
"",
"Accepted language has been removed from the preference"
);
is(
win.document.getElementById("activeLanguages").itemCount,
0,
"Accepted languages list is empty"
);
ok(
win.document.getElementById("remove").disabled,
"The Remove button is disabled when there is no language on the list"
);
acceptLanguagesSubdialog(win);
gBrowser.removeCurrentTab();
});
|