michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var hs = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: michael@0: /** michael@0: * Checks to see that a search has exactly one result in the database. michael@0: * michael@0: * @param aTerms michael@0: * The terms to search for. michael@0: * @returns true if the search returns one result, false otherwise. michael@0: */ michael@0: function search_has_result(aTerms) michael@0: { michael@0: var options = hs.getNewQueryOptions(); michael@0: options.maxResults = 1; michael@0: options.resultType = options.RESULTS_AS_URI; michael@0: var query = hs.getNewQuery(); michael@0: query.searchTerms = aTerms; michael@0: var result = hs.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: var cc = root.childCount; michael@0: root.containerOpen = false; michael@0: return (cc == 1); michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function test_execute() michael@0: { michael@0: const SEARCH_TERM = "ユニコード"; michael@0: const TEST_URL = "http://example.com/" + SEARCH_TERM + "/"; michael@0: yield promiseAddVisits(uri(TEST_URL)); michael@0: do_check_true(search_has_result(SEARCH_TERM)); michael@0: });