michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function test_execute() michael@0: { michael@0: PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("http://1.moz.org/"), michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, "Bookmark 1" michael@0: ); michael@0: let id1 = PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("place:folder=1234"), michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, "Shortcut 1" michael@0: ); michael@0: let id2 = PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("place:folder=-1"), michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, "Shortcut 2" michael@0: ); michael@0: PlacesUtils.bookmarks.insertBookmark( michael@0: PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("http://2.moz.org/"), michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, "Bookmark 2" michael@0: ); michael@0: michael@0: // Add also a simple visit. michael@0: yield promiseAddVisits(uri(("http://3.moz.org/"))); michael@0: michael@0: // Query containing a broken folder shortcuts among results. michael@0: let query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.unfiledBookmarksFolderId], 1); michael@0: let options = PlacesUtils.history.getNewQueryOptions(); michael@0: let root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: michael@0: do_check_eq(root.childCount, 4); michael@0: michael@0: let shortcut = root.getChild(1); michael@0: do_check_eq(shortcut.uri, "place:folder=1234"); michael@0: PlacesUtils.asContainer(shortcut); michael@0: shortcut.containerOpen = true; michael@0: do_check_eq(shortcut.childCount, 0); michael@0: shortcut.containerOpen = false; michael@0: // Remove the broken shortcut while the containing result is open. michael@0: PlacesUtils.bookmarks.removeItem(id1); michael@0: do_check_eq(root.childCount, 3); michael@0: michael@0: shortcut = root.getChild(1); michael@0: do_check_eq(shortcut.uri, "place:folder=-1"); michael@0: PlacesUtils.asContainer(shortcut); michael@0: shortcut.containerOpen = true; michael@0: do_check_eq(shortcut.childCount, 0); michael@0: shortcut.containerOpen = false; michael@0: // Remove the broken shortcut while the containing result is open. michael@0: PlacesUtils.bookmarks.removeItem(id2); michael@0: do_check_eq(root.childCount, 2); michael@0: michael@0: root.containerOpen = false; michael@0: michael@0: // Broken folder shortcut as root node. michael@0: let query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([1234], 1); michael@0: let options = PlacesUtils.history.getNewQueryOptions(); michael@0: let root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: do_check_eq(root.childCount, 0); michael@0: root.containerOpen = false; michael@0: michael@0: // Broken folder shortcut as root node with folder=-1. michael@0: query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([-1], 1); michael@0: options = PlacesUtils.history.getNewQueryOptions(); michael@0: root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: do_check_eq(root.childCount, 0); michael@0: root.containerOpen = false; michael@0: });