Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. |
michael@0 | 8 | getService(Ci.nsINavHistoryService); |
michael@0 | 9 | let bh = hs.QueryInterface(Ci.nsIBrowserHistory); |
michael@0 | 10 | let db = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection; |
michael@0 | 11 | |
michael@0 | 12 | const URLS = [ |
michael@0 | 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", |
michael@0 | 14 | s: "goog" }, |
michael@0 | 15 | ]; |
michael@0 | 16 | |
michael@0 | 17 | function run_test() |
michael@0 | 18 | { |
michael@0 | 19 | run_next_test(); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | add_task(function test_execute() |
michael@0 | 23 | { |
michael@0 | 24 | for (let [, url] in Iterator(URLS)) { |
michael@0 | 25 | yield task_test_url(url); |
michael@0 | 26 | } |
michael@0 | 27 | }); |
michael@0 | 28 | |
michael@0 | 29 | function task_test_url(aURL) { |
michael@0 | 30 | print("Testing url: " + aURL.u); |
michael@0 | 31 | yield promiseAddVisits(uri(aURL.u)); |
michael@0 | 32 | let query = hs.getNewQuery(); |
michael@0 | 33 | query.searchTerms = aURL.s; |
michael@0 | 34 | let options = hs.getNewQueryOptions(); |
michael@0 | 35 | let root = hs.executeQuery(query, options).root; |
michael@0 | 36 | root.containerOpen = true; |
michael@0 | 37 | let cc = root.childCount; |
michael@0 | 38 | do_check_eq(cc, 1); |
michael@0 | 39 | print("Checking url is in the query."); |
michael@0 | 40 | let node = root.getChild(0); |
michael@0 | 41 | print("Found " + node.uri); |
michael@0 | 42 | root.containerOpen = false; |
michael@0 | 43 | bh.removePage(uri(node.uri)); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function check_empty_table(table_name) { |
michael@0 | 47 | print("Checking url has been removed."); |
michael@0 | 48 | let stmt = db.createStatement("SELECT count(*) FROM " + table_name); |
michael@0 | 49 | try { |
michael@0 | 50 | stmt.executeStep(); |
michael@0 | 51 | do_check_eq(stmt.getInt32(0), 0); |
michael@0 | 52 | } |
michael@0 | 53 | finally { |
michael@0 | 54 | stmt.finalize(); |
michael@0 | 55 | } |
michael@0 | 56 | } |