toolkit/components/places/tests/unit/test_433317_query_title_update.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/test_433317_query_title_update.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     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 +  try {
    1.12 +  var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
    1.13 +                getService(Ci.nsINavHistoryService);
    1.14 +  var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    1.15 +              getService(Ci.nsINavBookmarksService);
    1.16 +  } catch(ex) {
    1.17 +    do_throw("Unable to initialize Places services");
    1.18 +  }
    1.19 +
    1.20 +  // create a query bookmark
    1.21 +  var queryId = bmsvc.insertBookmark(bmsvc.toolbarFolder, uri("place:"),
    1.22 +                                     0 /* first item */, "test query");
    1.23 +
    1.24 +  // query for that query
    1.25 +  var options = histsvc.getNewQueryOptions();
    1.26 +  var query = histsvc.getNewQuery();
    1.27 +  query.setFolders([bmsvc.toolbarFolder], 1);
    1.28 +  var result = histsvc.executeQuery(query, options);
    1.29 +  var root = result.root;
    1.30 +  root.containerOpen = true;
    1.31 +  var queryNode = root.getChild(0);
    1.32 +  do_check_eq(queryNode.title, "test query");
    1.33 +
    1.34 +  // change the title
    1.35 +  bmsvc.setItemTitle(queryId, "foo");
    1.36 +
    1.37 +  // confirm the node was updated
    1.38 +  do_check_eq(queryNode.title, "foo");
    1.39 +
    1.40 +  root.containerOpen = false;
    1.41 +}

mercurial