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: function run_test() { michael@0: do_test_pending(); michael@0: michael@0: let migrator = MigrationUtils.getMigrator("ie"); michael@0: michael@0: // Sanity check for the source. michael@0: do_check_true(migrator.sourceExists); michael@0: michael@0: // Ensure bookmarks migration is available. michael@0: let availableSources = migrator.getMigrateData("FieldOfFlowers", false); michael@0: do_check_true((availableSources & MigrationUtils.resourceTypes.BOOKMARKS) > 0); michael@0: michael@0: // Wait for the imported bookmarks. Check that "From Internet Explorer" michael@0: // folders are created in the menu and on the toolbar. michael@0: let source = MigrationUtils.getLocalizedString("sourceNameIE"); michael@0: let label = MigrationUtils.getLocalizedString("importedBookmarksFolder", [source]); michael@0: michael@0: let expectedParents = [ PlacesUtils.bookmarksMenuFolderId, michael@0: PlacesUtils.toolbarFolderId ]; michael@0: michael@0: PlacesUtils.bookmarks.addObserver({ michael@0: onItemAdded: function onItemAdded(aItemId, aParentId, aIndex, aItemType, michael@0: aURI, aTitle) { michael@0: if (aTitle == label) { michael@0: let index = expectedParents.indexOf(aParentId); michael@0: do_check_neq(index, -1); michael@0: expectedParents.splice(index, 1); michael@0: if (expectedParents.length == 0) michael@0: PlacesUtils.bookmarks.removeObserver(this); michael@0: } michael@0: }, michael@0: onBeginUpdateBatch: function () {}, michael@0: onEndUpdateBatch: function () {}, michael@0: onItemRemoved: function () {}, michael@0: onItemChanged: function () {}, michael@0: onItemVisited: function () {}, michael@0: onItemMoved: function () {}, michael@0: }, false); michael@0: michael@0: // Wait for migration. michael@0: Services.obs.addObserver(function onMigrationEnded() { michael@0: Services.obs.removeObserver(onMigrationEnded, "Migration:Ended"); michael@0: michael@0: // Check the bookmarks have been imported to all the expected parents. michael@0: do_check_eq(expectedParents.length, 0); michael@0: michael@0: do_test_finished(); michael@0: }, "Migration:Ended", false); michael@0: michael@0: migrator.migrate(MigrationUtils.resourceTypes.BOOKMARKS, null, michael@0: "FieldOfFlowers"); michael@0: }