1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
5 * With no custom cleaning categories set and sanitizeOnShutdown disabled,
6 * the checkboxes "alwaysClear" and "deleteOnClose" should share the same state.
7 * The state of the cleaning categories cookiesAndStorage and cache should be in the state of the "deleteOnClose" box.
9 add_setup(async function () {
10 await SpecialPowers.pushPrefEnv({
12 ["privacy.clearOnShutdown.cookies", true],
13 ["privacy.sanitize.useOldClearHistoryDialog", false],
18 add_task(async function test_syncWithoutCustomPrefs() {
19 await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
23 let document = gBrowser.contentDocument;
24 let deleteOnCloseBox = document.getElementById("deleteOnClose");
25 let alwaysClearBox = document.getElementById("alwaysClear");
27 ok(!deleteOnCloseBox.checked, "DeleteOnClose initial state is deselected");
28 ok(!alwaysClearBox.checked, "AlwaysClear initial state is deselected");
30 deleteOnCloseBox.click();
32 ok(deleteOnCloseBox.checked, "DeleteOnClose is selected");
34 deleteOnCloseBox.checked,
35 alwaysClearBox.checked,
36 "DeleteOnClose sets alwaysClear in the same state, selected"
39 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
40 "Cookie cleaning pref is set"
43 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cache"),
44 "Cache cleaning pref is set"
47 Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"),
48 "Old cookie cleaning pref is not changed"
51 !Services.prefs.getBoolPref(
52 "privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
54 "History cleaning pref is not set"
57 !Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.siteSettings"),
58 "Site settings cleaning pref is not set"
61 !Services.prefs.getBoolPref("privacy.clearOnShutdown.siteSettings"),
62 "Old Site settings cleaning pref is not set"
65 deleteOnCloseBox.click();
67 ok(!deleteOnCloseBox.checked, "DeleteOnClose is deselected");
69 deleteOnCloseBox.checked,
70 alwaysClearBox.checked,
71 "DeleteOnclose sets alwaysClear in the same state, deselected"
75 !Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
76 "Cookie cleaning pref is reset"
79 !Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cache"),
80 "Cache cleaning pref is reset"
83 Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies"),
84 "Old cookie cleaning pref is not changed"
87 !Services.prefs.getBoolPref(
88 "privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
90 "History cleaning pref is not set"
93 !Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.siteSettings"),
94 "Site settings cleaning pref is not set"
97 BrowserTestUtils.removeTab(gBrowser.selectedTab);
98 Services.prefs.clearUserPref(
99 "privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
101 Services.prefs.clearUserPref("privacy.clearOnShutdown_v2.siteSettings");
102 Services.prefs.clearUserPref("privacy.clearOnShutdown_v2.cache");
103 Services.prefs.clearUserPref("privacy.clearOnShutdown_v2.cookiesAndStorage");
104 Services.prefs.clearUserPref("privacy.sanitize.sanitizeOnShutdown");
108 * With custom cleaning category already set and SanitizeOnShutdown enabled,
109 * deselecting "deleteOnClose" should not change the state of "alwaysClear".
110 * The state of the cleaning categories cookiesAndStorage and cache should be in the state of the "deleteOnClose" box.
112 add_task(async function test_syncWithCustomPrefs() {
113 await SpecialPowers.pushPrefEnv({
115 ["privacy.clearOnShutdown_v2.historyFormDataAndDownloads", true],
116 ["privacy.clearOnShutdown.history", false],
117 ["privacy.clearOnShutdown_v2.siteSettings", true],
118 ["privacy.sanitize.sanitizeOnShutdown", true],
122 await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
126 let document = gBrowser.contentDocument;
127 let deleteOnCloseBox = document.getElementById("deleteOnClose");
128 let alwaysClearBox = document.getElementById("alwaysClear");
130 ok(deleteOnCloseBox.checked, "DeleteOnClose initial state is selected");
131 ok(alwaysClearBox.checked, "AlwaysClear initial state is selected");
134 deleteOnCloseBox.checked,
135 alwaysClearBox.checked,
136 "AlwaysClear and deleteOnClose are in the same state, selected"
139 Services.prefs.getBoolPref(
140 "privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
142 "History cleaning pref is still set"
145 !Services.prefs.getBoolPref("privacy.clearOnShutdown.history"),
146 "Old history cleaning pref is not changed"
149 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.siteSettings"),
150 "Site settings cleaning pref is still set"
154 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
155 "Cookie cleaning pref is set"
158 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cache"),
159 "Cache cleaning pref is set"
162 deleteOnCloseBox.click();
164 ok(!deleteOnCloseBox.checked, "DeleteOnClose is deselected");
166 !deleteOnCloseBox.checked,
167 alwaysClearBox.checked,
168 "AlwaysClear is not synced with deleteOnClose, only deleteOnClose is deselected"
172 !Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cookiesAndStorage"),
173 "Cookie cleaning pref is reset"
176 !Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.cache"),
177 "Cache cleaning pref is reset"
180 Services.prefs.getBoolPref(
181 "privacy.clearOnShutdown_v2.historyFormDataAndDownloads"
183 "History cleaning pref is still set"
186 Services.prefs.getBoolPref("privacy.clearOnShutdown_v2.siteSettings"),
187 "Site settings cleaning pref is still set"
190 BrowserTestUtils.removeTab(gBrowser.selectedTab);
191 await SpecialPowers.popPrefEnv();
195 * Setting/resetting cleaning prefs for cookies, cache, offline apps
196 * and selecting/deselecting the "alwaysClear" Box, also selects/deselects
197 * the "deleteOnClose" box.
200 add_task(async function test_syncWithCustomPrefs() {
201 await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
205 let document = gBrowser.contentDocument;
206 let deleteOnCloseBox = document.getElementById("deleteOnClose");
207 let alwaysClearBox = document.getElementById("alwaysClear");
209 ok(!deleteOnCloseBox.checked, "DeleteOnClose initial state is deselected");
210 ok(!alwaysClearBox.checked, "AlwaysClear initial state is deselected");
212 await SpecialPowers.pushPrefEnv({
214 ["privacy.clearOnShutdown_v2.cookiesAndStorage", true],
215 ["privacy.clearOnShutdown_v2.cache", true],
216 ["privacy.sanitize.sanitizeOnShutdown", true],
220 ok(alwaysClearBox.checked, "AlwaysClear is selected");
222 deleteOnCloseBox.checked,
223 alwaysClearBox.checked,
224 "AlwaysClear and deleteOnClose are in the same state, selected"
227 alwaysClearBox.click();
229 ok(!alwaysClearBox.checked, "AlwaysClear is deselected");
231 deleteOnCloseBox.checked,
232 alwaysClearBox.checked,
233 "AlwaysClear and deleteOnClose are in the same state, deselected"
236 BrowserTestUtils.removeTab(gBrowser.selectedTab);
237 await SpecialPowers.popPrefEnv();
241 * On loading the page, the ClearOnClose box should be set according to the pref selection
243 add_task(async function test_initialState() {
244 await SpecialPowers.pushPrefEnv({
246 ["privacy.clearOnShutdown_v2.cookiesAndStorage", true],
247 ["privacy.clearOnShutdown_v2.cache", true],
248 ["privacy.sanitize.sanitizeOnShutdown", true],
252 await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
256 let document = gBrowser.contentDocument;
257 let deleteOnCloseBox = document.getElementById("deleteOnClose");
260 deleteOnCloseBox.checked,
261 "DeleteOnClose is set accordingly to the prefs, selected"
264 BrowserTestUtils.removeTab(gBrowser.selectedTab);
266 await SpecialPowers.pushPrefEnv({
268 ["privacy.clearOnShutdown_v2.cookiesAndStorage", false],
269 ["privacy.clearOnShutdown_v2.cache", false],
270 ["privacy.sanitize.sanitizeOnShutdown", true],
271 ["privacy.clearOnShutdown_v2.historyFormDataAndDownloads", true],
275 await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
279 document = gBrowser.contentDocument;
280 deleteOnCloseBox = document.getElementById("deleteOnClose");
283 !deleteOnCloseBox.checked,
284 "DeleteOnClose is set accordingly to the prefs, deselected"
287 BrowserTestUtils.removeTab(gBrowser.selectedTab);
289 // When private browsing mode autostart is selected, the deleteOnClose Box is selected always
290 await SpecialPowers.pushPrefEnv({
292 ["privacy.clearOnShutdown_v2.cookiesAndStorage", false],
293 ["privacy.clearOnShutdown_v2.cache", false],
294 ["privacy.sanitize.sanitizeOnShutdown", false],
295 ["browser.privatebrowsing.autostart", true],
299 await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
303 document = gBrowser.contentDocument;
304 deleteOnCloseBox = document.getElementById("deleteOnClose");
307 deleteOnCloseBox.checked,
308 "DeleteOnClose is set accordingly to the private Browsing autostart pref, selected"
311 // Reset history mode
312 let historyMode = document.getElementById("historyMode");
313 historyMode.value = "remember";
314 historyMode.doCommand();
315 BrowserTestUtils.removeTab(gBrowser.selectedTab);
316 await SpecialPowers.popPrefEnv();