add: ensureSearchPref() 
context: function OpenSearch(tabName, forceDialogFlag, searchStr){  //This function needs to be split up someday.  var autoOpenSearchPanel = false;  var defaultSearchURL = null;  var fallbackDefaultSearchURL = gNavigatorRegionBundle.getString("fallbackDefaultSearchURL");  // XXX This somehow causes a big leak, back to the old way  //     till we figure out why. See bug 61886.  // var url = getWebNavigation().currentURI.spec;  var url = _content.location.href;  //Check to see if search string contains "://" or "ftp." or white space.  //If it does treat as url and match for pattern      var urlmatch= /(:\/\/|^ftp\.)[^ \S]+$/     var forceAsURL = urlmatch.test(searchStr);  try {    autoOpenSearchPanel = pref.GetBoolPref("browser.search.opensidebarsearchpanel");    defaultSearchURL = pref.getLocalizedUnicharPref("browser.search.defaulturl");  } catch (ex) {  }  // Fallback to a default url (one that we can get sidebar search results for)  if (!defaultSearchURL)    defaultSearchURL = fallbackDefaultSearchURL;  //Check to see if content url equals url in location bar.  //If they match then go to default search URL engine  if ((!searchStr || searchStr == url)) {  if (defaultSearchURL != fallbackDefaultSearchURL)      loadURI(defaultSearchURL);    else      loadURI(gNavigatorRegionBundle.getString("otherSearchURL"));  } else {  //Check to see if location bar field is a url  //If it is a url go to URL.  A Url is "://" or "." as commented above  //Otherwise search on entry  if (forceAsURL) {     BrowserLoadURL()   } else {    var searchMode = 0;    try {      searchMode = pref.GetIntPref("browser.search.powermode");    } catch(ex) {    }    if (forceDialogFlag || searchMode == 1) {      // Use a single search dialog      var windowManager = Components.classes["@mozilla.org/rdf/datasource;1?name=window-mediator"]                                    .getService(Components.interfaces.nsIWindowMediator);      var searchWindow = windowManager.getMostRecentWindow("search:window");      if (!searchWindow) {        openDialog("chrome://communicator/content/search/search.xul", "SearchWindow", "dialog=no,close,chrome,resizable", tabName, searchStr);      } else {        // Already had one, focus it and load the page        searchWindow.focus();        if ("loadPage" in searchWindow)          searchWindow.loadPage(tabName, searchStr);      }    } else {      if (searchStr) {        var escapedSearchStr = escape(searchStr);        defaultSearchURL += escapedSearchStr;        var searchDS = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"]                                 .getService(Components.interfaces.nsIInternetSearchService);        searchDS.RememberLastSearchText(escapedSearchStr);        try {          var searchEngineURI = pref.CopyCharPref("browser.search.defaultengine");          if (searchEngineURI) {            var searchURL = searchDS.GetInternetSearchURL(searchEngineURI, escapedSearchStr);          if (searchURL)              defaultSearchURL = searchURL;          }        } catch (ex) {        }        loadURI(defaultSearchURL);      }     }    }  }  // should we try and open up the sidebar to show the "Search Results" panel?  if (autoOpenSearchPanel)    RevealSearchPanel();}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/bf04afe524d4d7a3789764bb4a62f70bea1802de/navigator.js/buggy/suite/browser/navigator.js