michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * Checks that backups properly include all of the bookmarks if the hierarchy michael@0: * in the database is unordered so that a hierarchy is defined before its michael@0: * ancestor in the bookmarks table. michael@0: */ michael@0: function run_test() { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function() { michael@0: let bm = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, michael@0: NetUtil.newURI("http://mozilla.org/"), michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: "bookmark"); michael@0: let f2 = PlacesUtils.bookmarks.createFolder(PlacesUtils.unfiledBookmarksFolderId, "f2", michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX); michael@0: PlacesUtils.bookmarks.moveItem(bm, f2, PlacesUtils.bookmarks.DEFAULT_INDEX); michael@0: let f1 = PlacesUtils.bookmarks.createFolder(PlacesUtils.unfiledBookmarksFolderId, "f1", michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX); michael@0: PlacesUtils.bookmarks.moveItem(f2, f1, PlacesUtils.bookmarks.DEFAULT_INDEX); michael@0: michael@0: // Create a backup. michael@0: yield PlacesBackups.create(); michael@0: michael@0: // Remove the bookmarks, then restore the backup. michael@0: PlacesUtils.bookmarks.removeItem(f1); michael@0: yield BookmarkJSONUtils.importFromFile((yield PlacesBackups.getMostRecentBackup()), true); michael@0: michael@0: do_log_info("Checking first level"); michael@0: let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root; michael@0: let level1 = root.getChild(0); michael@0: do_check_eq(level1.title, "f1"); michael@0: do_log_info("Checking second level"); michael@0: PlacesUtils.asContainer(level1).containerOpen = true michael@0: let level2 = level1.getChild(0); michael@0: do_check_eq(level2.title, "f2"); michael@0: do_log_info("Checking bookmark"); michael@0: PlacesUtils.asContainer(level2).containerOpen = true michael@0: let bookmark = level2.getChild(0); michael@0: do_check_eq(bookmark.title, "bookmark"); michael@0: level2.containerOpen = false; michael@0: level1.containerOpen = false; michael@0: root.containerOpen = false; michael@0: });