Bug 1548770 - Better test for File.createFile(), r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 10 May 2019 09:25:01 +0000
changeset 473367 daa2837789242ad8e01798e97fc986509a2e680e
parent 473366 a098226e42117f59f17112ed7be9e39710e18681
child 473368 7b99b4edde300fb943804f5709064fba5e493a8e
push id35996
push userdvarga@mozilla.com
push dateFri, 10 May 2019 21:46:48 +0000
treeherdermozilla-central@362df4629f8f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1548770
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548770 - Better test for File.createFile(), r=smaug Differential Revision: https://phabricator.services.mozilla.com/D30612
dom/file/tests/test_createFile.js
--- a/dom/file/tests/test_createFile.js
+++ b/dom/file/tests/test_createFile.js
@@ -1,9 +1,9 @@
-async function run_test() {
+add_task(async function() {
   const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   do_get_profile();
 
   let existingFile = Services.dirsvc.QueryInterface(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
   existingFile.append("exists.js");
   existingFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
 
@@ -23,9 +23,18 @@ async function run_test() {
 
   ok(!unknownFile.exists(), unknownFile.path + " doesn't exist");
 
   let a = await File.createFromNsIFile(existingFile, { existenceCheck: false });
   ok(a.size != 0, "The size is correctly set");
 
   let b = await File.createFromNsIFile(unknownFile, { existenceCheck: false });
   ok(b.size == 0, "The size is 0 for unknown file");
-}
+
+  let c = await File.createFromNsIFile(existingFile, { existenceCheck: true });
+  ok(c.size != 0, "The size is correctly set");
+
+  let d = await File.createFromNsIFile(unknownFile, { existenceCheck: true }).then(_ => true, _ => false);
+  ok(d === false, "Exception thrown");
+
+  existingFile.remove(true);
+  ok(!existingFile.exists(), "exists.js doesn't exist anymore");
+});