test_Chrome_passwords_emptySource.js (1150B)
1 "use strict"; 2 3 const { ChromeProfileMigrator } = ChromeUtils.importESModule( 4 "resource:///modules/ChromeProfileMigrator.sys.mjs" 5 ); 6 7 const { sinon } = ChromeUtils.importESModule( 8 "resource://testing-common/Sinon.sys.mjs" 9 ); 10 11 add_task(async function test_importEmptyDBWithoutAuthPrompts() { 12 let dirSvcPath; 13 let pathId; 14 15 if (AppConstants.platform == "macosx") { 16 dirSvcPath = "LibraryWithNoData/"; 17 pathId = "ULibDir"; 18 } else if (AppConstants.platform == "win") { 19 dirSvcPath = "AppData/LocalWithNoData/"; 20 pathId = "LocalAppData"; 21 } else { 22 throw new Error("Not implemented"); 23 } 24 let dirSvcFile = do_get_file(dirSvcPath); 25 registerFakePath(pathId, dirSvcFile); 26 27 let sandbox = sinon.createSandbox(); 28 sandbox 29 .stub(ChromeProfileMigrator.prototype, "canGetPermissions") 30 .resolves(true); 31 sandbox 32 .stub(ChromeProfileMigrator.prototype, "hasPermissions") 33 .resolves(true); 34 registerCleanupFunction(() => { 35 sandbox.restore(); 36 }); 37 38 let migrator = await MigrationUtils.getMigrator("chrome"); 39 Assert.ok( 40 !migrator, 41 "Migrator should not be available since there are no passwords" 42 ); 43 });