Bug 1548770 - Better test for File.createFile(), r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D30612

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-05-10 09:25:01 +00:00
Родитель d293ec56c7
Коммит e9271044cf
1 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -1,4 +1,4 @@
async function run_test() {
add_task(async function() {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
do_get_profile();
@ -28,4 +28,13 @@ async function run_test() {
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");
});