test_BackupService_setParentDirPath.js (1225B)
1 /* Any copyright is dedicated to the Public Domain. 2 https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 ChromeUtils.defineESModuleGetters(this, { 7 AppConstants: "resource://gre/modules/AppConstants.sys.mjs", 8 BackupError: "resource:///modules/backup/BackupError.mjs", 9 }); 10 11 add_task(function test_empty() { 12 let bs = new BackupService(); 13 Assert.throws( 14 () => bs.setParentDirPath(""), 15 BackupError, 16 "empty string is rejected" 17 ); 18 }); 19 20 add_task(function test_typical() { 21 let bs = new BackupService(); 22 let name = "setParentDirPath_typical"; 23 let path = PathUtils.join(do_get_profile().path, name); 24 bs.setParentDirPath(path); 25 Assert.equal( 26 Services.prefs.getStringPref("browser.backup.location"), 27 PathUtils.join(path, "Restore Firefox"), 28 "Path with 'Restore Firefox' appended is used" 29 ); 30 }); 31 32 add_task(function test_already_decorated() { 33 let bs = new BackupService(); 34 let name = "setParentDirPath_already_decorated"; 35 let path = PathUtils.join(do_get_profile().path, name, "Restore Firefox"); 36 bs.setParentDirPath(path); 37 Assert.equal( 38 Services.prefs.getStringPref("browser.backup.location"), 39 path, 40 "No duplicate 'Restore Firefox' is appended" 41 ); 42 });