toolkit/components/places/tests/queries/test_excludeReadOnlyFolders.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/queries/test_excludeReadOnlyFolders.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     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 +// The test data for our database, note that the ordering of the results that
    1.11 +// will be returned by the query (the isInQuery: true objects) is IMPORTANT.
    1.12 +// see compareArrayToResult in head_queries.js for more info.
    1.13 +var testData = [
    1.14 +  // Normal folder
    1.15 +  { isInQuery: true, isFolder: true, title: "Folder 1",
    1.16 +    parentFolder: PlacesUtils.toolbarFolderId },
    1.17 +
    1.18 +  // Read only folder
    1.19 +  { isInQuery: false, isFolder: true, title: "Folder 2 RO",
    1.20 +    parentFolder: PlacesUtils.toolbarFolderId, readOnly: true }
    1.21 +];
    1.22 +
    1.23 +function run_test()
    1.24 +{
    1.25 +  run_next_test();
    1.26 +}
    1.27 +
    1.28 +add_task(function test_excludeReadOnlyFolders()
    1.29 +{
    1.30 +  yield task_populateDB(testData);
    1.31 +
    1.32 +  var query = PlacesUtils.history.getNewQuery();
    1.33 +  query.setFolders([PlacesUtils.toolbarFolderId], 1);
    1.34 +
    1.35 +  // Options
    1.36 +  var options = PlacesUtils.history.getNewQueryOptions();
    1.37 +  options.excludeQueries = true;
    1.38 +  options.excludeReadOnlyFolders = true;
    1.39 +
    1.40 +  // Results
    1.41 +  var result = PlacesUtils.history.executeQuery(query, options);
    1.42 +  var root = result.root;
    1.43 +  root.containerOpen = true;
    1.44 +
    1.45 +  displayResultSet(root);
    1.46 +  // The readonly folder should not be in our result set.
    1.47 +  do_check_eq(1, root.childCount);
    1.48 +  do_check_eq("Folder 1", root.getChild(0).title);
    1.49 +
    1.50 +  root.containerOpen = false;
    1.51 +});

mercurial