summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/tests/browser/browser_ie_edge_bookmarks_success_strings.js
blob: ab0b705678a7328590d93bb930710fbfc6690d6f (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests that the progress strings that the Migration Wizard shows
 * during migrations for IE and Edge uses the term "Favorites" rather
 * then "Bookmarks".
 */
add_task(async function test_ie_edge_bookmarks_success_strings() {
  for (let key of ["ie", "edge", "internal-testing"]) {
    let sandbox = sinon.createSandbox();

    sandbox.stub(InternalTestingProfileMigrator, "key").get(() => {
      return key;
    });

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

    let testingMigrator = new InternalTestingProfileMigrator();
    sandbox.stub(MigrationUtils, "getMigrator").callsFake(() => {
      return Promise.resolve(testingMigrator);
    });

    let migration = waitForTestMigration(
      [MigrationUtils.resourceTypes.BOOKMARKS],
      [MigrationUtils.resourceTypes.BOOKMARKS],
      InternalTestingProfileMigrator.testProfile
    );

    await withMigrationWizardDialog(async prefsWin => {
      let dialogBody = prefsWin.document.body;
      let wizard = dialogBody.querySelector("migration-wizard");
      let wizardDone = BrowserTestUtils.waitForEvent(
        wizard,
        "MigrationWizard:DoneMigration"
      );
      selectResourceTypesAndStartMigration(
        wizard,
        [MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS],
        key
      );
      await migration;

      let dialog = prefsWin.document.querySelector("#migrationWizardDialog");
      let shadow = wizard.openOrClosedShadowRoot;

      // If we were using IE or Edge (EdgeHTLM), then the success message should
      // include the word "favorites". Otherwise, we expect it to include
      // the word "bookmarks".
      let bookmarksProgressGroup = shadow.querySelector(
        `.resource-progress-group[data-resource-type="${MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.BOOKMARKS}"`
      );
      let successTextElement =
        bookmarksProgressGroup.querySelector(".success-text");

      await BrowserTestUtils.waitForCondition(() => {
        return successTextElement.textContent.trim();
      });

      let successText = successTextElement.textContent.toLowerCase();

      if (key == "internal-testing") {
        Assert.ok(
          successText.includes("bookmarks"),
          `Success test should refer to bookmarks: ${successText}.`
        );
      } else {
        Assert.ok(
          successText.includes("favorites"),
          `Success test should refer to favorites: ${successText}`
        );
      }

      let doneButton = shadow.querySelector(
        "div[name='page-progress'] .done-button"
      );
      let dialogClosed = BrowserTestUtils.waitForEvent(dialog, "close");
      doneButton.click();
      await dialogClosed;
      await wizardDone;
    });

    sandbox.restore();
  }
});