53 Cc[
"@mozilla.org/moz/jssubscript-loader;1"].
54 getService(Components.interfaces.mozIJSSubScriptLoader).
55 loadSubScript(
"chrome://mochikit/content/MochiKit/packed.js");
57 Cc[
"@mozilla.org/moz/jssubscript-loader;1"].
58 getService(Components.interfaces.mozIJSSubScriptLoader).
59 loadSubScript(
"chrome://browser/content/sanitize.js");
61 const winWatch =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
63 const dm =
Cc[
"@mozilla.org/download-manager;1"].
65 const bhist =
Cc[
"@mozilla.org/browser/global-history;2"].
67 const formhist =
Cc[
"@mozilla.org/satchel/form-history;1"].
78 wh.onload =
function () {
80 this.selectDuration(
Sanitizer.TIMESPAN_HOUR);
82 if (!this.getItemList().collapsed)
95 for (let
i = 0;
i < 30;
i++) {
100 wh.onload =
function () {
101 this.selectDuration(
Sanitizer.TIMESPAN_HOUR);
102 this.checkPrefCheckbox(
"history",
false);
103 this.checkDetails(
false);
106 this.toggleDetails();
107 this.checkDetails(
true);
110 this.toggleDetails();
111 this.checkDetails(
false);
128 for (let
i = 0;
i < 30;
i++) {
131 let downloadIDs = [];
132 for (let
i = 0;
i < 5;
i++) {
137 for (let
i = 0;
i < 5;
i++) {
140 let olderDownloadIDs = [];
141 for (let
i = 0;
i < 5;
i++) {
144 let totalHistoryVisits = uris.length + olderURIs.length;
147 wh.onload =
function () {
148 this.selectDuration(
Sanitizer.TIMESPAN_HOUR);
149 this.checkPrefCheckbox(
"history",
true);
153 "timeSpan pref should be hour after accepting dialog with " +
156 "history pref should be true after accepting dialog with " +
157 "history checkbox checked");
159 "downloads pref should be true after accepting dialog with " +
160 "history checkbox checked");
185 for (let
i = 0;
i < 5;
i++) {
188 let downloadIDs = [];
189 for (let
i = 0;
i < 5;
i++) {
192 let formEntries = [];
193 for (let
i = 0;
i < 5;
i++) {
198 wh.onload =
function () {
199 is(this.isWarningPanelVisible(),
false,
200 "Warning panel should be hidden after previously accepting dialog " +
201 "with a predefined timespan");
202 this.selectDuration(
Sanitizer.TIMESPAN_HOUR);
205 this.checkPrefCheckbox(
"history",
false);
206 this.checkPrefCheckbox(
"formdata",
true);
210 "timeSpan pref should be hour after accepting dialog with " +
213 "history pref should be false after accepting dialog with " +
214 "history checkbox unchecked");
216 "downloads pref should be false after accepting dialog with " +
217 "history checkbox unchecked");
244 wh.onload =
function () {
245 is(this.isWarningPanelVisible(),
false,
246 "Warning panel should be hidden after previously accepting dialog " +
247 "with a predefined timespan");
248 this.selectDuration(
Sanitizer.TIMESPAN_EVERYTHING);
249 this.checkPrefCheckbox(
"history",
true);
250 this.checkDetails(
true);
253 this.toggleDetails();
254 this.checkDetails(
false);
257 this.toggleDetails();
258 this.checkDetails(
true);
263 "timeSpan pref should be everything after accepting dialog " +
264 "with everything selected");
283 wh.onload =
function () {
284 is(this.isWarningPanelVisible(),
true,
285 "Warning panel should be visible after previously accepting dialog " +
286 "with clearing everything");
287 this.selectDuration(
Sanitizer.TIMESPAN_EVERYTHING);
288 this.checkPrefCheckbox(
"history",
true);
292 "timeSpan pref should be everything after accepting dialog " +
293 "with everything selected");
305 wh.onload =
function () {
307 this.checkAllCheckboxes();
308 this.selectDuration(
Sanitizer.TIMESPAN_EVERYTHING);
311 this.toggleDetails();
312 this.checkDetails(
false);
319 wh.onload =
function () {
321 this.checkDetails(
false);
324 this.checkPrefCheckbox(
"history",
false);
331 wh.onload =
function () {
333 this.checkDetails(
true);
336 this.checkAllCheckboxes();
337 this.checkPrefCheckbox(
"siteSettings",
false);
344 wh.onload =
function () {
346 this.checkDetails(
true);
349 this.toggleDetails();
350 this.checkDetails(
false);
357 wh.onload =
function () {
359 this.checkDetails(
true);
362 this.selectDuration(
Sanitizer.TIMESPAN_HOUR);
364 this.toggleDetails();
365 this.checkDetails(
false);
372 wh.onload =
function () {
374 this.checkDetails(
false);
382 wh.onload =
function () {
384 this.checkDetails(
false);
387 this.toggleDetails();
388 this.checkDetails(
true);
422 acceptDialog:
function () {
423 is(this.
win.document.documentElement.getButton(
"accept").disabled,
false,
424 "Dialog's OK button should not be disabled");
425 this.
win.document.documentElement.acceptDialog();
431 cancelDialog:
function () {
432 this.
win.document.documentElement.cancelDialog();
443 checkDetails:
function (aShouldBeShown) {
444 let button = this.getDetailsButton();
445 let list = this.getItemList();
446 let
hidden = list.hidden || list.collapsed;
447 is(hidden, !aShouldBeShown,
448 "Details should be " + (aShouldBeShown ?
"shown" :
"hidden") +
449 " but were actually " + (hidden ?
"hidden" :
"shown"));
450 let
dir = hidden ?
"down" :
"up";
451 is(button.className,
"expander-" + dir,
452 "Details button should be " + dir +
" because item list is " +
453 (hidden ?
"" :
"not ") +
"hidden");
456 height += list.boxObject.height;
457 if (this.isWarningPanelVisible())
458 height += this.getWarningPanel().boxObject.height;
459 ok(height < this.
win.innerHeight,
460 "Window should be tall enough to fit warning panel and item list");
472 checkPrefCheckbox:
function (aPrefName, aCheckState) {
473 var
pref =
"privacy.cpd." + aPrefName;
474 var cb = this.
win.document.querySelectorAll(
475 "#itemList > [preference='" + pref +
"']");
476 is(cb.length, 1,
"found checkbox for " + pref +
" preference");
477 if (cb[0].checked != aCheckState)
484 checkAllCheckboxes:
function () {
485 var cb = this.
win.document.querySelectorAll(
"#itemList > [preference]");
486 ok(cb.length > 1,
"found checkboxes for preferences");
487 for (var
i = 0;
i < cb.length; ++
i) {
497 getDetailsButton:
function () {
498 return this.
win.document.getElementById(
"detailsExpander");
504 getDurationDropdown:
function () {
505 return this.
win.document.getElementById(
"sanitizeDurationChoice");
511 getItemList:
function () {
512 return this.
win.document.getElementById(
"itemList");
518 getWarningPanel:
function () {
519 return this.
win.document.getElementById(
"sanitizeEverythingWarningBox");
526 isWarningPanelVisible:
function () {
527 return !this.getWarningPanel().hidden;
541 if (aTopic !==
"domwindowopened")
544 winWatch.unregisterNotification(
this);
547 let
win = aSubject.QueryInterface(
Ci.nsIDOMWindow);
549 win.addEventListener(
"load",
function onload(
event) {
550 win.removeEventListener(
"load",
onload,
false);
552 if (win.name !==
"SanitizeDialog")
558 executeSoon(
function () {
566 ok(
false,
"Unexpected exception: " + exc +
"\n" + exc.stack);
572 win.addEventListener(
"unload",
function onunload(
event) {
573 if (win.name !==
"SanitizeDialog") {
574 win.removeEventListener(
"unload", onunload,
false);
582 win.removeEventListener(
"unload", onunload,
false);
585 executeSoon(
function () {
595 ok(
false,
"Unexpected exception: " + exc +
"\n" + exc.stack);
604 "chrome://browser/content/sanitize.xul",
606 "chrome,titlebar,dialog,centerscreen,modal",
616 selectDuration:
function (aDurVal) {
617 this.getDurationDropdown().value = aDurVal;
618 if (aDurVal ===
Sanitizer.TIMESPAN_EVERYTHING) {
619 is(this.isWarningPanelVisible(),
true,
620 "Warning panel should be visible for TIMESPAN_EVERYTHING");
623 is(this.isWarningPanelVisible(),
false,
624 "Warning panel should not be visible for non-TIMESPAN_EVERYTHING");
631 toggleDetails:
function () {
632 this.getDetailsButton().click();
643 let
name =
"fakefile-" + aMinutesAgo +
"-minutes-ago";
647 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
649 startTime: now_uSec - (aMinutesAgo * 60 * 1000000),
650 endTime: now_uSec - ((aMinutesAgo + 1) *60 * 1000000),
651 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
652 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
655 let db =
dm.DBConnection;
656 let stmt = db.createStatement(
657 "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " +
658 "state, currBytes, maxBytes, preferredAction, autoResume) " +
659 "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " +
660 ":currBytes, :maxBytes, :preferredAction, :autoResume)");
662 for (let prop in data) {
663 stmt.params[prop] = data[prop];
672 "Sanity check: download " + gDownloadId +
673 " should exist after creating it");
675 return gDownloadId++;
685 let
name = aMinutesAgo +
"-minutes-ago";
690 let timestamp = now_uSec - (aMinutesAgo * 60 * 1000000);
691 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
692 timestamp +
" WHERE fieldname = '" + name +
"'");
695 "Sanity check: form entry " + name +
" should exist after creating it");
706 let pURI =
makeURI(
"http://" + aMinutesAgo +
"-minutes-ago.com/");
707 bhist.addPageWithDetails(pURI,
708 aMinutesAgo +
" minutes ago",
709 now_uSec - (aMinutesAgo * 60 * 1000 * 1000));
710 is(
bhist.isVisited(pURI),
true,
711 "Sanity check: history visit " + pURI.spec +
712 " should exist after creating it");
720 bhist.removeAllPages();
736 is(
gPrefService.getBoolPref(
"privacy." + aPrefName), aExpectedVal, aMsg);
748 let db =
dm.DBConnection;
749 let stmt = db.createStatement(
751 "FROM moz_downloads " +
754 stmt.params.id = aID;
755 let rows = stmt.step();
785 let niceStr = aShouldBeCleared ?
"no longer" :
"still";
786 aDownloadIDs.forEach(
function (
id) {
788 "download " +
id +
" should " + niceStr +
" exist");
801 let niceStr = aShouldBeCleared ?
"no longer" :
"still";
802 aFormEntries.forEach(
function (
entry) {
804 "form entry " +
entry +
" should " + niceStr +
" exist");
817 let niceStr = aShouldBeCleared ?
"no longer" :
"still";
818 aURIs.forEach(
function (aURI) {
819 is(
bhist.isVisited(aURI), !aShouldBeCleared,
820 "history visit " + aURI.spec +
" should " + niceStr +
" exist");
835 is(
gPrefService.getIntPref(
"privacy." + aPrefName), aExpectedVal, aMsg);
Cc["@mozilla.org/moz/jssubscript-loader;1"] getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript("chrome const winWatch
function addDownloadWithMinutesAgo(aMinutesAgo)
getService(Ci.sbIFaceplateManager)
function ensureDownloadsClearedState(aDownloadIDs, aShouldBeCleared)
BogusChannel prototype open
function makeURI(aURLSpec, aCharset)
function boolPrefIs(aPrefName, aExpectedVal, aMsg)
function intPrefIs(aPrefName, aExpectedVal, aMsg)
function WindowHelper(aWin)
function downloadExists(aID)
function addFormEntryWithMinutesAgo(aMinutesAgo)
function addHistoryWithMinutesAgo(aMinutesAgo)
return aWindow document documentElement getAttribute(aAttribute)||dimension
function ensureFormEntriesClearedState(aFormEntries, aShouldBeCleared)
_getSelectedPageStyle s i
function ensureHistoryClearedState(aURIs, aShouldBeCleared)
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe