B2G/gecko/toolkit/mozapps/extensions/test/browser/browser_bug714593.js
/*
 * Completes a search
 *
 * @param  aQuery
 *         The query to search for
 * @param  aFinishImmediately
 *         Boolean representing whether or not the search is expected to
 *         finish immediately
 * @param  aCallback
 *         The callback to call when the search is done
 * @param  aCategoryType
 *         The expected selected category after the search is done.
 *         Optional and defaults to "search"
 */
Completes a search
@param  aQuery
The query to search for
@param  aFinishImmediately
Boolean representing whether or not the search is expected to
finish immediately
@param  aCallback
The callback to call when the search is done
@param  aCategoryType
The expected selected category after the search is done.
Optional and defaults to "search"
Completes a search @param aQuery The query to search for @param aFinishImmediately Boolean representing whether or not the search is expected to finish immediately @param aCallback The callback to call when the search is done @param aCategoryType The expected selected category after the search is done . Optional and defaults to " search "
function search(aQuery, aFinishImmediately, aCallback, aCategoryType) {
  Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, NO_MATCH_URL);
  aCategoryType = aCategoryType ? aCategoryType : "search";
  var searchBox = gManagerWindow.document.getElementById("header-search");
  searchBox.value = aQuery;
  EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
  EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
  var finishImmediately = true;
  wait_for_view_load(gManagerWindow, function() {
    is(gCategoryUtilities.selectedCategory, aCategoryType, "Expected category view should be selected");
    is(gCategoryUtilities.isTypeVisible("search"), aCategoryType == "search",
       "Search category should only be visible if it is the current view");
    is(finishImmediately, aFinishImmediately, "Search should finish immediately only if expected");
    aCallback();
  });
  finishImmediately = false
  if (!aFinishImmediately)
    check_is_searching(true);
}
function search ( aQuery , aFinishImmediately , aCallback , aCategoryType ) { Services . prefs . setCharPref ( PREF_GETADDONS_GETSEARCHRESULTS , NO_MATCH_URL ) ; aCategoryType = aCategoryType ? aCategoryType : "search" ; var searchBox = gManagerWindow . document . getElementById ( "header-search" ) ; searchBox . value = aQuery ; EventUtils . synthesizeMouseAtCenter ( searchBox , { } , gManagerWindow ) ; EventUtils . synthesizeKey ( "VK_RETURN" , { } , gManagerWindow ) ; var finishImmediately = true ; wait_for_view_load ( gManagerWindow , function ( ) { is ( gCategoryUtilities . selectedCategory , aCategoryType , "Expected category view should be selected" ) ; is ( gCategoryUtilities . isTypeVisible ( "search" ) , aCategoryType == "search" , "Search category should only be visible if it is the current view" ) ; is ( finishImmediately , aFinishImmediately , "Search should finish immediately only if expected" ) ; aCallback ( ) ; } ) ; finishImmediately = false if ( ! aFinishImmediately ) check_is_searching ( true ) ; }
Completes a search
 @param  aQuery
         The query to search for
 @param  aFinishImmediately
         Boolean representing whether or not the search is expected to
         finish immediately
 @param  aCallback
         The callback to call when the search is done
 @param  aCategoryType
         The expected selected category after the search is done.
Completes a search @param aQuery The query to search for @param aFinishImmediately Boolean representing whether or not the search is expected to finish immediately @param aCallback The callback to call when the search is done @param aCategoryType The expected selected category after the search is done .
// Point search to the correct xml test file