Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
8 getService(Ci.nsINavHistoryService);
10 /**
11 * Checks to see that a search has exactly one result in the database.
12 *
13 * @param aTerms
14 * The terms to search for.
15 * @returns true if the search returns one result, false otherwise.
16 */
17 function search_has_result(aTerms)
18 {
19 var options = hs.getNewQueryOptions();
20 options.maxResults = 1;
21 options.resultType = options.RESULTS_AS_URI;
22 var query = hs.getNewQuery();
23 query.searchTerms = aTerms;
24 var result = hs.executeQuery(query, options);
25 var root = result.root;
26 root.containerOpen = true;
27 var cc = root.childCount;
28 root.containerOpen = false;
29 return (cc == 1);
30 }
32 function run_test()
33 {
34 run_next_test();
35 }
37 add_task(function test_execute()
38 {
39 const SEARCH_TERM = "ユニコード";
40 const TEST_URL = "http://example.com/" + SEARCH_TERM + "/";
41 yield promiseAddVisits(uri(TEST_URL));
42 do_check_true(search_has_result(SEARCH_TERM));
43 });