diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
commit | 39dac57259cff8b61db0b22cb2ad0a8adb02692e (patch) | |
tree | 52a026cc8c22793eb17fd0f5e22adce1ae08a1dd /toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js | |
parent | a1cce3b2b00bbd9f4983013ddd8934a7bccb9e99 (diff) | |
parent | c2d9ab62f3d097c9e0e00184cab1f546554f5eaa (diff) | |
download | UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.gz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.lz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.xz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.zip |
Merge branch 'redwood' into 28.9-platform
Diffstat (limited to 'toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js')
-rw-r--r-- | toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js b/toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js deleted file mode 100644 index adf345b0c..000000000 --- a/toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js +++ /dev/null @@ -1,143 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -var {OS: {File, Path, Constants}} = Components.utils.import("resource://gre/modules/osfile.jsm", {}); -Components.utils.import("resource://gre/modules/Task.jsm"); - -/** - * Remove all temporary files and back up files, including - * test_backupTo_option_with_tmpPath.tmp - * test_backupTo_option_with_tmpPath.tmp.backup - * test_backupTo_option_without_tmpPath.tmp - * test_backupTo_option_without_tmpPath.tmp.backup - * test_non_backupTo_option.tmp - * test_non_backupTo_option.tmp.backup - * test_backupTo_option_without_destination_file.tmp - * test_backupTo_option_without_destination_file.tmp.backup - * test_backupTo_option_with_backup_file.tmp - * test_backupTo_option_with_backup_file.tmp.backup - */ -function clearFiles() { - return Task.spawn(function () { - let files = ["test_backupTo_option_with_tmpPath.tmp", - "test_backupTo_option_without_tmpPath.tmp", - "test_non_backupTo_option.tmp", - "test_backupTo_option_without_destination_file.tmp", - "test_backupTo_option_with_backup_file.tmp"]; - for (let file of files) { - let path = Path.join(Constants.Path.tmpDir, file); - yield File.remove(path); - yield File.remove(path + ".backup"); - } - }); -} - -function run_test() { - run_next_test(); -} - -add_task(function* init() { - yield clearFiles(); -}); - -/** - * test when - * |backupTo| specified - * |tmpPath| specified - * destination file exists - * @result destination file will be backed up - */ -add_task(function* test_backupTo_option_with_tmpPath() { - let DEFAULT_CONTENTS = "default contents" + Math.random(); - let WRITE_CONTENTS = "abc" + Math.random(); - let path = Path.join(Constants.Path.tmpDir, - "test_backupTo_option_with_tmpPath.tmp"); - yield File.writeAtomic(path, DEFAULT_CONTENTS); - yield File.writeAtomic(path, WRITE_CONTENTS, { tmpPath: path + ".tmp", - backupTo: path + ".backup" }); - do_check_true((yield File.exists(path + ".backup"))); - let contents = yield File.read(path + ".backup"); - do_check_eq(DEFAULT_CONTENTS, (new TextDecoder()).decode(contents)); -}); - -/** - * test when - * |backupTo| specified - * |tmpPath| not specified - * destination file exists - * @result destination file will be backed up - */ -add_task(function* test_backupTo_option_without_tmpPath() { - let DEFAULT_CONTENTS = "default contents" + Math.random(); - let WRITE_CONTENTS = "abc" + Math.random(); - let path = Path.join(Constants.Path.tmpDir, - "test_backupTo_option_without_tmpPath.tmp"); - yield File.writeAtomic(path, DEFAULT_CONTENTS); - yield File.writeAtomic(path, WRITE_CONTENTS, { backupTo: path + ".backup" }); - do_check_true((yield File.exists(path + ".backup"))); - let contents = yield File.read(path + ".backup"); - do_check_eq(DEFAULT_CONTENTS, (new TextDecoder()).decode(contents)); -}); - -/** - * test when - * |backupTo| not specified - * |tmpPath| not specified - * destination file exists - * @result destination file will not be backed up - */ -add_task(function* test_non_backupTo_option() { - let DEFAULT_CONTENTS = "default contents" + Math.random(); - let WRITE_CONTENTS = "abc" + Math.random(); - let path = Path.join(Constants.Path.tmpDir, - "test_non_backupTo_option.tmp"); - yield File.writeAtomic(path, DEFAULT_CONTENTS); - yield File.writeAtomic(path, WRITE_CONTENTS); - do_check_false((yield File.exists(path + ".backup"))); -}); - -/** - * test when - * |backupTo| specified - * |tmpPath| not specified - * destination file not exists - * @result no back up file exists - */ -add_task(function* test_backupTo_option_without_destination_file() { - let DEFAULT_CONTENTS = "default contents" + Math.random(); - let WRITE_CONTENTS = "abc" + Math.random(); - let path = Path.join(Constants.Path.tmpDir, - "test_backupTo_option_without_destination_file.tmp"); - yield File.remove(path); - yield File.writeAtomic(path, WRITE_CONTENTS, { backupTo: path + ".backup" }); - do_check_false((yield File.exists(path + ".backup"))); -}); - -/** - * test when - * |backupTo| specified - * |tmpPath| not specified - * backup file exists - * destination file exists - * @result destination file will be backed up - */ -add_task(function* test_backupTo_option_with_backup_file() { - let DEFAULT_CONTENTS = "default contents" + Math.random(); - let WRITE_CONTENTS = "abc" + Math.random(); - let path = Path.join(Constants.Path.tmpDir, - "test_backupTo_option_with_backup_file.tmp"); - yield File.writeAtomic(path, DEFAULT_CONTENTS); - - yield File.writeAtomic(path + ".backup", new Uint8Array(1000)); - - yield File.writeAtomic(path, WRITE_CONTENTS, { backupTo: path + ".backup" }); - do_check_true((yield File.exists(path + ".backup"))); - let contents = yield File.read(path + ".backup"); - do_check_eq(DEFAULT_CONTENTS, (new TextDecoder()).decode(contents)); -}); - -add_task(function* cleanup() { - yield clearFiles(); -}); |