toolkit/components/places/tests/unit/test_536081.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:f5a64dc45fd3
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/. */
6
7 let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
8 getService(Ci.nsINavHistoryService);
9 let bh = hs.QueryInterface(Ci.nsIBrowserHistory);
10 let db = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
11
12 const URLS = [
13 { u: "http://www.google.com/search?q=testing%3Bthis&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox-a",
14 s: "goog" },
15 ];
16
17 function run_test()
18 {
19 run_next_test();
20 }
21
22 add_task(function test_execute()
23 {
24 for (let [, url] in Iterator(URLS)) {
25 yield task_test_url(url);
26 }
27 });
28
29 function task_test_url(aURL) {
30 print("Testing url: " + aURL.u);
31 yield promiseAddVisits(uri(aURL.u));
32 let query = hs.getNewQuery();
33 query.searchTerms = aURL.s;
34 let options = hs.getNewQueryOptions();
35 let root = hs.executeQuery(query, options).root;
36 root.containerOpen = true;
37 let cc = root.childCount;
38 do_check_eq(cc, 1);
39 print("Checking url is in the query.");
40 let node = root.getChild(0);
41 print("Found " + node.uri);
42 root.containerOpen = false;
43 bh.removePage(uri(node.uri));
44 }
45
46 function check_empty_table(table_name) {
47 print("Checking url has been removed.");
48 let stmt = db.createStatement("SELECT count(*) FROM " + table_name);
49 try {
50 stmt.executeStep();
51 do_check_eq(stmt.getInt32(0), 0);
52 }
53 finally {
54 stmt.finalize();
55 }
56 }

mercurial