B2G/gecko/toolkit/components/places/tests/unit/test_history_sidebar.js
/**
 * Adds a test URI visit to the database, and checks for a valid place ID.
 *
 * @param aURI
 *        The URI to add a visit for.
 * @param aTime
 *        Reference "now" time.
 * @param aDayOffset
 *        number of days to add, pass a negative value to subtract them.
 * @returns visit id for aURI.
 */
Adds a test URI visit to the database, and checks for a valid place ID.
@param aURI
The URI to add a visit for.
@param aTime
Reference "now" time.
@param aDayOffset
number of days to add, pass a negative value to subtract them.
@returns visit id for aURI.
Adds a test URI visit to the database and checks for a valid place ID . @param aURI The URI to add a visit for . @param aTime Reference " now " time . @param aDayOffset number of days to add pass a negative value to subtract them . @returns visit id for aURI .
function add_normalized_visit(aURI, aTime, aDayOffset) {
  var dateObj = new Date(aTime);
  dateObj.setHours(0);
  dateObj.setMinutes(0);
  dateObj.setSeconds(0);
  dateObj.setMilliseconds(0);
  var previousDateObj = new Date(dateObj.getTime() + aDayOffset * 86400000);
  var DSTCorrection = (dateObj.getTimezoneOffset() -
                       previousDateObj.getTimezoneOffset()) * 60 * 1000;
  var PRTimeWithOffset = (previousDateObj.getTime() - DSTCorrection) * 1000;
  var timeInMs = new Date(PRTimeWithOffset/1000);
  print("Adding visit to " + aURI.spec + " at " + timeInMs);
  var visitId = hs.addVisit(aURI,
                            PRTimeWithOffset,
                            null,
                            hs.TRANSITION_TYPED, 
                            false, 
                            0);
  do_check_true(visitId > 0);
  return visitId;
}
function add_normalized_visit ( aURI , aTime , aDayOffset ) { var dateObj = new Date ( aTime ) ; dateObj . setHours ( 0 ) ; dateObj . setMinutes ( 0 ) ; dateObj . setSeconds ( 0 ) ; dateObj . setMilliseconds ( 0 ) ; var previousDateObj = new Date ( dateObj . getTime ( ) + aDayOffset * 86400000 ) ; var DSTCorrection = ( dateObj . getTimezoneOffset ( ) - previousDateObj . getTimezoneOffset ( ) ) * 60 * 1000 ; var PRTimeWithOffset = ( previousDateObj . getTime ( ) - DSTCorrection ) * 1000 ; var timeInMs = new Date ( PRTimeWithOffset / 1000 ) ; print ( "Adding visit to " + aURI . spec + " at " + timeInMs ) ; var visitId = hs . addVisit ( aURI , PRTimeWithOffset , null , hs . TRANSITION_TYPED , false , 0 ) ; do_check_true ( visitId > 0 ) ; return visitId ; }
Adds a test URI visit to the database, and checks for a valid place ID.
Adds a test URI visit to the database and checks for a valid place ID .
// Normalize to midnight // Days where DST changes should be taken in count. // Substract aDayOffset // user typed in URL bar // not redirect