1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/unit/test_415460.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +var hs = Cc["@mozilla.org/browser/nav-history-service;1"]. 1.11 + getService(Ci.nsINavHistoryService); 1.12 + 1.13 +/** 1.14 + * Checks to see that a search has exactly one result in the database. 1.15 + * 1.16 + * @param aTerms 1.17 + * The terms to search for. 1.18 + * @returns true if the search returns one result, false otherwise. 1.19 + */ 1.20 +function search_has_result(aTerms) 1.21 +{ 1.22 + var options = hs.getNewQueryOptions(); 1.23 + options.maxResults = 1; 1.24 + options.resultType = options.RESULTS_AS_URI; 1.25 + var query = hs.getNewQuery(); 1.26 + query.searchTerms = aTerms; 1.27 + var result = hs.executeQuery(query, options); 1.28 + var root = result.root; 1.29 + root.containerOpen = true; 1.30 + var cc = root.childCount; 1.31 + root.containerOpen = false; 1.32 + return (cc == 1); 1.33 +} 1.34 + 1.35 +function run_test() 1.36 +{ 1.37 + run_next_test(); 1.38 +} 1.39 + 1.40 +add_task(function test_execute() 1.41 +{ 1.42 + const SEARCH_TERM = "ユニコード"; 1.43 + const TEST_URL = "http://example.com/" + SEARCH_TERM + "/"; 1.44 + yield promiseAddVisits(uri(TEST_URL)); 1.45 + do_check_true(search_has_result(SEARCH_TERM)); 1.46 +});