B2G/gecko/browser/base/content/test/browser_sanitizeDialog_treeView.js
/**
 * Adds a download to history.
 *
 * @param aMinutesAgo
 *        The download will be downloaded this many minutes ago
 */
Adds a download to history.
@param aMinutesAgo
The download will be downloaded this many minutes ago
Adds a download to history . @param aMinutesAgo The download will be downloaded this many minutes ago
function addDownloadWithMinutesAgo(aMinutesAgo) {
  let name = "fakefile-" + aMinutesAgo + "-minutes-ago";
  let data = {
    id:        gDownloadId,
    name:      name,
    source:   "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
    target:    name,
    startTime: now_uSec - (aMinutesAgo * 60 * 1000000),
    endTime:   now_uSec - ((aMinutesAgo + 1) *60 * 1000000),
    state:     Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
  };
  let db = dm.DBConnection;
  let stmt = db.createStatement(
    "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " +
      "state, currBytes, maxBytes, preferredAction, autoResume) " +
    "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " +
      ":currBytes, :maxBytes, :preferredAction, :autoResume)");
  try {
    for (let prop in data) {
      stmt.params[prop] = data[prop];
    }
    stmt.execute();
  }
  finally {
    stmt.reset();
  }
  is(downloadExists(gDownloadId), true,
     "Sanity check: download " + gDownloadId +
     " should exist after creating it");
  return gDownloadId++;
}
function addDownloadWithMinutesAgo ( aMinutesAgo ) { let name = "fakefile-" + aMinutesAgo + "-minutes-ago" ; let data = { id : gDownloadId , name : name , source : "https://bugzilla.mozilla.org/show_bug.cgi?id=480169" , target : name , startTime : now_uSec - ( aMinutesAgo * 60 * 1000000 ) , endTime : now_uSec - ( ( aMinutesAgo + 1 ) * 60 * 1000000 ) , state : Ci . nsIDownloadManager . DOWNLOAD_FINISHED , currBytes : 0 , maxBytes : - 1 , preferredAction : 0 , autoResume : 0 } ; let db = dm . DBConnection ; let stmt = db . createStatement ( "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " + "state, currBytes, maxBytes, preferredAction, autoResume) " + "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " + ":currBytes, :maxBytes, :preferredAction, :autoResume)" ) ; try { for ( let prop in data ) { stmt . params [ prop ] = data [ prop ] ; } stmt . execute ( ) ; } finally { stmt . reset ( ) ; } is ( downloadExists ( gDownloadId ) , true , "Sanity check: download " + gDownloadId + " should exist after creating it" ) ; return gDownloadId ++ ; }
Adds a download to history.
Adds a download to history .