toolkit/components/places/tests/unit/test_bookmarks_setNullTitle.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_bookmarks_setNullTitle.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     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 +/**
    1.11 + * Both SetItemtitle and insertBookmark should allow for null titles.
    1.12 + */
    1.13 +
    1.14 +const bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    1.15 +           getService(Ci.nsINavBookmarksService);
    1.16 +
    1.17 +const TEST_URL = "http://www.mozilla.org";
    1.18 +
    1.19 +function run_test() {
    1.20 +  // Insert a bookmark with an empty title.
    1.21 +  var itemId = bs.insertBookmark(bs.toolbarFolder,
    1.22 +                                 uri(TEST_URL),
    1.23 +                                 bs.DEFAULT_INDEX,
    1.24 +                                 "");
    1.25 +  // Check returned title is an empty string.
    1.26 +  do_check_eq(bs.getItemTitle(itemId), "");
    1.27 +  // Set title to null.
    1.28 +  bs.setItemTitle(itemId, null);
    1.29 +  // Check returned title is null.
    1.30 +  do_check_eq(bs.getItemTitle(itemId), null);
    1.31 +  // Cleanup.
    1.32 +  bs.removeItem(itemId);
    1.33 +
    1.34 +  // Insert a bookmark with a null title.
    1.35 +  itemId = bs.insertBookmark(bs.toolbarFolder,
    1.36 +                             uri(TEST_URL),
    1.37 +                             bs.DEFAULT_INDEX,
    1.38 +                             null);
    1.39 +  // Check returned title is null.
    1.40 +  do_check_eq(bs.getItemTitle(itemId), null);
    1.41 +  // Set title to an empty string.
    1.42 +  bs.setItemTitle(itemId, "");
    1.43 +  // Check returned title is an empty string.
    1.44 +  do_check_eq(bs.getItemTitle(itemId), "");
    1.45 +  // Cleanup.
    1.46 +  bs.removeItem(itemId);
    1.47 +}

mercurial