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: // The test data for our database, note that the ordering of the results that michael@0: // will be returned by the query (the isInQuery: true objects) is IMPORTANT. michael@0: // see compareArrayToResult in head_queries.js for more info. michael@0: var testData = [ michael@0: // Normal folder michael@0: { isInQuery: true, isFolder: true, title: "Folder 1", michael@0: parentFolder: PlacesUtils.toolbarFolderId }, michael@0: michael@0: // Read only folder michael@0: { isInQuery: false, isFolder: true, title: "Folder 2 RO", michael@0: parentFolder: PlacesUtils.toolbarFolderId, readOnly: true } 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_excludeReadOnlyFolders() michael@0: { michael@0: yield task_populateDB(testData); michael@0: michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.toolbarFolderId], 1); michael@0: michael@0: // Options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.excludeQueries = true; michael@0: options.excludeReadOnlyFolders = true; michael@0: michael@0: // Results michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: michael@0: displayResultSet(root); michael@0: // The readonly folder should not be in our result set. michael@0: do_check_eq(1, root.childCount); michael@0: do_check_eq("Folder 1", root.getChild(0).title); michael@0: michael@0: root.containerOpen = false; michael@0: });