52 Cc[
"@mozilla.org/moz/jssubscript-loader;1"].
53 getService(Components.interfaces.mozIJSSubScriptLoader).
54 loadSubScript(
"chrome://mochikit/content/MochiKit/packed.js");
56 Cc[
"@mozilla.org/moz/jssubscript-loader;1"].
57 getService(Components.interfaces.mozIJSSubScriptLoader).
58 loadSubScript(
"chrome://browser/content/sanitize.js");
60 const winWatch =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
62 const dm =
Cc[
"@mozilla.org/download-manager;1"].
64 const bhist =
Cc[
"@mozilla.org/browser/global-history;2"].
66 const formhist =
Cc[
"@mozilla.org/satchel/form-history;1"].
78 for (let
i = 0;
i < 30;
i++) {
85 wh.selectDuration(
Sanitizer.TIMESPAN_HOUR);
86 wh.checkGrippy(
"Grippy should be at last row after selecting HOUR " +
88 wh.getRowCount() - 1);
91 let row = wh.getGrippyRow();
95 wh.checkGrippy(
"Grippy should be moved up one row", row);
98 wh.checkGrippy(
"Grippy should remain at first row after trying to move " +
101 while (row !== wh.getRowCount() - 1) {
104 wh.checkGrippy(
"Grippy should be moved down one row", row);
107 wh.checkGrippy(
"Grippy should remain at last row after trying to move " +
109 wh.getRowCount() - 1);
112 wh.checkPrefCheckbox(
"history",
false);
130 for (let
i = 0;
i < 30;
i++) {
133 let downloadIDs = [];
134 for (let
i = 0;
i < 5;
i++) {
139 for (let
i = 0;
i < 5;
i++) {
142 let olderDownloadIDs = [];
143 for (let
i = 0;
i < 5;
i++) {
146 let totalHistoryVisits = uris.length + olderURIs.length;
151 wh.selectDuration(
Sanitizer.TIMESPAN_HOUR);
152 wh.checkGrippy(
"Grippy should be at proper row after selecting HOUR " +
158 wh.checkPrefCheckbox(
"history",
true);
181 for (let
i = 0;
i < 5;
i++) {
184 let downloadIDs = [];
185 for (let
i = 0;
i < 5;
i++) {
188 let formEntries = [];
189 for (let
i = 0;
i < 5;
i++) {
196 wh.selectDuration(
Sanitizer.TIMESPAN_HOUR);
197 wh.checkGrippy(
"Grippy should be at last row after selecting HOUR " +
199 wh.getRowCount() - 1);
202 wh.checkPrefCheckbox(
"history",
false);
203 wh.checkPrefCheckbox(
"formdata",
true);
232 wh.selectDuration(
Sanitizer.TIMESPAN_EVERYTHING);
233 wh.checkPrefCheckbox(
"history",
true);
272 acceptDialog:
function () {
273 is(this.
win.document.documentElement.getButton(
"accept").disabled,
false,
274 "Dialog's OK button should not be disabled");
275 this.
win.document.documentElement.acceptDialog();
281 cancelDialog:
function () {
282 this.
win.document.documentElement.cancelDialog();
294 checkGrippy:
function (aMsg, aExpectedRow) {
295 is(this.getGrippyRow(), aExpectedRow, aMsg);
296 this.checkTreeSelection();
297 this.ensureGrippyIsVisible();
309 checkPrefCheckbox:
function (aPrefName, aCheckState) {
310 var
pref =
"privacy.cpd." + aPrefName;
311 var cb = this.
win.document.querySelectorAll(
312 "#itemList > [preference='" + pref +
"']");
313 is(cb.length, 1,
"found checkbox for " + pref +
" preference");
314 if (cb[0].checked != aCheckState)
323 checkTreeSelection:
function () {
324 let grippyRow = this.getGrippyRow();
325 let sel = this.getTree().view.selection;
326 if (grippyRow === 0) {
327 is(sel.getRangeCount(), 0,
328 "Grippy row is 0, so no tree selection should exist");
331 is(sel.getRangeCount(), 1,
332 "Grippy row > 0, so only one tree selection range should exist");
335 sel.getRangeAt(0, min, max);
336 is(min.value, 0,
"Tree selection should start at first row");
337 is(max.value, grippyRow - 1,
338 "Tree selection should end at row before grippy");
346 ensureGrippyIsVisible:
function () {
347 let tbo = this.getTree().treeBoxObject;
348 let firstVis = tbo.getFirstVisibleRow();
349 let lastVis = tbo.getLastVisibleRow();
350 let grippyRow = this.getGrippyRow();
351 ok(firstVis <= grippyRow && grippyRow <= lastVis,
352 "Grippy row should be visible; this inequality should be true: " +
353 firstVis +
" <= " + grippyRow +
" <= " + lastVis);
359 getDurationDropdown:
function () {
360 return this.
win.document.getElementById(
"sanitizeDurationChoice");
366 getGrippyRow:
function () {
367 return this.
win.gContiguousSelectionTreeHelper.getGrippyRow();
373 getRowCount:
function () {
374 return this.getTree().view.rowCount;
380 getTree:
function () {
381 return this.
win.gContiguousSelectionTreeHelper.tree;
388 isWarningPanelVisible:
function () {
389 return this.
win.document.getElementById(
"durationDeck").selectedIndex == 1;
395 isTreeVisible:
function () {
396 return this.
win.document.getElementById(
"durationDeck").selectedIndex == 0;
406 moveGrippyBy:
function (aDelta) {
409 let
key = aDelta < 0 ?
"UP" :
"DOWN";
410 let abs = Math.abs(aDelta);
411 let treechildren = this.getTree().treeBoxObject.treeBody;
412 for (let
i = 0;
i < abs;
i++) {
413 EventUtils.sendKey(key, treechildren);
423 selectDuration:
function (aDurVal) {
424 this.getDurationDropdown().value = aDurVal;
425 if (aDurVal ===
Sanitizer.TIMESPAN_EVERYTHING) {
426 is(this.isTreeVisible(),
false,
427 "Tree should not be visible for TIMESPAN_EVERYTHING");
428 is(this.isWarningPanelVisible(),
true,
429 "Warning panel should be visible for TIMESPAN_EVERYTHING");
432 is(this.isTreeVisible(),
true,
433 "Tree should be visible for non-TIMESPAN_EVERYTHING");
434 is(this.isWarningPanelVisible(),
false,
435 "Warning panel should not be visible for non-TIMESPAN_EVERYTHING");
447 let
name =
"fakefile-" + aMinutesAgo +
"-minutes-ago";
451 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
453 startTime: now_uSec - (aMinutesAgo * 60 * 1000000),
454 endTime: now_uSec - ((aMinutesAgo + 1) *60 * 1000000),
455 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
456 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
459 let db =
dm.DBConnection;
460 let stmt = db.createStatement(
461 "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " +
462 "state, currBytes, maxBytes, preferredAction, autoResume) " +
463 "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " +
464 ":currBytes, :maxBytes, :preferredAction, :autoResume)");
466 for (let prop in data) {
467 stmt.params[prop] = data[prop];
476 "Sanity check: download " + gDownloadId +
477 " should exist after creating it");
479 return gDownloadId++;
489 let
name = aMinutesAgo +
"-minutes-ago";
494 let timestamp = now_uSec - (aMinutesAgo * 60 * 1000000);
495 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
496 timestamp +
" WHERE fieldname = '" + name +
"'");
499 "Sanity check: form entry " + name +
" should exist after creating it");
510 let pURI =
makeURI(
"http://" + aMinutesAgo +
"-minutes-ago.com/");
511 bhist.addPageWithDetails(pURI,
512 aMinutesAgo +
" minutes ago",
513 now_uSec - (aMinutesAgo * 60 * 1000 * 1000));
514 is(
bhist.isVisited(pURI),
true,
515 "Sanity check: history visit " + pURI.spec +
516 " should exist after creating it");
524 bhist.removeAllPages();
538 let db =
dm.DBConnection;
539 let stmt = db.createStatement(
541 "FROM moz_downloads " +
544 stmt.params.id = aID;
545 let rows = stmt.step();
575 let niceStr = aShouldBeCleared ?
"no longer" :
"still";
576 aDownloadIDs.forEach(
function (
id) {
578 "download " +
id +
" should " + niceStr +
" exist");
591 let niceStr = aShouldBeCleared ?
"no longer" :
"still";
592 aFormEntries.forEach(
function (
entry) {
594 "form entry " +
entry +
" should " + niceStr +
" exist");
607 let niceStr = aShouldBeCleared ?
"no longer" :
"still";
608 aURIs.forEach(
function (aURI) {
609 is(
bhist.isVisited(aURI), !aShouldBeCleared,
610 "history visit " + aURI.spec +
" should " + niceStr +
" exist");
623 if (aTopic ===
"domwindowopened") {
624 winWatch.unregisterNotification(
this);
625 let
win = aSubject.QueryInterface(
Ci.nsIDOMWindow);
626 win.addEventListener(
"load",
function onload(
event) {
627 win.removeEventListener(
"load",
onload,
false);
628 executeSoon(
function () {
632 aOnloadCallback(win);
637 ok(
false,
"Unexpected exception: " + exc +
"\n" + exc.stack);
645 winWatch.registerNotification(windowObserver);
647 "chrome://browser/content/sanitize.xul",
649 "chrome,titlebar,dialog,centerscreen,modal",
function addFormEntryWithMinutesAgo(aMinutesAgo)
Cc["@mozilla.org/moz/jssubscript-loader;1"] getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript("chrome const winWatch
function downloadExists(aID)
getService(Ci.sbIFaceplateManager)
function addHistoryWithMinutesAgo(aMinutesAgo)
function addDownloadWithMinutesAgo(aMinutesAgo)
function makeURI(aURLSpec, aCharset)
function WindowHelper(aWin)
function ensureDownloadsClearedState(aDownloadIDs, aShouldBeCleared)
function ensureFormEntriesClearedState(aFormEntries, aShouldBeCleared)
function openWindow(aOnloadCallback)
function ensureHistoryClearedState(aURIs, aShouldBeCleared)
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe