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.

     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/. */
     5 function run_test() {
     6   do_test_pending();
     8   let migrator = MigrationUtils.getMigrator("ie");
    10   // Sanity check for the source.
    11   do_check_true(migrator.sourceExists);
    13   // Ensure bookmarks migration is available.
    14   let availableSources = migrator.getMigrateData("FieldOfFlowers", false);
    15   do_check_true((availableSources & MigrationUtils.resourceTypes.BOOKMARKS) > 0);
    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]);
    22   let expectedParents = [ PlacesUtils.bookmarksMenuFolderId,
    23                           PlacesUtils.toolbarFolderId ];
    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);
    44   // Wait for migration.
    45   Services.obs.addObserver(function onMigrationEnded() {
    46     Services.obs.removeObserver(onMigrationEnded, "Migration:Ended");
    48     // Check the bookmarks have been imported to all the expected parents.
    49     do_check_eq(expectedParents.length, 0);
    51     do_test_finished();
    52   }, "Migration:Ended", false);
    54   migrator.migrate(MigrationUtils.resourceTypes.BOOKMARKS, null,
    55                    "FieldOfFlowers");
    56 }

mercurial