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
|
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.is_hidden(dialogOverlay), "The dialog is visible.");
return win;
}
function acceptLanguagesSubdialog(win) {
const button = win.document.querySelector("dialog").getButton("accept");
button.doCommand();
}
ok(BrowserTestUtils.is_hidden(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.is_hidden(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;
ok(
activeLanguages[0].id == "en-us",
"The ID for 'en-US' locale code is correctly set."
);
ok(
activeLanguages[0].firstChild.value == "English (United States) [en-us]",
"The name for known 'en-US' locale code is correctly resolved."
);
ok(
activeLanguages[1].id == "en-xx",
"The ID for 'en-XX' locale code is correctly set."
);
ok(
activeLanguages[1].firstChild.value == "English [en-xx]",
"The name for unknown 'en-XX' locale code is resolved using 'en'."
);
ok(
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);
gBrowser.removeCurrentTab();
});
|