Bug 1660015: Add IOUtils to privileged eslint environment configuration r=barret,zombie

This change makes eslint aware of the global IOUtils interface, such that it
may be used without having to access it from the window or otherwise declaring
the global in a special comment on a file-by-file basis.

Differential Revision: https://phabricator.services.mozilla.com/D87612
This commit is contained in:
Keefer Rourke 2020-08-26 15:31:24 +00:00
Родитель 62ed33101c
Коммит 000d8dcc94
9 изменённых файлов: 68 добавлений и 71 удалений

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

@ -3,8 +3,6 @@
"use strict";
/* global IOUtils */
const TEST_ROOT = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"http://example.com"

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

@ -1,7 +1,5 @@
// Utility functions.
/* global IOUtils */
Uint8Array.prototype.equals = function equals(other) {
if (this.byteLength !== other.byteLength) {
return false;

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

@ -37,7 +37,7 @@ self.onmessage = async function(msg) {
// Write a file.
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_numbers.tmp");
const bytes = Uint8Array.of(...new Array(50).keys());
const bytesWritten = await self.IOUtils.writeAtomic(tmpFileName, bytes);
const bytesWritten = await IOUtils.writeAtomic(tmpFileName, bytes);
is(
bytesWritten,
50,
@ -45,7 +45,7 @@ self.onmessage = async function(msg) {
);
// Read it back.
let fileContents = await self.IOUtils.read(tmpFileName);
let fileContents = await IOUtils.read(tmpFileName);
ok(
ObjectUtils.deepEqual(bytes, fileContents) &&
bytes.length == fileContents.length,
@ -53,7 +53,7 @@ self.onmessage = async function(msg) {
);
const tooManyBytes = bytes.length + 1;
fileContents = await self.IOUtils.read(tmpFileName, tooManyBytes);
fileContents = await IOUtils.read(tmpFileName, tooManyBytes);
ok(
ObjectUtils.deepEqual(bytes, fileContents) &&
fileContents.length == bytes.length,
@ -67,9 +67,9 @@ self.onmessage = async function(msg) {
const src = OS.Path.join(tmpDir, "test_move_file_src.tmp");
const dest = OS.Path.join(tmpDir, "test_move_file_dest.tmp");
const bytes = Uint8Array.of(...new Array(50).keys());
await self.IOUtils.writeAtomic(src, bytes);
await IOUtils.writeAtomic(src, bytes);
await self.IOUtils.move(src, dest);
await IOUtils.move(src, dest);
ok(
!(await fileExists(src)) && (await fileExists(dest)),
"IOUtils::move can move files from a worker"
@ -83,7 +83,7 @@ self.onmessage = async function(msg) {
const destFileName = OS.Path.join(tmpDir, "test_ioutils_copy.tmp");
await createFile(tmpFileName, "original");
await self.IOUtils.copy(tmpFileName, destFileName);
await IOUtils.copy(tmpFileName, destFileName);
ok(
(await fileExists(tmpFileName)) &&
(await fileHasTextContents(destFileName, "original")),
@ -95,7 +95,7 @@ self.onmessage = async function(msg) {
async function test_make_directory() {
const dir = OS.Path.join(tmpDir, "test_make_dir.tmp.d");
await self.IOUtils.makeDirectory(dir);
await IOUtils.makeDirectory(dir);
ok(
OS.File.stat(dir).isDir,
"IOUtils::makeDirectory can make a new directory from a worker"

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

@ -29,7 +29,7 @@
info("Test moving a file to a relative destination");
await Assert.rejects(
window.IOUtils.move(tmpFileName, dest),
IOUtils.move(tmpFileName, dest),
/Refusing to work with path\(.*\) because only absolute file paths are permitted/,
"IOUtils::move only works with absolute paths"
);
@ -48,7 +48,7 @@
await createFile(tmpFileName, "dest");
// Test.
info("Test move to new file in same directory");
await window.IOUtils.move(tmpFileName, destFileName);
await IOUtils.move(tmpFileName, destFileName);
info(`Moved ${tmpFileName} to ${destFileName}`);
ok(
!await fileExists(tmpFileName)
@ -61,7 +61,7 @@
await createFile(tmpFileName, "source");
// Test.
await Assert.rejects(
window.IOUtils.move(tmpFileName, destFileName, { noOverwrite: true }),
IOUtils.move(tmpFileName, destFileName, { noOverwrite: true }),
/Could not move source file\(.*\) to destination\(.*\) because the destination already exists and overwrites are not allowed/,
"IOUtils::move will refuse to move a file if overwrites are disabled"
);
@ -73,7 +73,7 @@
// Test.
info("Test move to existing file with overwrite");
await window.IOUtils.move(tmpFileName, destFileName, { noOverwrite: false });
await IOUtils.move(tmpFileName, destFileName, { noOverwrite: false });
ok(!await fileExists(tmpFileName), "IOUtils::move moved source");
ok(
await fileHasTextContents(destFileName, "source"),
@ -93,7 +93,7 @@
await createFile(tmpFileName);
// Test.
ok(!await fileOrDirExists(destDir), "Expected path not to exist");
await window.IOUtils.move(tmpFileName, dest);
await IOUtils.move(tmpFileName, dest);
ok(
!await fileExists(tmpFileName) && await fileExists(dest),
"IOUtils::move creates non-existing parents if needed"
@ -104,7 +104,7 @@
await createFile(tmpFileName);
// Test.
ok(await dirExists(destDir), `Expected ${destDir} to be a directory`);
await window.IOUtils.move(tmpFileName, dest);
await IOUtils.move(tmpFileName, dest);
ok(
!await fileExists(tmpFileName)
&& await fileExists(dest),
@ -115,7 +115,7 @@
info("Test move to existing directory without specifying leaf name.")
await createFile(tmpFileName);
// Test.
await window.IOUtils.move(tmpFileName, destDir);
await IOUtils.move(tmpFileName, destDir);
ok(await dirExists(destDir), `Expected ${destDir} to be a directory`);
ok(
!await fileExists(tmpFileName)
@ -134,7 +134,7 @@
const destDir = OS.Path.join(tmpDir, "test_move_dir_dest.tmp.d");
await createDir(srcDir);
// Test.
await window.IOUtils.move(srcDir, destDir);
await IOUtils.move(srcDir, destDir);
ok(
!await fileOrDirExists(srcDir) && await dirExists(destDir),
"IOUtils::move can rename directories"
@ -145,7 +145,7 @@
await createDir(srcDir);
await createFile(OS.Path.join(srcDir, "file.tmp"), "foo");
// Test.
await window.IOUtils.move(srcDir, destDir);
await IOUtils.move(srcDir, destDir);
const destFile = OS.Path.join(destDir, OS.Path.basename(srcDir), "file.tmp");
ok(
!await fileOrDirExists(srcDir)
@ -166,7 +166,7 @@
const notExistsDest = OS.Path.join(tmpDir, "not_exists_dest.tmp");
// Test.
await Assert.rejects(
window.IOUtils.move(notExistsSrc, notExistsDest),
IOUtils.move(notExistsSrc, notExistsDest),
/Could not move source file\(.*\) because it does not exist/,
"IOUtils::move throws if source file does not exist"
);
@ -183,7 +183,7 @@
await createDir(srcDir);
// Test.
await Assert.rejects(
window.IOUtils.move(srcDir, destFile),
IOUtils.move(srcDir, destFile),
/Could not move the source directory\(.*\) to the destination\(.*\) because the destination is not a directory/,
"IOUtils::move throws if try to move dir into an existing file"
);
@ -199,7 +199,7 @@
await createFile(tmpFileName, "original");
// Test.
info("Test copy to new file in same directory");
await window.IOUtils.copy(tmpFileName, destFileName);
await IOUtils.copy(tmpFileName, destFileName);
ok(
await fileExists(tmpFileName)
&& await fileHasTextContents(destFileName, "original"),
@ -211,7 +211,7 @@
await createFile(tmpFileName, "new contents");
// Test.
await Assert.rejects(
window.IOUtils.copy(tmpFileName, destFileName, { noOverwrite: true }),
IOUtils.copy(tmpFileName, destFileName, { noOverwrite: true }),
/Could not copy source file\(.*\) to destination\(.*\) because the destination already exists and overwrites are not allowed/,
"IOUtils::copy will refuse to copy to existing destination if overwrites are disabled"
);
@ -223,7 +223,7 @@
// Test.
info("Test copy to existing file with overwrite");
await window.IOUtils.copy(tmpFileName, destFileName, { noOverwrite: false });
await IOUtils.copy(tmpFileName, destFileName, { noOverwrite: false });
ok(await fileExists(tmpFileName), "IOUtils::copy retains source");
ok(
await fileHasTextContents(destFileName, "new contents"),
@ -243,7 +243,7 @@
await createFile(tmpFileName);
// Test.
ok(!await fileOrDirExists(destDir), "Expected path not to exist");
await window.IOUtils.copy(tmpFileName, dest);
await IOUtils.copy(tmpFileName, dest);
ok(
await fileExists(tmpFileName) && await fileExists(dest),
"IOUtils::copy creates non-existing parents if needed"
@ -254,7 +254,7 @@
await createFile(tmpFileName);
// Test.
ok(await dirExists(destDir), `Expected ${destDir} to be a directory`);
await window.IOUtils.copy(tmpFileName, dest);
await IOUtils.copy(tmpFileName, dest);
ok(
await fileExists(tmpFileName)
&& await fileExists(dest),
@ -265,7 +265,7 @@
info("Test copy file to existing directory without specifying leaf name")
await createFile(tmpFileName);
// Test.
await window.IOUtils.copy(tmpFileName, destDir);
await IOUtils.copy(tmpFileName, destDir);
ok(await dirExists(destDir), `Expected ${destDir} to be a directory`);
ok(
await fileExists(tmpFileName)
@ -284,7 +284,7 @@
const destDir = OS.Path.join(tmpDir, "test_copy_dir_dest.tmp.d");
await createDir(srcDir);
// Test.
await window.IOUtils.copy(srcDir, destDir, { recursive: true });
await IOUtils.copy(srcDir, destDir, { recursive: true });
ok(
await dirExists(srcDir) && await dirExists(destDir),
"IOUtils::copy can recursively copy entire directories"
@ -295,7 +295,7 @@
await createDir(srcDir);
await createFile(OS.Path.join(srcDir, "file.tmp"), "foo");
// Test.
await window.IOUtils.copy(srcDir, destDir, { recursive: true });
await IOUtils.copy(srcDir, destDir, { recursive: true });
const destFile = OS.Path.join(destDir, OS.Path.basename(srcDir), "file.tmp");
ok(
await dirExists(srcDir)
@ -316,7 +316,7 @@
const notExistsDest = OS.Path.join(tmpDir, "test_copy_not_exists_dest.tmp");
// Test.
await Assert.rejects(
window.IOUtils.copy(notExistsSrc, notExistsDest),
IOUtils.copy(notExistsSrc, notExistsDest),
/Could not copy source file\(.*\) because it does not exist/,
"IOUtils::copy throws if source file does not exist"
);
@ -333,7 +333,7 @@
await createDir(srcDir);
// Test.
await Assert.rejects(
window.IOUtils.copy(srcDir, destFile, { recursive: true }),
IOUtils.copy(srcDir, destFile, { recursive: true }),
/Could not copy the source directory\(.*\) to the destination\(.*\) because the destination is not a directory/,
"IOUtils::copy throws if try to move dir into an existing file"
);
@ -344,7 +344,7 @@
await createDir(srcDir);
// Test.
await Assert.rejects(
window.IOUtils.copy(srcDir, notExistsDest, { recursive: false }),
IOUtils.copy(srcDir, notExistsDest, { recursive: false }),
/Refused to copy source directory\(.*\) to the destination\(.*\)/,
"IOUtils::copy throws if try to copy a directory with { recursive: false }"
);

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

@ -25,20 +25,20 @@
add_task(async function test_make_directory() {
info("Test creating a new directory");
const newDirectoryName = OS.Path.join(tmpDir, "test_ioutils_new_dir.tmp.d");
await window.IOUtils.makeDirectory(newDirectoryName);
await IOUtils.makeDirectory(newDirectoryName);
ok(
await OS.File.exists(newDirectoryName),
"IOUtils::makeDirectory can create a new directory"
);
info("Test creating an existing directory");
await window.IOUtils.makeDirectory(newDirectoryName, { ignoreExisting: true });
await IOUtils.makeDirectory(newDirectoryName, { ignoreExisting: true });
ok(
await OS.File.exists(newDirectoryName),
"IOUtils::makeDirectory can ignore existing directories"
);
await Assert.rejects(
window.IOUtils.makeDirectory(newDirectoryName, { ignoreExisting: false }),
IOUtils.makeDirectory(newDirectoryName, { ignoreExisting: false }),
/Could not create directory because it already exists at .*/,
"IOUtils::makeDirectory can throw if the target dir exists"
)
@ -50,12 +50,12 @@
"test_ioutils_mkdir_child.tmp.d"
);
await Assert.rejects(
window.IOUtils.makeDirectory(nestedDirName, { createAncestors: false }),
IOUtils.makeDirectory(nestedDirName, { createAncestors: false }),
/Could not create directory at .* because the path has missing ancestor components/,
"IOUtils::makeDirectory can fail if the target is missing parents"
);
ok(!await OS.File.exists(nestedDirName), `Expected ${nestedDirName} not to exist`);
await window.IOUtils.makeDirectory(nestedDirName, { createAncestors: true });
await IOUtils.makeDirectory(nestedDirName, { createAncestors: true });
ok(
await OS.File.exists(nestedDirName),
"IOUtils::makeDirectory can create ancestors of the target directory"
@ -70,14 +70,14 @@
await createFile(notADirFileName);
await Assert.rejects(
window.IOUtils.makeDirectory(notADirFileName, { ignoreExisting: false }),
IOUtils.makeDirectory(notADirFileName, { ignoreExisting: false }),
/Could not create directory because the target file\(.*\) exists and is not a directory/,
"IOUtils::makeDirectory [ignoreExisting: false] throws when the target is an existing file"
);
ok(await fileExists(notADirFileName), `Expected ${notADirFileName} to exist`);
await Assert.rejects(
window.IOUtils.makeDirectory(notADirFileName, { ignoreExisting: true }),
IOUtils.makeDirectory(notADirFileName, { ignoreExisting: true }),
/Could not create directory because the target file\(.*\) exists and is not a directory/,
"IOUtils::makeDirectory [ignoreExisting: true] throws when the target is an existing file"
);

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

@ -25,7 +25,7 @@
add_task(async function test_read_failure() {
const doesNotExist = OS.Path.join(tmpDir, "does_not_exist.tmp");
await Assert.rejects(
window.IOUtils.read(doesNotExist),
IOUtils.read(doesNotExist),
/Could not open the file at .*/,
"IOUtils::read rejects when file does not exist"
);
@ -35,11 +35,11 @@
// Make a new file, and try to write to it with overwrites disabled.
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_overwrite.tmp");
const untouchableContents = new TextEncoder().encode("Can't touch this!\n");
await window.IOUtils.writeAtomic(tmpFileName, untouchableContents);
await IOUtils.writeAtomic(tmpFileName, untouchableContents);
const newContents = new TextEncoder().encode("Nah nah nah!\n");
await Assert.rejects(
window.IOUtils.writeAtomic(tmpFileName, newContents, {
IOUtils.writeAtomic(tmpFileName, newContents, {
noOverwrite: true,
}),
/Refusing to overwrite the file at */,
@ -50,7 +50,7 @@
"IOUtils::writeAtomic doesn't change target file when overwrite is refused"
);
const bytesWritten = await window.IOUtils.writeAtomic(
const bytesWritten = await IOUtils.writeAtomic(
tmpFileName,
newContents,
{ noOverwrite: false /* Default. */ }
@ -70,7 +70,7 @@
let destFileName = OS.Path.join(tmpDir, "test_write_with_backup_option.tmp");
let backupFileName = destFileName + ".backup";
let bytesWritten =
await window.IOUtils.writeAtomic(destFileName, fileContents, {
await IOUtils.writeAtomic(destFileName, fileContents, {
backupFile: backupFileName,
});
ok(
@ -91,7 +91,7 @@
let newFileContents = new TextEncoder().encode("New file contents");
ok(await fileExists(destFileName), `Expected ${destFileName} to exist`);
bytesWritten =
await window.IOUtils.writeAtomic(destFileName, newFileContents, {
await IOUtils.writeAtomic(destFileName, newFileContents, {
backupFile: backupFileName,
});
ok(
@ -118,7 +118,7 @@
let backupFileName = destFileName + ".backup";
let tmpFileName = OS.Path.join(tmpDir, "temp_file.tmp");
let bytesWritten =
await window.IOUtils.writeAtomic(destFileName, fileContents, {
await IOUtils.writeAtomic(destFileName, fileContents, {
backupFile: backupFileName,
tmpPath: tmpFileName,
});
@ -140,7 +140,7 @@
info("Test backup with tmp and backup file options, existing destination");
let newFileContents = new TextEncoder().encode("New file contents");
bytesWritten =
await window.IOUtils.writeAtomic(destFileName, newFileContents, {
await IOUtils.writeAtomic(destFileName, newFileContents, {
backupFile: backupFileName,
tmpPath: tmpFileName,
});
@ -166,7 +166,7 @@
add_task(async function test_partial_read() {
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_partial_read.tmp");
const bytes = Uint8Array.of(...new Array(50).keys());
const bytesWritten = await window.IOUtils.writeAtomic(tmpFileName, bytes);
const bytesWritten = await IOUtils.writeAtomic(tmpFileName, bytes);
is(
bytesWritten,
50,
@ -175,7 +175,7 @@
// Read just the first 10 bytes.
const first10 = bytes.slice(0, 10);
const bytes10 = await window.IOUtils.read(tmpFileName, 10);
const bytes10 = await IOUtils.read(tmpFileName, 10);
ok(
ObjectUtils.deepEqual(bytes10, first10),
"IOUtils::read can read part of a file, up to specified max bytes"
@ -183,7 +183,7 @@
// Trying to explicitly read nothing isn't useful, but it should still
// succeed.
const bytes0 = await window.IOUtils.read(tmpFileName, 0);
const bytes0 = await IOUtils.read(tmpFileName, 0);
is(bytes0.length, 0, "IOUtils::read can read 0 bytes");
await cleanup(tmpFileName);
@ -194,7 +194,7 @@
// succeed.
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_empty.tmp");
const emptyByteArray = new Uint8Array(0);
const bytesWritten = await window.IOUtils.writeAtomic(
const bytesWritten = await IOUtils.writeAtomic(
tmpFileName,
emptyByteArray
);
@ -202,11 +202,11 @@
// Trying to explicitly read nothing isn't useful, but it should still
// succeed.
const bytes0 = await window.IOUtils.read(tmpFileName, 0);
const bytes0 = await IOUtils.read(tmpFileName, 0);
is(bytes0.length, 0, "IOUtils::read can read 0 bytes");
// Implicitly try to read nothing.
const nothing = await window.IOUtils.read(tmpFileName);
const nothing = await IOUtils.read(tmpFileName);
is(nothing.length, 0, "IOUtils:: read can read empty files");
await cleanup(tmpFileName);
@ -217,7 +217,7 @@
info("Test writing to a new binary file");
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_numbers.tmp");
const bytes = Uint8Array.of(...new Array(50).keys());
const bytesWritten = await window.IOUtils.writeAtomic(tmpFileName, bytes);
const bytesWritten = await IOUtils.writeAtomic(tmpFileName, bytes);
is(
bytesWritten,
50,
@ -226,7 +226,7 @@
// Read it back.
info("Test reading a binary file");
let fileContents = await window.IOUtils.read(tmpFileName);
let fileContents = await IOUtils.read(tmpFileName);
ok(
ObjectUtils.deepEqual(bytes, fileContents) &&
bytes.length == fileContents.length,
@ -234,7 +234,7 @@
);
const tooManyBytes = bytes.length + 1;
fileContents = await window.IOUtils.read(tmpFileName, tooManyBytes);
fileContents = await IOUtils.read(tmpFileName, tooManyBytes);
ok(
ObjectUtils.deepEqual(bytes, fileContents) &&
fileContents.length == bytes.length,
@ -251,7 +251,7 @@
info("Test writing a file at a relative destination");
await Assert.rejects(
window.IOUtils.writeAtomic(tmpFileName, bytes),
IOUtils.writeAtomic(tmpFileName, bytes),
/Refusing to work with path\(.*\) because only absolute file paths are permitted/,
"IOUtils::writeAtomic only works with absolute paths"
);
@ -262,7 +262,7 @@
info("Test reading a file at a relative destination");
await Assert.rejects(
window.IOUtils.read(tmpFileName),
IOUtils.read(tmpFileName),
/Refusing to work with path\(.*\) because only absolute file paths are permitted/,
"IOUtils::writeAtomic only works with absolute paths"
);

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

@ -25,18 +25,18 @@
add_task(async function test_create_and_remove_file() {
info("Test creating and removing a single file");
const tmpFileName = OS.Path.join(tmpDir, "test_ioutils_create_and_remove.tmp");
await window.IOUtils.writeAtomic(tmpFileName, new Uint8Array(0));
await IOUtils.writeAtomic(tmpFileName, new Uint8Array(0));
ok(await fileExists(tmpFileName), `Expected file ${tmpFileName} to exist`);
await window.IOUtils.remove(tmpFileName);
await IOUtils.remove(tmpFileName);
ok(!await fileExists(tmpFileName), "IOUtils::remove can remove files");
info("Test creating and removing an empty directory");
const tmpDirName = OS.Path.join(tmpDir, "test_ioutils_create_and_remove.tmp.d");
await window.IOUtils.makeDirectory(tmpDirName);
await IOUtils.makeDirectory(tmpDirName);
ok(await dirExists(tmpDirName), `Expected directory ${tmpDirName} to exist`);
await window.IOUtils.remove(tmpDirName);
await IOUtils.remove(tmpDirName);
ok(!await dirExists(tmpDirName), "IOUtils::remove can remove empty directories");
});
@ -44,11 +44,11 @@
const tmpFileName = OS.Path.join(tmpDir, "test_ioutil_remove_non_existing.tmp");
ok(!await fileExists(tmpFileName), `Expected file ${tmpFileName} not to exist`);
await window.IOUtils.remove(tmpFileName, { ignoreAbsent: true });
await IOUtils.remove(tmpFileName, { ignoreAbsent: true });
ok(!await fileExists(tmpFileName), "IOUtils::remove can ignore missing files without error");
await Assert.rejects(
window.IOUtils.remove(tmpFileName, { ignoreAbsent: false }),
IOUtils.remove(tmpFileName, { ignoreAbsent: false }),
/Could not remove the file at .* because it does not exist/,
"IOUtils::remove can throw an error when target file is missing"
);
@ -74,12 +74,12 @@
);
await Assert.rejects(
window.IOUtils.remove(tmpParentDir, { recursive: false }),
IOUtils.remove(tmpParentDir, { recursive: false }),
/Could not remove the non-empty directory at .*/,
"IOUtils::remove fails if non-recursively removing directory with contents"
);
await window.IOUtils.remove(tmpParentDir, { recursive: true });
await IOUtils.remove(tmpParentDir, { recursive: true });
ok(
!await dirExists(tmpParentDir),
"IOUtils::remove can recursively remove a directory"

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

@ -27,7 +27,7 @@
const emptyFileName = OS.Path.join(tmpDir, "test_stat_empty.tmp");
await createFile(emptyFileName);
const emptyFileInfo = await window.IOUtils.stat(emptyFileName);
const emptyFileInfo = await IOUtils.stat(emptyFileName);
is(emptyFileInfo.size, 0, "IOUtils::stat can get correct (empty) file size");
is(emptyFileInfo.path, emptyFileName, "IOUtils::stat result contains the path");
is(emptyFileInfo.type, "regular", "IOUtils::stat can stat regular (empty) files");
@ -42,7 +42,7 @@
const bytes = Uint8Array.of(...new Array(50).keys());
await createFile(tempFileName, bytes);
const fileInfo = await window.IOUtils.stat(tempFileName);
const fileInfo = await IOUtils.stat(tempFileName);
is(fileInfo.size, 50, "IOUtils::stat can get correct file size");
is(fileInfo.path, tempFileName, "IOUtils::stat result contains the path");
is(fileInfo.type, "regular", "IOUtils::stat can stat regular files");
@ -56,7 +56,7 @@
const tempDirName = OS.Path.join(tmpDir, "test_stat_dir.tmp.d");
await OS.File.makeDir(tempDirName);
const dirInfo = await window.IOUtils.stat(tempDirName);
const dirInfo = await IOUtils.stat(tempDirName);
is(dirInfo.size, -1, "IOUtils::stat reports -1 size for directories")
is(fileInfo.path, tempFileName, "IOUtils::stat result contains the path");
is(fileInfo.type, "regular", "IOUtils::stat can stat directories");
@ -74,7 +74,7 @@
const notExistsFile = OS.Path.join(tmpDir, "test_stat_not_exists.tmp");
await Assert.rejects(
window.IOUtils.stat(notExistsFile),
IOUtils.stat(notExistsFile),
/Could not stat file\(.*\) because it does not exist/,
"IOUtils::stat throws if the target file does not exist"
);

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

@ -311,6 +311,7 @@ module.exports = {
InstallTriggerImpl: false,
IntersectionObserver: false,
IntersectionObserverEntry: false,
IOUtils: false,
JSProcessActorChild: false,
JSProcessActorParent: false,
JSWindowActorChild: false,