1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/unit/test_433525_hasChildren_crash.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +function run_test() 1.11 +{ 1.12 + run_next_test(); 1.13 +} 1.14 + 1.15 +add_task(function test_execute() 1.16 +{ 1.17 + try { 1.18 + var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. 1.19 + getService(Ci.nsINavHistoryService); 1.20 + var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. 1.21 + getService(Ci.nsINavBookmarksService); 1.22 + } catch(ex) { 1.23 + do_throw("Unable to initialize Places services"); 1.24 + } 1.25 + 1.26 + // add a visit 1.27 + var testURI = uri("http://test"); 1.28 + yield promiseAddVisits(testURI); 1.29 + 1.30 + // query for the visit 1.31 + var options = histsvc.getNewQueryOptions(); 1.32 + options.maxResults = 1; 1.33 + options.resultType = options.RESULTS_AS_URI; 1.34 + var query = histsvc.getNewQuery(); 1.35 + query.uri = testURI; 1.36 + var result = histsvc.executeQuery(query, options); 1.37 + var root = result.root; 1.38 + 1.39 + // check hasChildren while the container is closed 1.40 + do_check_eq(root.hasChildren, true); 1.41 + 1.42 + // now check via the saved search path 1.43 + var queryURI = histsvc.queriesToQueryString([query], 1, options); 1.44 + bmsvc.insertBookmark(bmsvc.toolbarFolder, uri(queryURI), 1.45 + 0 /* first item */, "test query"); 1.46 + 1.47 + // query for that query 1.48 + var options = histsvc.getNewQueryOptions(); 1.49 + var query = histsvc.getNewQuery(); 1.50 + query.setFolders([bmsvc.toolbarFolder], 1); 1.51 + var result = histsvc.executeQuery(query, options); 1.52 + var root = result.root; 1.53 + root.containerOpen = true; 1.54 + var queryNode = root.getChild(0); 1.55 + do_check_eq(queryNode.title, "test query"); 1.56 + queryNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); 1.57 + do_check_eq(queryNode.hasChildren, true); 1.58 + root.containerOpen = false; 1.59 +});