B2G/gecko/toolkit/components/places/tests/unit/test_childlessTags.js
/**
 * Runs a tag query and ensures that the tags returned are those and only those
 * in aTags.  aTags may be empty, in which case this function ensures that no
 * tags exist.
 *
 * @param aTags
 *        An array of tags (strings)
 */
Runs a tag query and ensures that the tags returned are those and only those
in aTags.  aTags may be empty, in which case this function ensures that no
tags exist.

@param aTags
An array of tags (strings)
Runs a tag query and ensures that the tags returned are those and only those in aTags . aTags may be empty in which case this function ensures that no tags exist . @param aTags An array of tags ( strings )
function ensureTagsExist(aTags) {
  var query = histsvc.getNewQuery();
  var opts = histsvc.getNewQueryOptions();
  opts.resultType = opts.RESULTS_AS_TAG_QUERY;
  var resultRoot = histsvc.executeQuery(query, opts).root;
  var tags = aTags.slice(0);
  resultRoot.containerOpen = true;
  do_check_eq(resultRoot.childCount, tags.length);
  for (let i = 0; i < resultRoot.childCount; i++) {
    var tag = resultRoot.getChild(i).title;
    var indexOfTag = tags.indexOf(tag);
    do_check_true(indexOfTag >= 0);
    tags.splice(indexOfTag, 1);
  }
  resultRoot.containerOpen = false;
}
function ensureTagsExist ( aTags ) { var query = histsvc . getNewQuery ( ) ; var opts = histsvc . getNewQueryOptions ( ) ; opts . resultType = opts . RESULTS_AS_TAG_QUERY ; var resultRoot = histsvc . executeQuery ( query , opts ) . root ; var tags = aTags . slice ( 0 ) ; resultRoot . containerOpen = true ; do_check_eq ( resultRoot . childCount , tags . length ) ; for ( let i = 0 ; i < resultRoot . childCount ; i ++ ) { var tag = resultRoot . getChild ( i ) . title ; var indexOfTag = tags . indexOf ( tag ) ; do_check_true ( indexOfTag >= 0 ) ; tags . splice ( indexOfTag , 1 ) ; } resultRoot . containerOpen = false ; }
Runs a tag query and ensures that the tags returned are those and only those
 in aTags.
Runs a tag query and ensures that the tags returned are those and only those in aTags .
// Dupe aTags. // Ensure that the number of tags returned from the query is the same as the // number in |tags|. // For each tag result from the query, ensure that it's contained in |tags|. // Remove the tag from |tags| so that we ensure the sets are equal.