toolkit/components/places/tests/bookmarks/test_protectRoots.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/bookmarks/test_protectRoots.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function run_test()
     1.8 +{
     1.9 +  const ROOTS = [
    1.10 +    PlacesUtils.bookmarksMenuFolderId,
    1.11 +    PlacesUtils.toolbarFolderId,
    1.12 +    PlacesUtils.unfiledBookmarksFolderId,
    1.13 +    PlacesUtils.tagsFolderId,
    1.14 +    PlacesUtils.placesRootId
    1.15 +  ];
    1.16 +
    1.17 +  for (let root of ROOTS) {
    1.18 +    do_check_true(PlacesUtils.isRootItem(root));
    1.19 +
    1.20 +    try {
    1.21 +      PlacesUtils.bookmarks.removeItem(root);
    1.22 +      do_throw("Trying to remove a root should throw");
    1.23 +    } catch (ex) {}
    1.24 +
    1.25 +    try {
    1.26 +      PlacesUtils.bookmarks.moveItem(root, PlacesUtils.placesRootId, 0);
    1.27 +      do_throw("Trying to move a root should throw");
    1.28 +    } catch (ex) {}
    1.29 +
    1.30 +    try {
    1.31 +      PlacesUtils.bookmarks.removeFolderChildren(root);
    1.32 +      if (root == PlacesUtils.placesRootId)
    1.33 +        do_throw("Trying to remove children of the main root should throw");
    1.34 +    } catch (ex) {
    1.35 +      if (root != PlacesUtils.placesRootId)
    1.36 +        do_throw("Trying to remove children of other roots should not throw");
    1.37 +    }
    1.38 +  }
    1.39 +}

mercurial