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: let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: let bh = hs.QueryInterface(Ci.nsIBrowserHistory); michael@0: let db = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection; michael@0: michael@0: const URLS = [ michael@0: { 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", michael@0: s: "goog" }, 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: for (let [, url] in Iterator(URLS)) { michael@0: yield task_test_url(url); michael@0: } michael@0: }); michael@0: michael@0: function task_test_url(aURL) { michael@0: print("Testing url: " + aURL.u); michael@0: yield promiseAddVisits(uri(aURL.u)); michael@0: let query = hs.getNewQuery(); michael@0: query.searchTerms = aURL.s; michael@0: let options = hs.getNewQueryOptions(); michael@0: let root = hs.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: let cc = root.childCount; michael@0: do_check_eq(cc, 1); michael@0: print("Checking url is in the query."); michael@0: let node = root.getChild(0); michael@0: print("Found " + node.uri); michael@0: root.containerOpen = false; michael@0: bh.removePage(uri(node.uri)); michael@0: } michael@0: michael@0: function check_empty_table(table_name) { michael@0: print("Checking url has been removed."); michael@0: let stmt = db.createStatement("SELECT count(*) FROM " + table_name); michael@0: try { michael@0: stmt.executeStep(); michael@0: do_check_eq(stmt.getInt32(0), 0); michael@0: } michael@0: finally { michael@0: stmt.finalize(); michael@0: } michael@0: }