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_duration.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_duration.js')
-rw-r--r-- | toolkit/components/osfile/tests/xpcshell/test_duration.js | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/toolkit/components/osfile/tests/xpcshell/test_duration.js b/toolkit/components/osfile/tests/xpcshell/test_duration.js deleted file mode 100644 index 305c03da8..000000000 --- a/toolkit/components/osfile/tests/xpcshell/test_duration.js +++ /dev/null @@ -1,91 +0,0 @@ -var {OS} = Components.utils.import("resource://gre/modules/osfile.jsm", {}); -var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {}); - -/** - * Test optional duration reporting that can be used for telemetry. - */ -add_task(function* duration() { - Services.prefs.setBoolPref("toolkit.osfile.log", true); - // Options structure passed to a OS.File copy method. - let copyOptions = { - // This field should be overridden with the actual duration - // measurement. - outExecutionDuration: null - }; - let currentDir = yield OS.File.getCurrentDirectory(); - let pathSource = OS.Path.join(currentDir, "test_duration.js"); - let copyFile = pathSource + ".bak"; - function testOptions(options, name) { - do_print("Checking outExecutionDuration for operation: " + name); - do_print(name + ": Gathered method duration time: " + - options.outExecutionDuration + "ms"); - // Making sure that duration was updated. - do_check_eq(typeof options.outExecutionDuration, "number"); - do_check_true(options.outExecutionDuration >= 0); - }; - // Testing duration of OS.File.copy. - yield OS.File.copy(pathSource, copyFile, copyOptions); - testOptions(copyOptions, "OS.File.copy"); - yield OS.File.remove(copyFile); - - // Trying an operation where options are cloned. - let pathDest = OS.Path.join(OS.Constants.Path.tmpDir, - "osfile async test read writeAtomic.tmp"); - let tmpPath = pathDest + ".tmp"; - let readOptions = { - outExecutionDuration: null - }; - let contents = yield OS.File.read(pathSource, undefined, readOptions); - testOptions(readOptions, "OS.File.read"); - // Options structure passed to a OS.File writeAtomic method. - let writeAtomicOptions = { - // This field should be first initialized with the actual - // duration measurement then progressively incremented. - outExecutionDuration: null, - tmpPath: tmpPath - }; - yield OS.File.writeAtomic(pathDest, contents, writeAtomicOptions); - testOptions(writeAtomicOptions, "OS.File.writeAtomic"); - yield OS.File.remove(pathDest); - - do_print("Ensuring that we can use outExecutionDuration to accumulate durations"); - - let ARBITRARY_BASE_DURATION = 5; - copyOptions = { - // This field should now be incremented with the actual duration - // measurement. - outExecutionDuration: ARBITRARY_BASE_DURATION - }; - let backupDuration = ARBITRARY_BASE_DURATION; - // Testing duration of OS.File.copy. - yield OS.File.copy(pathSource, copyFile, copyOptions); - - do_check_true(copyOptions.outExecutionDuration >= backupDuration); - - backupDuration = copyOptions.outExecutionDuration; - yield OS.File.remove(copyFile, copyOptions); - do_check_true(copyOptions.outExecutionDuration >= backupDuration); - - // Trying an operation where options are cloned. - // Options structure passed to a OS.File writeAtomic method. - writeAtomicOptions = { - // This field should be overridden with the actual duration - // measurement. - outExecutionDuration: copyOptions.outExecutionDuration, - tmpPath: tmpPath - }; - backupDuration = writeAtomicOptions.outExecutionDuration; - - yield OS.File.writeAtomic(pathDest, contents, writeAtomicOptions); - do_check_true(copyOptions.outExecutionDuration >= backupDuration); - OS.File.remove(pathDest); - - // Testing an operation that doesn't take arguments at all - let file = yield OS.File.open(pathSource); - yield file.stat(); - yield file.close(); -}); - -function run_test() { - run_next_test(); -} |