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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial