B2G/gecko/toolkit/components/places/tests/queries/test_tags.js
/**
 * Returns new query and query options objects.  The query's tags will be
 * set to aTags.  aTags may be null, in which case setTags() is not called at
 * all on the query.
 *
 * @param  aTags
 *         The query's tags will be set to those in this array
 * @param  aTagsAreNot
 *         The query's tagsAreNot property will be set to this
 * @return [query, queryOptions]
 */
Returns new query and query options objects.  The query's tags will be
set to aTags.  aTags may be null, in which case setTags() is not called at
all on the query.

@param  aTags
The query's tags will be set to those in this array
@param  aTagsAreNot
The query's tagsAreNot property will be set to this
@return [query, queryOptions]
Returns new query and query options objects . The query ' s tags will be set to aTags . aTags may be null in which case setTags () is not called at all on the query . @param aTags The query ' s tags will be set to those in this array @param aTagsAreNot The query ' s tagsAreNot property will be set to this @return [ query queryOptions ]
function makeQuery(aTags, aTagsAreNot) {
  aTagsAreNot = !!aTagsAreNot;
  do_log_info("Making a query " +
        (aTags ?
         "with tags " + aTags.toSource() :
         "without calling setTags() at all") +
        " and with tagsAreNot=" +
        aTagsAreNot);
  var query = PlacesUtils.history.getNewQuery();
  query.tagsAreNot = aTagsAreNot;
  if (aTags) {
    query.tags = aTags;
    var uniqueTags = [];
    aTags.forEach(function (t) {
      if (typeof(t) === "string" && uniqueTags.indexOf(t) < 0)
        uniqueTags.push(t);
    });
    uniqueTags.sort();
  }
  do_log_info("Made query should be correct for tags and tagsAreNot");
  if (uniqueTags)
    setsAreEqual(query.tags, uniqueTags, true);
  var expCount = uniqueTags ? uniqueTags.length : 0;
  do_check_eq(query.tags.length, expCount);
  do_check_eq(query.tagsAreNot, aTagsAreNot);
  return [query, PlacesUtils.history.getNewQueryOptions()];
}
function makeQuery ( aTags , aTagsAreNot ) { aTagsAreNot = ! ! aTagsAreNot ; do_log_info ( "Making a query " + ( aTags ? "with tags " + aTags . toSource ( ) : "without calling setTags() at all" ) + " and with tagsAreNot=" + aTagsAreNot ) ; var query = PlacesUtils . history . getNewQuery ( ) ; query . tagsAreNot = aTagsAreNot ; if ( aTags ) { query . tags = aTags ; var uniqueTags = [ ] ; aTags . forEach ( function ( t ) { if ( typeof ( t ) === "string" && uniqueTags . indexOf ( t ) < 0 ) uniqueTags . push ( t ) ; } ) ; uniqueTags . sort ( ) ; } do_log_info ( "Made query should be correct for tags and tagsAreNot" ) ; if ( uniqueTags ) setsAreEqual ( query . tags , uniqueTags , true ) ; var expCount = uniqueTags ? uniqueTags . length : 0 ; do_check_eq ( query . tags . length , expCount ) ; do_check_eq ( query . tagsAreNot , aTagsAreNot ) ; return [ query , PlacesUtils . history . getNewQueryOptions ( ) ] ; }
Returns new query and query options objects.
Returns new query and query options objects .