browser/components/migration/tests/unit/test_IE_bookmarks.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ce245e50efab
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 function run_test() {
6 do_test_pending();
7
8 let migrator = MigrationUtils.getMigrator("ie");
9
10 // Sanity check for the source.
11 do_check_true(migrator.sourceExists);
12
13 // Ensure bookmarks migration is available.
14 let availableSources = migrator.getMigrateData("FieldOfFlowers", false);
15 do_check_true((availableSources & MigrationUtils.resourceTypes.BOOKMARKS) > 0);
16
17 // Wait for the imported bookmarks. Check that "From Internet Explorer"
18 // folders are created in the menu and on the toolbar.
19 let source = MigrationUtils.getLocalizedString("sourceNameIE");
20 let label = MigrationUtils.getLocalizedString("importedBookmarksFolder", [source]);
21
22 let expectedParents = [ PlacesUtils.bookmarksMenuFolderId,
23 PlacesUtils.toolbarFolderId ];
24
25 PlacesUtils.bookmarks.addObserver({
26 onItemAdded: function onItemAdded(aItemId, aParentId, aIndex, aItemType,
27 aURI, aTitle) {
28 if (aTitle == label) {
29 let index = expectedParents.indexOf(aParentId);
30 do_check_neq(index, -1);
31 expectedParents.splice(index, 1);
32 if (expectedParents.length == 0)
33 PlacesUtils.bookmarks.removeObserver(this);
34 }
35 },
36 onBeginUpdateBatch: function () {},
37 onEndUpdateBatch: function () {},
38 onItemRemoved: function () {},
39 onItemChanged: function () {},
40 onItemVisited: function () {},
41 onItemMoved: function () {},
42 }, false);
43
44 // Wait for migration.
45 Services.obs.addObserver(function onMigrationEnded() {
46 Services.obs.removeObserver(onMigrationEnded, "Migration:Ended");
47
48 // Check the bookmarks have been imported to all the expected parents.
49 do_check_eq(expectedParents.length, 0);
50
51 do_test_finished();
52 }, "Migration:Ended", false);
53
54 migrator.migrate(MigrationUtils.resourceTypes.BOOKMARKS, null,
55 "FieldOfFlowers");
56 }

mercurial