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 | function run_test() |
michael@0 | 8 | { |
michael@0 | 9 | run_next_test(); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | add_task(function test_execute() |
michael@0 | 13 | { |
michael@0 | 14 | try { |
michael@0 | 15 | var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. |
michael@0 | 16 | getService(Ci.nsINavHistoryService); |
michael@0 | 17 | var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. |
michael@0 | 18 | getService(Ci.nsINavBookmarksService); |
michael@0 | 19 | } catch(ex) { |
michael@0 | 20 | do_throw("Unable to initialize Places services"); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | // add a visit |
michael@0 | 24 | var testURI = uri("http://test"); |
michael@0 | 25 | yield promiseAddVisits(testURI); |
michael@0 | 26 | |
michael@0 | 27 | // query for the visit |
michael@0 | 28 | var options = histsvc.getNewQueryOptions(); |
michael@0 | 29 | options.maxResults = 1; |
michael@0 | 30 | options.resultType = options.RESULTS_AS_URI; |
michael@0 | 31 | var query = histsvc.getNewQuery(); |
michael@0 | 32 | query.uri = testURI; |
michael@0 | 33 | var result = histsvc.executeQuery(query, options); |
michael@0 | 34 | var root = result.root; |
michael@0 | 35 | |
michael@0 | 36 | // check hasChildren while the container is closed |
michael@0 | 37 | do_check_eq(root.hasChildren, true); |
michael@0 | 38 | |
michael@0 | 39 | // now check via the saved search path |
michael@0 | 40 | var queryURI = histsvc.queriesToQueryString([query], 1, options); |
michael@0 | 41 | bmsvc.insertBookmark(bmsvc.toolbarFolder, uri(queryURI), |
michael@0 | 42 | 0 /* first item */, "test query"); |
michael@0 | 43 | |
michael@0 | 44 | // query for that query |
michael@0 | 45 | var options = histsvc.getNewQueryOptions(); |
michael@0 | 46 | var query = histsvc.getNewQuery(); |
michael@0 | 47 | query.setFolders([bmsvc.toolbarFolder], 1); |
michael@0 | 48 | var result = histsvc.executeQuery(query, options); |
michael@0 | 49 | var root = result.root; |
michael@0 | 50 | root.containerOpen = true; |
michael@0 | 51 | var queryNode = root.getChild(0); |
michael@0 | 52 | do_check_eq(queryNode.title, "test query"); |
michael@0 | 53 | queryNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); |
michael@0 | 54 | do_check_eq(queryNode.hasChildren, true); |
michael@0 | 55 | root.containerOpen = false; |
michael@0 | 56 | }); |