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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /**
     8  * Both SetItemtitle and insertBookmark should allow for null titles.
     9  */
    11 const bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    12            getService(Ci.nsINavBookmarksService);
    14 const TEST_URL = "http://www.mozilla.org";
    16 function run_test() {
    17   // Insert a bookmark with an empty title.
    18   var itemId = bs.insertBookmark(bs.toolbarFolder,
    19                                  uri(TEST_URL),
    20                                  bs.DEFAULT_INDEX,
    21                                  "");
    22   // Check returned title is an empty string.
    23   do_check_eq(bs.getItemTitle(itemId), "");
    24   // Set title to null.
    25   bs.setItemTitle(itemId, null);
    26   // Check returned title is null.
    27   do_check_eq(bs.getItemTitle(itemId), null);
    28   // Cleanup.
    29   bs.removeItem(itemId);
    31   // Insert a bookmark with a null title.
    32   itemId = bs.insertBookmark(bs.toolbarFolder,
    33                              uri(TEST_URL),
    34                              bs.DEFAULT_INDEX,
    35                              null);
    36   // Check returned title is null.
    37   do_check_eq(bs.getItemTitle(itemId), null);
    38   // Set title to an empty string.
    39   bs.setItemTitle(itemId, "");
    40   // Check returned title is an empty string.
    41   do_check_eq(bs.getItemTitle(itemId), "");
    42   // Cleanup.
    43   bs.removeItem(itemId);
    44 }

mercurial