summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/tests/unit/test_Chrome_passwords_emptySource.js
blob: 0e6993fdedc3e20bbbd459627c9dacf04595526d (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
"use strict";

const { ChromeProfileMigrator } = ChromeUtils.importESModule(
  "resource:///modules/ChromeProfileMigrator.sys.mjs"
);

const { sinon } = ChromeUtils.importESModule(
  "resource://testing-common/Sinon.sys.mjs"
);

add_task(async function test_importEmptyDBWithoutAuthPrompts() {
  let dirSvcPath;
  let pathId;

  if (AppConstants.platform == "macosx") {
    dirSvcPath = "LibraryWithNoData/";
    pathId = "ULibDir";
  } else if (AppConstants.platform == "win") {
    dirSvcPath = "AppData/LocalWithNoData/";
    pathId = "LocalAppData";
  } else {
    throw new Error("Not implemented");
  }
  let dirSvcFile = do_get_file(dirSvcPath);
  registerFakePath(pathId, dirSvcFile);

  let sandbox = sinon.createSandbox();
  sandbox
    .stub(ChromeProfileMigrator.prototype, "canGetPermissions")
    .resolves(true);
  sandbox
    .stub(ChromeProfileMigrator.prototype, "hasPermissions")
    .resolves(true);
  registerCleanupFunction(() => {
    sandbox.restore();
  });

  let migrator = await MigrationUtils.getMigrator("chrome");
  Assert.ok(
    !migrator,
    "Migrator should not be available since there are no passwords"
  );
});