toolkit/components/places/tests/unit/test_broken_folderShortcut_result.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function run_test()
     5 {
     6   run_next_test();
     7 }
     9 add_task(function test_execute()
    10 {
    11   PlacesUtils.bookmarks.insertBookmark(
    12     PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("http://1.moz.org/"),
    13     PlacesUtils.bookmarks.DEFAULT_INDEX, "Bookmark 1"
    14   );
    15   let id1 = PlacesUtils.bookmarks.insertBookmark(
    16     PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("place:folder=1234"),
    17     PlacesUtils.bookmarks.DEFAULT_INDEX, "Shortcut 1"
    18   );
    19   let id2 = PlacesUtils.bookmarks.insertBookmark(
    20     PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("place:folder=-1"),
    21     PlacesUtils.bookmarks.DEFAULT_INDEX, "Shortcut 2"
    22   );
    23   PlacesUtils.bookmarks.insertBookmark(
    24     PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("http://2.moz.org/"),
    25     PlacesUtils.bookmarks.DEFAULT_INDEX, "Bookmark 2"
    26   );
    28   // Add also a simple visit.
    29   yield promiseAddVisits(uri(("http://3.moz.org/")));
    31   // Query containing a broken folder shortcuts among results.
    32   let query = PlacesUtils.history.getNewQuery();
    33   query.setFolders([PlacesUtils.unfiledBookmarksFolderId], 1);
    34   let options = PlacesUtils.history.getNewQueryOptions();
    35   let root = PlacesUtils.history.executeQuery(query, options).root;
    36   root.containerOpen = true;
    38   do_check_eq(root.childCount, 4);
    40   let shortcut = root.getChild(1);
    41   do_check_eq(shortcut.uri, "place:folder=1234");
    42   PlacesUtils.asContainer(shortcut);
    43   shortcut.containerOpen = true;
    44   do_check_eq(shortcut.childCount, 0);
    45   shortcut.containerOpen = false;
    46   // Remove the broken shortcut while the containing result is open.
    47   PlacesUtils.bookmarks.removeItem(id1);
    48   do_check_eq(root.childCount, 3);
    50   shortcut = root.getChild(1);
    51   do_check_eq(shortcut.uri, "place:folder=-1");
    52   PlacesUtils.asContainer(shortcut);
    53   shortcut.containerOpen = true;
    54   do_check_eq(shortcut.childCount, 0);
    55   shortcut.containerOpen = false;
    56   // Remove the broken shortcut while the containing result is open.
    57   PlacesUtils.bookmarks.removeItem(id2);
    58   do_check_eq(root.childCount, 2);
    60   root.containerOpen = false;
    62   // Broken folder shortcut as root node.
    63   let query = PlacesUtils.history.getNewQuery();
    64   query.setFolders([1234], 1);
    65   let options = PlacesUtils.history.getNewQueryOptions();
    66   let root = PlacesUtils.history.executeQuery(query, options).root;
    67   root.containerOpen = true;
    68   do_check_eq(root.childCount, 0);
    69   root.containerOpen = false;
    71   // Broken folder shortcut as root node with folder=-1.
    72   query = PlacesUtils.history.getNewQuery();
    73   query.setFolders([-1], 1);
    74   options = PlacesUtils.history.getNewQueryOptions();
    75   root = PlacesUtils.history.executeQuery(query, options).root;
    76   root.containerOpen = true;
    77   do_check_eq(root.childCount, 0);
    78   root.containerOpen = false;
    79 });

mercurial