mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 15:02:11 +00:00
Bug 490030 - privacy.cpd.history should overrule privacy.cpd.downloads in the Clear Recent History dialog. r=johnath
This commit is contained in:
parent
4c03f490b2
commit
e5d622ec29
@ -89,7 +89,7 @@
|
||||
<preference id="privacy.cpd.history" name="privacy.cpd.history" type="bool"/>
|
||||
<preference id="privacy.cpd.formdata" name="privacy.cpd.formdata" type="bool"/>
|
||||
<preference id="privacy.cpd.passwords" name="privacy.cpd.passwords" type="bool"/>
|
||||
<preference id="privacy.cpd.downloads" name="privacy.cpd.downloads" type="bool"/>
|
||||
<preference id="privacy.cpd.downloads" name="privacy.cpd.downloads" type="bool" disabled="true"/>
|
||||
<preference id="privacy.cpd.cookies" name="privacy.cpd.cookies" type="bool"/>
|
||||
<preference id="privacy.cpd.cache" name="privacy.cpd.cache" type="bool"/>
|
||||
<preference id="privacy.cpd.offlineApps" name="privacy.cpd.offlineApps" type="bool"/>
|
||||
@ -174,11 +174,11 @@
|
||||
control="detailsExpander"/>
|
||||
</hbox>
|
||||
<listbox id="itemList" rows="4" collapsed="true">
|
||||
<listitem id="history-downloads-checkbox"
|
||||
label="&itemHistoryAndDownloads.label;"
|
||||
<listitem label="&itemHistoryAndDownloads.label;"
|
||||
type="checkbox"
|
||||
accesskey="&itemHistoryAndDownloads.accesskey;"
|
||||
oncommand="gSanitizePromptDialog.onReadGeneric();"/>
|
||||
preference="privacy.cpd.history"
|
||||
onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/>
|
||||
<listitem label="&itemFormSearchHistory.label;"
|
||||
type="checkbox"
|
||||
accesskey="&itemFormSearchHistory.accesskey;"
|
||||
@ -207,17 +207,5 @@
|
||||
onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/>
|
||||
</listbox>
|
||||
|
||||
<!-- The separate history and downloads prefs are subsumed by the combined
|
||||
history-downloads checkbox, but by hiding them here we can take
|
||||
advantage of the onsyncfrompreference events. -->
|
||||
<checkbox id="history-checkbox"
|
||||
preference="privacy.cpd.history"
|
||||
onsyncfrompreference="return gSanitizePromptDialog.onReadHistoryOrDownloads();"
|
||||
hidden="true"/>
|
||||
<checkbox id="downloads-checkbox"
|
||||
preference="privacy.cpd.downloads"
|
||||
onsyncfrompreference="return gSanitizePromptDialog.onReadHistoryOrDownloads();"
|
||||
hidden="true"/>
|
||||
|
||||
</prefpane>
|
||||
</prefwindow>
|
||||
|
@ -199,22 +199,15 @@ var gSanitizePromptDialog = {
|
||||
*/
|
||||
onReadGeneric: function ()
|
||||
{
|
||||
// We don't update the separate history and downloads prefs until
|
||||
// dialogaccept. So we need to handle the checked state of the combined
|
||||
// history-downloads checkbox specially.
|
||||
var combinedCb = document.getElementById("history-downloads-checkbox");
|
||||
var found = combinedCb.checked;
|
||||
var found = false;
|
||||
|
||||
// Find any other pref that's checked and enabled.
|
||||
var i = 0;
|
||||
while (!found && i < this.sanitizePreferences.childNodes.length) {
|
||||
var preference = this.sanitizePreferences.childNodes[i];
|
||||
|
||||
// We took into account history and downloads above; don't do it again.
|
||||
found = !!preference.value &&
|
||||
!preference.disabled &&
|
||||
preference.id !== "privacy.cpd.history" &&
|
||||
preference.id !== "privacy.cpd.downloads";
|
||||
!preference.disabled;
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -225,23 +218,6 @@ var gSanitizePromptDialog = {
|
||||
return undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when the values of the history and downloads preference elements are
|
||||
* synced from the actual prefs. Sets the state of the combined history-
|
||||
* downloads checkbox appropriately.
|
||||
*/
|
||||
onReadHistoryOrDownloads: function ()
|
||||
{
|
||||
// Call the common function that will update the accept button
|
||||
this.onReadGeneric();
|
||||
|
||||
var historyPref = document.getElementById("privacy.cpd.history");
|
||||
var downloadsPref = document.getElementById("privacy.cpd.downloads");
|
||||
var combinedCb = document.getElementById("history-downloads-checkbox");
|
||||
combinedCb.disabled = historyPref.disabled && downloadsPref.disabled;
|
||||
combinedCb.checked = historyPref.value || downloadsPref.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sanitizer.prototype.sanitize() requires the prefs to be up-to-date.
|
||||
* Because the type of this prefwindow is "child" -- and that's needed because
|
||||
@ -255,14 +231,9 @@ var gSanitizePromptDialog = {
|
||||
var tsPref = document.getElementById("privacy.sanitize.timeSpan");
|
||||
Sanitizer.prefs.setIntPref("timeSpan", this.selectedTimespan);
|
||||
|
||||
// First set the values of the separate history and downloads pref
|
||||
// elements based on the combined history-downloads checkbox.
|
||||
var combinedCbChecked =
|
||||
document.getElementById("history-downloads-checkbox").checked;
|
||||
var historyPref = document.getElementById("privacy.cpd.history");
|
||||
historyPref.value = !historyPref.disabled && combinedCbChecked;
|
||||
var downloadsPref = document.getElementById("privacy.cpd.downloads");
|
||||
downloadsPref.value = !downloadsPref.disabled && combinedCbChecked;
|
||||
// Keep the pref for the download history in sync with the history pref.
|
||||
document.getElementById("privacy.cpd.downloads").value =
|
||||
document.getElementById("privacy.cpd.history").value;
|
||||
|
||||
// Now manually set the prefs from their corresponding preference
|
||||
// elements.
|
||||
|
@ -84,7 +84,7 @@ var gAllTests = [
|
||||
let wh = new WindowHelper();
|
||||
wh.onload = function () {
|
||||
this.selectDuration(Sanitizer.TIMESPAN_HOUR);
|
||||
this.checkPrefCheckbox("history-downloads-checkbox", false);
|
||||
this.checkPrefCheckbox("history", false);
|
||||
this.checkDetails();
|
||||
this.toggleDetails();
|
||||
this.checkDetails();
|
||||
@ -125,7 +125,7 @@ var gAllTests = [
|
||||
let wh = new WindowHelper();
|
||||
wh.onload = function () {
|
||||
this.selectDuration(Sanitizer.TIMESPAN_HOUR);
|
||||
this.checkPrefCheckbox("history-downloads-checkbox", true);
|
||||
this.checkPrefCheckbox("history", true);
|
||||
this.acceptDialog();
|
||||
|
||||
intPrefIs("sanitize.timeSpan", Sanitizer.TIMESPAN_HOUR,
|
||||
@ -133,10 +133,10 @@ var gAllTests = [
|
||||
"hour selected");
|
||||
boolPrefIs("cpd.history", true,
|
||||
"history pref should be true after accepting dialog with " +
|
||||
"combined history-downloads checkbox checked");
|
||||
"history checkbox checked");
|
||||
boolPrefIs("cpd.downloads", true,
|
||||
"downloads pref should be true after accepting dialog with " +
|
||||
"combined history-downloads checkbox checked");
|
||||
"history checkbox checked");
|
||||
|
||||
// History visits and downloads within one hour should be cleared.
|
||||
ensureHistoryClearedState(uris, true);
|
||||
@ -180,8 +180,8 @@ var gAllTests = [
|
||||
"with a predefined timespan");
|
||||
this.selectDuration(Sanitizer.TIMESPAN_HOUR);
|
||||
|
||||
// Remove only form entries, leave history and downloads.
|
||||
this.checkPrefCheckbox("history-downloads-checkbox", false);
|
||||
// Remove only form entries, leave history (including downloads).
|
||||
this.checkPrefCheckbox("history", false);
|
||||
this.checkPrefCheckbox("formdata", true);
|
||||
this.acceptDialog();
|
||||
|
||||
@ -190,10 +190,10 @@ var gAllTests = [
|
||||
"hour selected");
|
||||
boolPrefIs("cpd.history", false,
|
||||
"history pref should be false after accepting dialog with " +
|
||||
"combined history-downloads checkbox unchecked");
|
||||
"history checkbox unchecked");
|
||||
boolPrefIs("cpd.downloads", false,
|
||||
"downloads pref should be false after accepting dialog with " +
|
||||
"combined history-downloads checkbox unchecked");
|
||||
"history checkbox unchecked");
|
||||
|
||||
// Of the three only form entries should be cleared.
|
||||
ensureHistoryClearedState(uris, false);
|
||||
@ -225,7 +225,7 @@ var gAllTests = [
|
||||
"Warning panel should be hidden after previously accepting dialog " +
|
||||
"with a predefined timespan");
|
||||
this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
|
||||
this.checkPrefCheckbox("history-downloads-checkbox", true);
|
||||
this.checkPrefCheckbox("history", true);
|
||||
this.checkDetails();
|
||||
this.toggleDetails();
|
||||
this.checkDetails();
|
||||
@ -257,7 +257,7 @@ var gAllTests = [
|
||||
"Warning panel should be visible after previously accepting dialog " +
|
||||
"with clearing everything");
|
||||
this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
|
||||
this.checkPrefCheckbox("history-downloads-checkbox", true);
|
||||
this.checkPrefCheckbox("history", true);
|
||||
this.acceptDialog();
|
||||
|
||||
intPrefIs("sanitize.timeSpan", Sanitizer.TIMESPAN_EVERYTHING,
|
||||
@ -336,22 +336,17 @@ WindowHelper.prototype = {
|
||||
* form history, etc.).
|
||||
*
|
||||
* @param aPrefName
|
||||
* Either the ID of the checkbox or the final portion of its
|
||||
* privacy.cpd.* preference name
|
||||
* The final portion of the checkbox's privacy.cpd.* preference name
|
||||
* @param aCheckState
|
||||
* True if the checkbox should be checked, false otherwise
|
||||
*/
|
||||
checkPrefCheckbox: function (aPrefName, aCheckState) {
|
||||
let checkBoxes = this.win.document.getElementsByTagName("listitem");
|
||||
for (let i = 0; i < checkBoxes.length; i++) {
|
||||
let cb = checkBoxes[i];
|
||||
if (cb.id === aPrefName ||
|
||||
(cb.hasAttribute("preference") &&
|
||||
cb.getAttribute("preference") === "privacy.cpd." + aPrefName)) {
|
||||
cb.checked = aCheckState;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var pref = "privacy.cpd." + aPrefName;
|
||||
var cb = this.win.document.querySelectorAll(
|
||||
"#itemList > [preference='" + pref + "']");
|
||||
is(cb.length, 1, "found checkbox for " + pref + " preference");
|
||||
if (cb[0].checked != aCheckState)
|
||||
cb[0].click();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,7 @@ var gAllTests = [
|
||||
wh.getRowCount() - 1);
|
||||
|
||||
// Cancel the dialog, make sure history visits are not cleared.
|
||||
wh.checkPrefCheckbox("history-downloads-checkbox", false);
|
||||
wh.checkPrefCheckbox("history", false);
|
||||
|
||||
wh.cancelDialog();
|
||||
ensureHistoryClearedState(uris, false);
|
||||
@ -157,7 +157,7 @@ var gAllTests = [
|
||||
|
||||
// Accept the dialog, make sure history visits and downloads within one
|
||||
// hour are cleared.
|
||||
wh.checkPrefCheckbox("history-downloads-checkbox", true);
|
||||
wh.checkPrefCheckbox("history", true);
|
||||
wh.acceptDialog();
|
||||
ensureHistoryClearedState(uris, true);
|
||||
ensureDownloadsClearedState(downloadIDs, true);
|
||||
@ -200,8 +200,8 @@ var gAllTests = [
|
||||
"duration",
|
||||
wh.getRowCount() - 1);
|
||||
|
||||
// Remove only form entries, leave history and downloads.
|
||||
wh.checkPrefCheckbox("history-downloads-checkbox", false);
|
||||
// Remove only form entries, leave history (including downloads).
|
||||
wh.checkPrefCheckbox("history", false);
|
||||
wh.checkPrefCheckbox("formdata", true);
|
||||
wh.acceptDialog();
|
||||
|
||||
@ -232,7 +232,7 @@ var gAllTests = [
|
||||
openWindow(function (aWin) {
|
||||
let wh = new WindowHelper(aWin);
|
||||
wh.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
|
||||
wh.checkPrefCheckbox("history-downloads-checkbox", true);
|
||||
wh.checkPrefCheckbox("history", true);
|
||||
wh.acceptDialog();
|
||||
ensureHistoryClearedState(uris, true);
|
||||
});
|
||||
@ -304,22 +304,17 @@ WindowHelper.prototype = {
|
||||
* form history, etc.).
|
||||
*
|
||||
* @param aPrefName
|
||||
* Either the ID of the checkbox or the final portion of its
|
||||
* privacy.cpd.* preference name
|
||||
* The final portion of the checkbox's privacy.cpd.* preference name
|
||||
* @param aCheckState
|
||||
* True if the checkbox should be checked, false otherwise
|
||||
*/
|
||||
checkPrefCheckbox: function (aPrefName, aCheckState) {
|
||||
let checkBoxes = this.win.document.getElementsByTagName("listitem");
|
||||
for (let i = 0; i < checkBoxes.length; i++) {
|
||||
let cb = checkBoxes[i];
|
||||
if (cb.id === aPrefName ||
|
||||
(cb.hasAttribute("preference") &&
|
||||
cb.getAttribute("preference") === "privacy.cpd." + aPrefName)) {
|
||||
cb.checked = aCheckState;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var pref = "privacy.cpd." + aPrefName;
|
||||
var cb = this.win.document.querySelectorAll(
|
||||
"#itemList > [preference='" + pref + "']");
|
||||
is(cb.length, 1, "found checkbox for " + pref + " preference");
|
||||
if (cb[0].checked != aCheckState)
|
||||
cb[0].click();
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user