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: 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: try { michael@0: var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. michael@0: getService(Ci.nsINavBookmarksService); michael@0: } catch(ex) { michael@0: do_throw("Unable to initialize Places services"); michael@0: } michael@0: michael@0: // add a visit michael@0: var testURI = uri("http://test"); michael@0: yield promiseAddVisits(testURI); michael@0: michael@0: // query for the visit michael@0: var options = histsvc.getNewQueryOptions(); michael@0: options.maxResults = 1; michael@0: options.resultType = options.RESULTS_AS_URI; michael@0: var query = histsvc.getNewQuery(); michael@0: query.uri = testURI; michael@0: var result = histsvc.executeQuery(query, options); michael@0: var root = result.root; michael@0: michael@0: // check hasChildren while the container is closed michael@0: do_check_eq(root.hasChildren, true); michael@0: michael@0: // now check via the saved search path michael@0: var queryURI = histsvc.queriesToQueryString([query], 1, options); michael@0: bmsvc.insertBookmark(bmsvc.toolbarFolder, uri(queryURI), michael@0: 0 /* first item */, "test query"); michael@0: michael@0: // query for that query michael@0: var options = histsvc.getNewQueryOptions(); michael@0: var query = histsvc.getNewQuery(); michael@0: query.setFolders([bmsvc.toolbarFolder], 1); michael@0: var result = histsvc.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: var queryNode = root.getChild(0); michael@0: do_check_eq(queryNode.title, "test query"); michael@0: queryNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); michael@0: do_check_eq(queryNode.hasChildren, true); michael@0: root.containerOpen = false; michael@0: });