summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/tests/browser/browser_only_file_migrators.js
blob: 80c09e9a093ed4e3c25a306f9948b3dbe6739c7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests that the NO_BROWSERS_FOUND page has a button to redirect to the
 * selection page when only file migrators are found.
 */
add_task(async function test_only_file_migrators() {
  await SpecialPowers.pushPrefEnv({
    set: [["signon.management.page.fileImport.enabled", true]],
  });

  let sandbox = sinon.createSandbox();
  registerCleanupFunction(() => {
    sandbox.restore();
  });

  sandbox.stub(MigrationUtils, "availableMigratorKeys").get(() => {
    return [];
  });

  await withMigrationWizardDialog(async prefsWin => {
    let dialog = prefsWin.document.querySelector("#migrationWizardDialog");
    let wizard = dialog.querySelector("migration-wizard");
    let shadow = wizard.openOrClosedShadowRoot;
    let deck = shadow.querySelector("#wizard-deck");

    await BrowserTestUtils.waitForMutationCondition(
      deck,
      { attributeFilter: ["selected-view"] },
      () => {
        return (
          deck.getAttribute("selected-view") ==
          "page-" + MigrationWizardConstants.PAGES.NO_BROWSERS_FOUND
        );
      }
    );

    let chooseImportFileButton = shadow.querySelector(
      "#choose-import-from-file"
    );

    let changedToSelectionPage = BrowserTestUtils.waitForMutationCondition(
      deck,
      { attributeFilter: ["selected-view"] },
      () => {
        return (
          deck.getAttribute("selected-view") ==
          "page-" + MigrationWizardConstants.PAGES.SELECTION
        );
      }
    );
    chooseImportFileButton.click();
    await changedToSelectionPage;

    // No browser migrators should be listed.
    let browserMigratorItems = wizard.querySelectorAll(
      `panel-item[type="${MigrationWizardConstants.MIGRATOR_TYPES.BROWSER}"]`
    );
    Assert.ok(!browserMigratorItems.length, "No browser migrators listed.");

    // Check to make sure there's at least one file migrator listed.
    let fileMigratorItems = wizard.querySelectorAll(
      `panel-item[type="${MigrationWizardConstants.MIGRATOR_TYPES.FILE}"]`
    );

    Assert.ok(!!fileMigratorItems.length, "Listed at least one file migrator.");
  });
});