deleted file mode 100644
--- a/toolkit/components/osfile/.eslintrc.js
+++ /dev/null
@@ -1,14 +0,0 @@
-"use strict";
-
-module.exports = {
- "rules": {
- "consistent-return": "off",
- "no-irregular-whitespace": "off",
- "no-lone-blocks": "off",
- "no-redeclare": "off",
- "no-self-assign": "off",
- "no-shadow": "off",
- "no-unused-vars": "off",
- "object-shorthand": "off",
- }
-};
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -256,31 +256,31 @@ var Scheduler = this.Scheduler = {
return this._worker;
},
_worker: null,
/**
* Restart the OS.File worker killer timer.
*/
- restartTimer: function(arg) {
+ restartTimer(arg) {
this.hasRecentActivity = true;
},
/**
* Shutdown OS.File.
*
* @param {*} options
* - {boolean} shutdown If |true|, reject any further request. Otherwise,
* further requests will resurrect the worker.
* - {boolean} reset If |true|, instruct the worker to shutdown if this
* would not cause leaks. Otherwise, assume that the worker will be shutdown
* through some other mean.
*/
- kill: function({shutdown, reset}) {
+ kill({shutdown, reset}) {
// Grab the kill queue to make sure that we
// cannot be interrupted by another call to `kill`.
let killQueue = this._killQueue;
// Deactivate the queue, to ensure that no message is sent
// to an obsolete worker (we reactivate it in the `finally`).
// This needs to be done right now so that we maintain relative
// ordering with calls to post(), etc.
@@ -377,17 +377,17 @@ var Scheduler = this.Scheduler = {
* Push a task at the end of the queue.
*
* @param {function} code A function returning a Promise.
* This function will be executed once all the previously
* pushed tasks have completed.
* @return {Promise} A promise with the same behavior as
* the promise returned by |code|.
*/
- push: function(code) {
+ push(code) {
let promise = this.queue.then(code);
// By definition, |this.queue| can never reject.
this.queue = promise.catch(() => undefined);
// Fork |promise| to ensure that uncaught errors are reported
return promise.then();
},
/**
@@ -477,17 +477,17 @@ var Scheduler = this.Scheduler = {
});
},
/**
* Post Telemetry statistics.
*
* This is only useful on first launch.
*/
- _updateTelemetry: function() {
+ _updateTelemetry() {
let worker = this.worker;
let workerTimeStamps = worker.workerTimeStamps;
if (!workerTimeStamps) {
// If the first call to OS.File results in an uncaught errors,
// the timestamps are absent. As this case is a developer error,
// let's not waste time attempting to extract telemetry from it.
return;
}
@@ -1265,20 +1265,20 @@ var DirectoryIterator = function Directo
*/
this.__itmsg = Scheduler.post(
"new_DirectoryIterator", [Type.path.toMsg(path), options],
path
);
this._isClosed = false;
};
DirectoryIterator.prototype = {
- iterator: function() {
+ iterator() {
return this;
},
- __iterator__: function() {
+ __iterator__() {
return this;
},
// Once close() is called, _itmsg should reject with a
// StopIteration. However, we don't want to create the promise until
// it's needed because it might never be used. In that case, we
// would get a warning on the console.
get _itmsg() {
@@ -1476,17 +1476,17 @@ this.OS.Shared = {
return SharedAll.Config.DEBUG = x;
}
};
Object.freeze(this.OS.Shared);
this.OS.Path = Path;
// Returns a resolved promise when all the queued operation have been completed.
Object.defineProperty(OS.File, "queue", {
- get: function() {
+ get() {
return Scheduler.queue;
}
});
// `true` if this is a content process, `false` otherwise.
// It would be nicer to go through `Services.appInfo`, but some tests need to be
// able to replace that field with a custom implementation before it is first
// called.
@@ -1495,17 +1495,17 @@ const isContent = Components.classes["@m
/**
* Shutdown barriers, to let clients register to be informed during shutdown.
*/
var Barriers = {
shutdown: new AsyncShutdown.Barrier("OS.File: Waiting for clients before full shutdown"),
/**
* Return the shutdown state of OS.File
*/
- getDetails: function() {
+ getDetails() {
let result = {
launched: Scheduler.launched,
shutdown: Scheduler.shutdown,
worker: !!Scheduler._worker,
pendingReset: !!Scheduler.resetTimer,
latestSent: Scheduler.Debugging.latestSent,
latestReceived: Scheduler.Debugging.latestReceived,
messagesSent: Scheduler.Debugging.messagesSent,
--- a/toolkit/components/osfile/modules/osfile_async_worker.js
+++ b/toolkit/components/osfile/modules/osfile_async_worker.js
@@ -54,44 +54,44 @@ if (this.Components) {
this._idgen = 0;
// A map from id to resource
this._map = new Map();
};
ResourceTracker.prototype = {
/**
* Get a resource from its unique identifier.
*/
- get: function(id) {
+ get(id) {
let result = this._map.get(id);
if (result == null) {
return result;
}
return result.resource;
},
/**
* Remove a resource from its unique identifier.
*/
- remove: function(id) {
+ remove(id) {
if (!this._map.has(id)) {
throw new Error("Cannot find resource id " + id);
}
this._map.delete(id);
},
/**
* Add a resource, return a new unique identifier
*
* @param {*} resource A resource.
* @param {*=} info Optional information. For debugging purposes.
*
* @return {*} A unique identifier. For the moment, this is a number,
* but this might not remain the case forever.
*/
- add: function(resource, info) {
+ add(resource, info) {
let id = this._idgen++;
- this._map.set(id, {resource: resource, info: info});
+ this._map.set(id, {resource, info});
return id;
},
/**
* Return a list of all open resources i.e. the ones still present in
* ResourceTracker's _map.
*/
listOpenedResources: function listOpenedResources() {
return Array.from(this._map, ([id, resource]) => resource.info.path);
@@ -149,31 +149,31 @@ if (this.Components) {
* The agent.
*
* It is in charge of performing method-specific deserialization
* of messages, calling the function/method of OS.File and serializing
* back the results.
*/
let Agent = {
// Update worker's OS.Shared.DEBUG flag message from controller.
- SET_DEBUG: function(aDEBUG) {
+ SET_DEBUG(aDEBUG) {
SharedAll.Config.DEBUG = aDEBUG;
},
// Return worker's current OS.Shared.DEBUG value to controller.
// Note: This is used for testing purposes.
- GET_DEBUG: function() {
+ GET_DEBUG() {
return SharedAll.Config.DEBUG;
},
/**
* Execute shutdown sequence, returning data on leaked file descriptors.
*
* @param {bool} If |true|, kill the worker if this would not cause
* leaks.
*/
- Meta_shutdown: function(kill) {
+ Meta_shutdown(kill) {
let result = {
openedFiles: OpenedFiles.listOpenedResources(),
openedDirectoryIterators: OpenedDirectoryIterators.listOpenedResources(),
killed: false // Placeholder
};
// Is it safe to kill the worker?
let safe = result.openedFiles.length == 0
@@ -264,17 +264,17 @@ if (this.Components) {
if (options.tmpPath) {
options.tmpPath = Type.path.fromMsg(options.tmpPath);
}
return File.writeAtomic(Type.path.fromMsg(path),
Type.voidptr_t.fromMsg(buffer),
options
);
},
- removeDir: function(path, options) {
+ removeDir(path, options) {
return File.removeDir(Type.path.fromMsg(path), options);
},
new_DirectoryIterator: function new_DirectoryIterator(path, options) {
let directoryPath = Type.path.fromMsg(path);
let iterator = new File.DirectoryIterator(directoryPath, options);
return OpenedDirectoryIterators.add(iterator, {
// Adding path information to keep track of opened directory
// iterators to report leaks when debugging.
--- a/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
+++ b/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
@@ -104,17 +104,17 @@ exports.Constants = OS.Constants;
// Define a lazy getter for a property
var defineLazyGetter = function defineLazyGetter(object, name, getter) {
Object.defineProperty(object, name, {
configurable: true,
get: function lazy() {
delete this[name];
let value = getter.call(this);
Object.defineProperty(object, name, {
- value: value
+ value
});
return value;
}
});
};
exports.defineLazyGetter = defineLazyGetter;
@@ -208,20 +208,20 @@ exports.LOG = LOG;
* reference instead of copying.
*/
var clone = function(object, refs = []) {
let result = {};
// Make a reference between result[key] and object[key].
let refer = function refer(result, key, object) {
Object.defineProperty(result, key, {
enumerable: true,
- get: function() {
+ get() {
return object[key];
},
- set: function(value) {
+ set(value) {
object[key] = value;
}
});
};
for (let k in object) {
if (refs.indexOf(k) < 0) {
result[k] = object[k];
} else {
@@ -296,17 +296,17 @@ Type.prototype = {
get in_ptr() {
delete this.in_ptr;
let ptr_t = new PtrType(
"[in] " + this.name + "*",
this.implementation.ptr,
this);
Object.defineProperty(this, "in_ptr",
{
- get: function() {
+ get() {
return ptr_t;
}
});
return ptr_t;
},
/**
* A pointer/array used to receive data from the foreign function.
@@ -314,17 +314,17 @@ Type.prototype = {
get out_ptr() {
delete this.out_ptr;
let ptr_t = new PtrType(
"[out] " + this.name + "*",
this.implementation.ptr,
this);
Object.defineProperty(this, "out_ptr",
{
- get: function() {
+ get() {
return ptr_t;
}
});
return ptr_t;
},
/**
* A pointer/array used to both pass data to the foreign function
@@ -336,17 +336,17 @@ Type.prototype = {
get inout_ptr() {
delete this.inout_ptr;
let ptr_t = new PtrType(
"[inout] " + this.name + "*",
this.implementation.ptr,
this);
Object.defineProperty(this, "inout_ptr",
{
- get: function() {
+ get() {
return ptr_t;
}
});
return ptr_t;
},
/**
* Attach a finalizer to a type.
@@ -860,17 +860,17 @@ HollowStructure.prototype = {
" already has a field at offset " + offset);
}
if (offset + type.size > this.size) {
throw new Error("HollowStructure " + this.name +
" cannot place a value of type " + type +
" at offset " + offset +
" without exceeding its size of " + this.size);
}
- let field = {name: name, type: type};
+ let field = {name, type};
this.offset_to_field_info[offset] = field;
},
/**
* Create a pseudo-field that will only serve as padding.
*
* @param {number} size The number of bytes in the field.
* @return {Object} An association field-name => field-type,
@@ -986,17 +986,17 @@ Library.prototype = Object.freeze({
Object.defineProperty(this, "library", {
value: library
});
Object.freeze(this);
return library;
}
let error = new Error("Could not open library " + this.name);
Object.defineProperty(this, "library", {
- get: function() {
+ get() {
throw error;
}
});
Object.freeze(this);
throw error;
},
/**
@@ -1005,20 +1005,20 @@ Library.prototype = Object.freeze({
* @param {object} The object containing the function as a field.
* @param {string} The name of the field containing the function.
* @param {string} symbol The name of the function, as defined in the
* library.
* @param {ctypes.abi} abi The abi to use, or |null| for default.
* @param {Type} returnType The type of values returned by the function.
* @param {...Type} argTypes The type of arguments to the function.
*/
- declareLazyFFI: function(object, field, ...args) {
+ declareLazyFFI(object, field, ...args) {
let lib = this;
Object.defineProperty(object, field, {
- get: function() {
+ get() {
delete this[field];
let ffi = declareFFI(lib.library, ...args);
if (ffi) {
return this[field] = ffi;
}
return undefined;
},
configurable: true,
@@ -1032,20 +1032,20 @@ Library.prototype = Object.freeze({
* @param {object} The object containing the function as a field.
* @param {string} The name of the field containing the function.
* @param {string} symbol The name of the function, as defined in the
* library.
* @param {ctypes.abi} abi The abi to use, or |null| for default.
* @param {ctypes.CType} returnType The type of values returned by the function.
* @param {...ctypes.CType} argTypes The type of arguments to the function.
*/
- declareLazy: function(object, field, ...args) {
+ declareLazy(object, field, ...args) {
let lib = this;
Object.defineProperty(object, field, {
- get: function() {
+ get() {
delete this[field];
let ffi = lib.library.declare(...args);
if (ffi) {
return this[field] = ffi;
}
return undefined;
},
configurable: true,
@@ -1062,20 +1062,20 @@ Library.prototype = Object.freeze({
* @param {object} The object containing the function as a field.
* @param {string} The name of the field containing the function.
* @param {string} symbol The name of the function, as defined in the
* library.
* @param {ctypes.abi} abi The abi to use, or |null| for default.
* @param {ctypes.CType} returnType The type of values returned by the function.
* @param {...ctypes.CType} argTypes The type of arguments to the function.
*/
- declareLazyWithFallback: function(fallbacklibrary, object, field, ...args) {
+ declareLazyWithFallback(fallbacklibrary, object, field, ...args) {
let lib = this;
Object.defineProperty(object, field, {
- get: function() {
+ get() {
delete this[field];
try {
let ffi = lib.library.declare(...args);
if (ffi) {
return this[field] = ffi;
}
} catch (ex) {
// Use the fallback library and get the symbol from there.
@@ -1084,17 +1084,17 @@ Library.prototype = Object.freeze({
}
return undefined;
},
configurable: true,
enumerable: true
});
},
- toString: function() {
+ toString() {
return "[Library " + this.name + "]";
}
});
exports.Library = Library;
/**
* Declare a function through js-ctypes
*
@@ -1121,17 +1121,16 @@ var declareFFI = function declareFFI(lib
// Note: This is the only known manner of checking whether an object
// is an abi.
throw new TypeError("declareFFI expects as second argument an abi or null");
}
if (!returnType.importFromC) {
throw new TypeError("declareFFI expects as third argument an instance of Type");
}
let signature = [symbol, abi];
- let argtypes = [];
for (let i = 3; i < arguments.length; ++i) {
let current = arguments[i];
if (!current) {
throw new TypeError("Missing type for argument " + ( i - 3 ) +
" of symbol " + symbol);
}
if (!current.implementation) {
throw new TypeError("Missing implementation for argument " + (i - 3)
@@ -1171,17 +1170,17 @@ exports.declareFFI = declareFFI;
* @param {string} symbol The name of the function, as defined in the
* library.
* @param {ctypes.abi} abi The abi to use, or |null| for default.
* @param {Type} returnType The type of values returned by the function.
* @param {...Type} argTypes The type of arguments to the function.
*/
function declareLazyFFI(object, field, ...declareFFIArgs) {
Object.defineProperty(object, field, {
- get: function() {
+ get() {
delete this[field];
let ffi = declareFFI(...declareFFIArgs);
if (ffi) {
return this[field] = ffi;
}
return undefined;
},
configurable: true,
@@ -1199,17 +1198,17 @@ exports.declareLazyFFI = declareLazyFFI;
* @param {string} symbol The name of the function, as defined in the
* library.
* @param {ctypes.abi} abi The abi to use, or |null| for default.
* @param {ctypes.CType} returnType The type of values returned by the function.
* @param {...ctypes.CType} argTypes The type of arguments to the function.
*/
function declareLazy(object, field, lib, ...declareArgs) {
Object.defineProperty(object, field, {
- get: function() {
+ get() {
delete this[field];
try {
let ffi = lib.declare(...declareArgs);
return this[field] = ffi;
} catch (ex) {
// The symbol doesn't exist
return undefined;
}
@@ -1274,41 +1273,41 @@ exports.OSError = OSError;
// /////////////////// Temporary boilerplate
// Boilerplate, to simplify the transition to require()
// Do not rely upon this symbol, it will disappear with
// bug 883050.
exports.OS = {
Constants: exports.Constants,
Shared: {
- LOG: LOG,
- clone: clone,
- Type: Type,
- HollowStructure: HollowStructure,
+ LOG,
+ clone,
+ Type,
+ HollowStructure,
Error: OSError,
- declareFFI: declareFFI,
- projectValue: projectValue,
- isTypedArray: isTypedArray,
- defineLazyGetter: defineLazyGetter
+ declareFFI,
+ projectValue,
+ isTypedArray,
+ defineLazyGetter
}
};
Object.defineProperty(exports.OS.Shared, "DEBUG", {
- get: function() {
+ get() {
return Config.DEBUG;
},
- set: function(x) {
+ set(x) {
return Config.DEBUG = x;
}
});
Object.defineProperty(exports.OS.Shared, "TEST", {
- get: function() {
+ get() {
return Config.TEST;
},
- set: function(x) {
+ set(x) {
return Config.TEST = x;
}
});
// /////////////////// Permanent boilerplate
if (typeof Components != "undefined") {
this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
--- a/toolkit/components/osfile/modules/osfile_shared_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_shared_front.jsm
@@ -17,17 +17,17 @@ if (typeof Components != "undefined") {
}
(function(exports) {
var SharedAll =
require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
var Path = require("resource://gre/modules/osfile/ospath.jsm");
var Lz4 =
require("resource://gre/modules/lz4.js");
-var LOG = SharedAll.LOG.bind(SharedAll, "Shared front-end");
+SharedAll.LOG.bind(SharedAll, "Shared front-end");
var clone = SharedAll.clone;
/**
* Code shared by implementations of File.
*
* @param {*} fd An OS-specific file handle.
* @param {string} path File path of the file handle, used for error-reporting.
* @constructor
@@ -147,17 +147,17 @@ AbstractFile.openUnique = function openU
let maxAttempts = options.maxAttempts || 99;
let humanReadable = !!options.humanReadable;
const HEX_RADIX = 16;
// We produce HEX numbers between 0 and 2^24 - 1.
const MAX_HEX_NUMBER = 16777215;
try {
return {
- path: path,
+ path,
file: OS.File.open(path, mode)
};
} catch (ex) {
if (ex instanceof OS.File.Error && ex.becauseExists) {
for (let i = 0; i < maxAttempts; ++i) {
try {
if (humanReadable) {
uniquePath = Path.join(dirName, fileName + "-" + (i + 1) + suffix);
@@ -174,16 +174,17 @@ AbstractFile.openUnique = function openU
// keep trying ...
} else {
throw ex;
}
}
}
throw OS.File.Error.exists("could not find an unused file name.", path);
}
+ throw ex;
}
};
/**
* Code shared by iterators.
*/
AbstractFile.AbstractIterator = function AbstractIterator() {
};
--- a/toolkit/components/osfile/modules/osfile_unix_allthreads.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_allthreads.jsm
@@ -32,17 +32,17 @@ if (typeof Components != "undefined") {
this.exports = {};
} else if (typeof module != "undefined" && typeof require != "undefined") {
// Module is loaded with require()
SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
} else {
throw new Error("Please open this module with Component.utils.import or with require()");
}
-var LOG = SharedAll.LOG.bind(SharedAll, "Unix", "allthreads");
+SharedAll.LOG.bind(SharedAll, "Unix", "allthreads");
var Const = SharedAll.Constants.libc;
// Open libc
var libc = new SharedAll.Library("libc",
"libc.so", "libSystem.B.dylib", "a.out");
exports.libc = libc;
// Define declareFFI
--- a/toolkit/components/osfile/modules/osfile_unix_back.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_back.jsm
@@ -1,15 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/chrome-worker, node */
/* global OS */
+// eslint-disable-next-line no-lone-blocks
{
if (typeof Components != "undefined") {
// We do not wish osfile_unix_back.jsm to be used directly as a main thread
// module yet. When time comes, it will be loaded by a combination of
// a main thread front-end/worker thread implementation that makes sure
// that we are not executing synchronous IO code in the main thread.
throw new Error("osfile_unix_back.jsm cannot be used from the main thread yet");
@@ -19,40 +20,39 @@
if (exports.OS && exports.OS.Unix && exports.OS.Unix.File) {
return; // Avoid double initialization
}
let SharedAll =
require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
let SysAll =
require("resource://gre/modules/osfile/osfile_unix_allthreads.jsm");
- let LOG = SharedAll.LOG.bind(SharedAll, "Unix", "back");
+ SharedAll.LOG.bind(SharedAll, "Unix", "back");
let libc = SysAll.libc;
let Const = SharedAll.Constants.libc;
/**
* Initialize the Unix module.
*
* @param {function=} declareFFI
*/
// FIXME: Both |init| and |aDeclareFFI| are deprecated, we should remove them
let init = function init(aDeclareFFI) {
- let declareFFI;
if (aDeclareFFI) {
- declareFFI = aDeclareFFI.bind(null, libc);
+ aDeclareFFI.bind(null, libc);
} else {
- declareFFI = SysAll.declareFFI;
+ SysAll.declareFFI;
}
- let declareLazyFFI = SharedAll.declareLazyFFI;
+ SharedAll.declareLazyFFI;
// Initialize types that require additional OS-specific
// support - either finalization or matching against
// OS-specific constants.
let Type = Object.create(SysAll.Type);
- let SysFile = exports.OS.Unix.File = { Type: Type };
+ let SysFile = exports.OS.Unix.File = { Type };
/**
* A file descriptor.
*/
Type.fd = Type.int.withName("fd");
Type.fd.importFromC = function importFromC(fd_int) {
return ctypes.CDataFinalizer(fd_int, SysFile._close);
};
--- a/toolkit/components/osfile/modules/osfile_unix_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_front.jsm
@@ -7,16 +7,17 @@
* Unix implementation.
*
* This front-end is meant to be imported by a worker thread.
*/
/* eslint-env mozilla/chrome-worker, node */
/* global OS */
+// eslint-disable-next-line no-lone-blocks
{
if (typeof Components != "undefined") {
// We do not wish osfile_unix_front.jsm to be used directly as a main thread
// module yet.
throw new Error("osfile_unix_front.jsm cannot be used from the main thread yet");
}
(function(exports) {
@@ -26,17 +27,17 @@
if (exports.OS && exports.OS.File) {
return; // Avoid double-initialization
}
let SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
let Path = require("resource://gre/modules/osfile/ospath.jsm");
let SysAll = require("resource://gre/modules/osfile/osfile_unix_allthreads.jsm");
exports.OS.Unix.File._init();
- let LOG = SharedAll.LOG.bind(SharedAll, "Unix front-end");
+ SharedAll.LOG.bind(SharedAll, "Unix front-end");
let Const = SharedAll.Constants.libc;
let UnixFile = exports.OS.Unix.File;
let Type = UnixFile.Type;
/**
* Representation of a file.
*
* You generally do not need to call this constructor yourself. Rather,
@@ -217,17 +218,17 @@
* numeric, milliseconds since epoch. If omitted or null, then the current
* date will be used.
*
* @throws {TypeError} In case of invalid parameters.
* @throws {OS.File.Error} In case of I/O error.
*/
if (SharedAll.Constants.Sys.Name != "Android") {
File.prototype.setDates = function(accessDate, modificationDate) {
- let {value, ptr} = datesToTimevals(accessDate, modificationDate);
+ let { /* value, */ ptr} = datesToTimevals(accessDate, modificationDate);
throw_on_negative("setDates",
UnixFile.futimes(this.fd, ptr),
this._path);
};
}
/**
* Flushes the file's buffers and causes all buffered data
@@ -550,17 +551,16 @@
if (!pump_buffer || pump_buffer.length < bufSize) {
pump_buffer = new (ctypes.ArrayType(ctypes.char))(bufSize);
}
let read = source._read.bind(source);
let write = dest._write.bind(dest);
// Perform actual copy
let total_read = 0;
while (true) {
- let chunk_size = Math.min(nbytes, bufSize);
let bytes_just_read = read(pump_buffer, bufSize);
if (bytes_just_read == 0) {
return total_read;
}
total_read += bytes_just_read;
let bytes_written = 0;
do {
bytes_written += write(
@@ -641,30 +641,29 @@
pump = pump_userland;
}
// Implement |copy| using |pump|.
// This implementation would require some work before being able to
// copy directories
File.copy = function copy(sourcePath, destPath, options = {}) {
let source, dest;
- let result;
try {
source = File.open(sourcePath);
// Need to open the output file with |append:false|, or else |splice|
// won't work.
if (options.noOverwrite) {
dest = File.open(destPath, {create: true, append: false});
} else {
dest = File.open(destPath, {trunc: true, append: false});
}
if (options.unixUserland) {
- result = pump_userland(source, dest, options);
+ pump_userland(source, dest, options);
} else {
- result = pump(source, dest, options);
+ pump(source, dest, options);
}
} catch (x) {
if (dest) {
dest.close();
}
if (source) {
source.close();
}
@@ -997,17 +996,17 @@
* @param {Date,number=} modificationDate The last modification date. If
* numeric, milliseconds since epoch. If omitted or null, then the current
* date will be used.
*
* @throws {TypeError} In case of invalid paramters.
* @throws {OS.File.Error} In case of I/O error.
*/
File.setDates = function setDates(path, accessDate, modificationDate) {
- let {value, ptr} = datesToTimevals(accessDate, modificationDate);
+ let {/* value, */ ptr} = datesToTimevals(accessDate, modificationDate);
throw_on_negative("setDates",
UnixFile.utimes(path, ptr),
path);
};
File.read = exports.OS.Shared.AbstractFile.read;
File.writeAtomic = exports.OS.Shared.AbstractFile.writeAtomic;
File.openUnique = exports.OS.Shared.AbstractFile.openUnique;
@@ -1077,20 +1076,20 @@
path
);
};
/**
* Get/set the current directory.
*/
Object.defineProperty(File, "curDir", {
- set: function(path) {
+ set(path) {
this.setCurrentDirectory(path);
},
- get: function() {
+ get() {
return this.getCurrentDirectory();
}
}
);
// Utility functions
/**
--- a/toolkit/components/osfile/modules/osfile_win_allthreads.jsm
+++ b/toolkit/components/osfile/modules/osfile_win_allthreads.jsm
@@ -32,17 +32,17 @@ if (typeof Components != "undefined") {
this.exports = {};
} else if (typeof module != "undefined" && typeof require != "undefined") {
// Module is loaded with require()
SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
} else {
throw new Error("Please open this module with Component.utils.import or with require()");
}
-var LOG = SharedAll.LOG.bind(SharedAll, "Win", "allthreads");
+SharedAll.LOG.bind(SharedAll, "Win", "allthreads");
var Const = SharedAll.Constants.Win;
// Open libc
var libc = new SharedAll.Library("libc", "kernel32.dll");
exports.libc = libc;
// Define declareFFI
var declareFFI = SharedAll.declareFFI.bind(null, libc);
@@ -80,17 +80,16 @@ libc.declareLazy(Scope, "FormatMessage",
* @param {string=} path The file path that manipulated. If unspecified,
* assign the empty string.
*
* @constructor
* @extends {OS.Shared.Error}
*/
var OSError = function OSError(operation = "unknown operation",
lastError = ctypes.winLastError, path = "") {
- operation = operation;
SharedAll.OSError.call(this, operation, path);
this.winLastError = lastError;
};
OSError.prototype = Object.create(SharedAll.OSError.prototype);
OSError.prototype.toString = function toString() {
let buf = new (ctypes.ArrayType(ctypes.char16_t, 1024))();
let result = Scope.FormatMessage(
Const.FORMAT_MESSAGE_FROM_SYSTEM |
--- a/toolkit/components/osfile/modules/osfile_win_back.jsm
+++ b/toolkit/components/osfile/modules/osfile_win_back.jsm
@@ -17,16 +17,17 @@
* 3. included from the osfile worker thread using importScript
* (it serves to define the implementation of the asynchronous API)
* (bug 729057)
*/
/* eslint-env mozilla/chrome-worker, node */
/* global OS */
+// eslint-disable-next-line no-lone-blocks
{
if (typeof Components != "undefined") {
// We do not wish osfile_win.jsm to be used directly as a main thread
// module yet. When time comes, it will be loaded by a combination of
// a main thread front-end/worker thread implementation that makes sure
// that we are not executing synchronous IO code in the main thread.
throw new Error("osfile_win.jsm cannot be used from the main thread yet");
@@ -35,41 +36,41 @@
(function(exports) {
"use strict";
if (exports.OS && exports.OS.Win && exports.OS.Win.File) {
return; // Avoid double initialization
}
let SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
let SysAll = require("resource://gre/modules/osfile/osfile_win_allthreads.jsm");
- let LOG = SharedAll.LOG.bind(SharedAll, "Unix", "back");
+ SharedAll.LOG.bind(SharedAll, "Unix", "back");
let libc = SysAll.libc;
let advapi32 = new SharedAll.Library("advapi32", "advapi32.dll");
let Const = SharedAll.Constants.Win;
/**
* Initialize the Windows module.
*
* @param {function=} declareFFI
*/
// FIXME: Both |init| and |aDeclareFFI| are deprecated, we should remove them
let init = function init(aDeclareFFI) {
- let declareFFI;
+ let declareFFI; // eslint-disable-line no-unused-vars
if (aDeclareFFI) {
declareFFI = aDeclareFFI.bind(null, libc);
} else {
declareFFI = SysAll.declareFFI;
}
- let declareLazyFFI = SharedAll.declareLazyFFI;
+ let declareLazyFFI = SharedAll.declareLazyFFI; // eslint-disable-line no-unused-vars
// Initialize types that require additional OS-specific
// support - either finalization or matching against
// OS-specific constants.
let Type = Object.create(SysAll.Type);
- let SysFile = exports.OS.Win.File = { Type: Type };
+ let SysFile = exports.OS.Win.File = { Type };
// Initialize types
/**
* A C integer holding INVALID_HANDLE_VALUE in case of error or
* a file descriptor in case of success.
*/
Type.HANDLE =
--- a/toolkit/components/osfile/modules/osfile_win_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_win_front.jsm
@@ -7,16 +7,17 @@
* Windows implementation.
*
* This front-end is meant to be imported by a worker thread.
*/
/* eslint-env mozilla/chrome-worker, node */
/* global OS */
+// eslint-disable-next-line no-lone-blocks
{
if (typeof Components != "undefined") {
// We do not wish osfile_win_front.jsm to be used directly as a main thread
// module yet.
throw new Error("osfile_win_front.jsm cannot be used from the main thread yet");
}
(function(exports) {
@@ -1148,20 +1149,20 @@
WinFile.SetCurrentDirectory(path),
path);
};
/**
* Get/set the current directory by |curDir|.
*/
Object.defineProperty(File, "curDir", {
- set: function(path) {
+ set(path) {
this.setCurrentDirectory(path);
},
- get: function() {
+ get() {
return this.getCurrentDirectory();
}
}
);
// Utility functions, used for error-handling
/**
@@ -1191,50 +1192,16 @@
function throw_on_zero(operation, result, path) {
if (result == 0) {
throw new File.Error(operation, ctypes.winLastError, path);
}
return result;
}
/**
- * Utility function to sort errors represented as "-1" from successes.
- *
- * @param {string=} operation The name of the operation. If unspecified,
- * the name of the caller function.
- * @param {number} result The result of the operation that may
- * represent either an error or a success. If -1, this function raises
- * an error holding ctypes.winLastError, otherwise it returns |result|.
- * @param {string=} path The path of the file.
- */
- function throw_on_negative(operation, result, path) {
- if (result < 0) {
- throw new File.Error(operation, ctypes.winLastError, path);
- }
- return result;
- }
-
- /**
- * Utility function to sort errors represented as |null| from successes.
- *
- * @param {string=} operation The name of the operation. If unspecified,
- * the name of the caller function.
- * @param {pointer} result The result of the operation that may
- * represent either an error or a success. If |null|, this function raises
- * an error holding ctypes.winLastError, otherwise it returns |result|.
- * @param {string=} path The path of the file.
- */
- function throw_on_null(operation, result, path) {
- if (result == null || (result.isNull && result.isNull())) {
- throw new File.Error(operation, ctypes.winLastError, path);
- }
- return result;
- }
-
- /**
* Helper used by both versions of setPermissions
*/
function toFileAttributes(winAttributes, oldDwAttrs) {
if ("readOnly" in winAttributes) {
if (winAttributes.readOnly) {
oldDwAttrs |= Const.FILE_ATTRIBUTE_READONLY;
} else {
oldDwAttrs &= ~Const.FILE_ATTRIBUTE_READONLY;
--- a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
+++ b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js
@@ -402,25 +402,25 @@ var test_debug = maketest("debug", funct
/**
* Test logging in the main thread with set OS.Shared.DEBUG and
* OS.Shared.TEST flags.
*/
var test_debug_test = maketest("debug_test", function debug_test(test) {
return (async function() {
// Create a console listener.
let consoleListener = {
- observe: function(aMessage) {
+ observe(aMessage) {
// Ignore unexpected messages.
if (!(aMessage instanceof Components.interfaces.nsIConsoleMessage)) {
return;
}
if (aMessage.message.indexOf("TEST OS") < 0) {
return;
}
test.ok(true, "DEBUG TEST messages are logged correctly.");
}
};
toggleDebugTest(true, consoleListener);
// Execution of OS.File.exist method will trigger OS.File.LOG several times.
- let fileExists = await OS.File.exists(EXISTING_FILE);
+ await OS.File.exists(EXISTING_FILE);
toggleDebugTest(false, consoleListener);
})();
});
--- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js
+++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js
@@ -60,17 +60,17 @@ function test_open_existing_file() {
/**
* Test that opening a file that does not exist fails with the right error.
*/
function test_open_non_existing_file() {
info("Starting test_open_non_existing");
let exn;
try {
- let file = OS.File.open("/I do not exist");
+ OS.File.open("/I do not exist");
} catch (x) {
exn = x;
info("test_open_non_existing_file: Exception detail " + exn);
}
ok(!!exn, "test_open_non_existing_file: Exception was raised ");
ok(exn instanceof OS.File.Error, "test_open_non_existing_file: Exception was a OS.File.Error");
ok(exn.becauseNoSuchFile, "test_open_non_existing_file: Exception confirms that the file does not exist");
}
--- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_shared.js
+++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_shared.js
@@ -14,19 +14,19 @@ function finish() {
}
function ok(condition, description) {
send({kind: "ok", condition: !!condition, description: "" + description});
}
function is(a, b, description) {
let outcome = a == b; // Need to decide outcome here, as not everything can be serialized
- send({kind: "is", outcome: outcome, description: "" + description, a: "" + a, b: "" + b});
+ send({kind: "is", outcome, description: "" + description, a: "" + a, b: "" + b});
}
function isnot(a, b, description) {
let outcome = a != b; // Need to decide outcome here, as not everything can be serialized
- send({kind: "isnot", outcome: outcome, description: "" + description, a: "" + a, b: "" + b});
+ send({kind: "isnot", outcome, description: "" + description, a: "" + a, b: "" + b});
}
function info(description) {
send({kind: "info", description: "" + description});
}
--- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js
+++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js
@@ -113,17 +113,17 @@ function test_read_write() {
bytes = OS.Unix.File.read(input, array, 4096);
ok(bytes != undefined, "test_read_write: bytes is defined");
isnot(bytes, -1, "test_read_write: no read error");
let write_from = 0;
if (bytes == 0) {
break;
}
while (bytes > 0) {
- let ptr = array.addressOfElement(write_from);
+ array.addressOfElement(write_from);
// Note: |write| launches an exception in case of error
let written = OS.Unix.File.write(output, array, bytes);
isnot(written, -1, "test_read_write: no write error");
write_from += written;
bytes -= written;
}
total += write_from;
}
@@ -181,20 +181,20 @@ function test_read_write() {
info("test_read_write cleanup complete");
}
function test_passing_undefined() {
info("Testing that an exception gets thrown when an FFI function is passed undefined");
let exceptionRaised = false;
try {
- let file = OS.Unix.File.open(undefined, OS.Constants.libc.O_RDWR
- | OS.Constants.libc.O_CREAT
- | OS.Constants.libc.O_TRUNC,
- OS.Constants.libc.S_IRWXU);
+ OS.Unix.File.open(undefined, OS.Constants.libc.O_RDWR
+ | OS.Constants.libc.O_CREAT
+ | OS.Constants.libc.O_TRUNC,
+ OS.Constants.libc.S_IRWXU);
} catch (e) {
if (e instanceof TypeError && e.message.indexOf("open") > -1) {
exceptionRaised = true;
} else {
throw e;
}
}
--- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_win.js
+++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_win.js
@@ -117,17 +117,17 @@ function test_ReadWrite() {
let write_from = 0;
let bytes_left = bytes_read;
log("test_ReadWrite: read chunk complete " + bytes_left.value);
if (bytes_left.value == 0) {
break;
}
while (bytes_left.value > 0) {
log("test_ReadWrite: writing " + bytes_left.value);
- let ptr = array.addressOfElement(write_from);
+ array.addressOfElement(write_from);
// Note: |WriteFile| launches an exception in case of error
result = OS.Win.File.WriteFile(output, array, bytes_left, bytes_written_ptr, null);
isnot(result, 0, "test_ReadWrite: write success");
write_from += bytes_written;
bytes_left -= bytes_written;
}
}
info("test_ReadWrite: copy complete");
@@ -188,17 +188,17 @@ function test_ReadWrite() {
info("test_ReadWrite cleanup complete");
}
function test_passing_undefined() {
info("Testing that an exception gets thrown when an FFI function is passed undefined");
let exceptionRaised = false;
try {
- let file = OS.Win.File.CreateFile(
+ OS.Win.File.CreateFile(
undefined,
OS.Constants.Win.GENERIC_READ,
0,
null,
OS.Constants.Win.OPEN_EXISTING,
0,
null);
} catch (e) {
--- a/toolkit/components/osfile/tests/xpcshell/test_compression.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_compression.js
@@ -31,17 +31,17 @@ add_task(async function test_compress_lz
add_task(async function test_uncompressed() {
do_print("Writing data without compression");
let path = OS.Path.join(OS.Constants.Path.tmpDir, "no_compression.tmp");
let array = new Uint8Array(1024);
for (let i = 0; i < array.byteLength; ++i) {
array[i] = i;
}
- let bytes = await OS.File.writeAtomic(path, array); // No compression
+ await OS.File.writeAtomic(path, array); // No compression
let exn;
// Force decompression, reading should fail
try {
await OS.File.read(path, { compression: "lz4" });
} catch (ex) {
exn = ex;
}
@@ -51,17 +51,17 @@ add_task(async function test_uncompresse
});
add_task(async function test_no_header() {
let path = OS.Path.join(OS.Constants.Path.tmpDir, "no_header.tmp");
let array = new Uint8Array(8).fill(0, 0); // Small array with no header
do_print("Writing data with no header");
- let bytes = await OS.File.writeAtomic(path, array); // No compression
+ await OS.File.writeAtomic(path, array); // No compression
let exn;
// Force decompression, reading should fail
try {
await OS.File.read(path, { compression: "lz4" });
} catch (ex) {
exn = ex;
}
do_check_true(!!exn);
@@ -75,17 +75,17 @@ add_task(async function test_invalid_con
let arr2 = new Uint8Array(248).fill(1, 0);
let array = new Uint8Array(arr1.length + arr2.length);
array.set(arr1);
array.set(arr2, arr1.length);
do_print("Writing invalid data (with a valid header and only ones after that)");
- let bytes = await OS.File.writeAtomic(path, array); // No compression
+ await OS.File.writeAtomic(path, array); // No compression
let exn;
// Force decompression, reading should fail
try {
await OS.File.read(path, { compression: "lz4" });
} catch (ex) {
exn = ex;
}
do_check_true(!!exn);
--- a/toolkit/components/osfile/tests/xpcshell/test_creationDate.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_creationDate.js
@@ -10,17 +10,17 @@ function run_test() {
* of creationDate.
*/
add_task(async function test_deprecatedCreationDate() {
let currentDir = await OS.File.getCurrentDirectory();
let path = OS.Path.join(currentDir, "test_creationDate.js");
let consoleMessagePromise = new Promise(resolve => {
let consoleListener = {
- observe: function(aMessage) {
+ observe(aMessage) {
if (aMessage.message.indexOf("Field 'creationDate' is deprecated.") > -1) {
do_print("Deprecation message printed");
do_check_true(true);
Services.console.unregisterListener(consoleListener);
resolve();
}
}
}
--- a/toolkit/components/osfile/tests/xpcshell/test_duration.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_duration.js
@@ -54,17 +54,17 @@ add_task(async function duration() {
let contents = await OS.File.read(pathSource, undefined, readOptions);
testOptions(readOptions, "OS.File.read", ["outExecutionDuration"]);
// 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.
outSerializationDuration: null,
outExecutionDuration: null,
- tmpPath: tmpPath
+ tmpPath
};
await OS.File.writeAtomic(pathDest, contents, writeAtomicOptions);
testOptions(writeAtomicOptions, "OS.File.writeAtomic");
await OS.File.remove(pathDest);
do_print(`Ensuring that we can use ${availableDurations.join(", ")} to accumulate durations`);
let ARBITRARY_BASE_DURATION = 5;
--- a/toolkit/components/osfile/tests/xpcshell/test_logging.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_logging.js
@@ -10,17 +10,17 @@ Components.utils.import("resource://gre/
function run_test() {
do_test_pending();
let messageCount = 0;
do_print("Test starting");
// Create a console listener.
let consoleListener = {
- observe: function(aMessage) {
+ observe(aMessage) {
// Ignore unexpected messages.
if (!(aMessage instanceof Components.interfaces.nsIConsoleMessage)) {
return;
}
// This is required, as printing to the |Services.console|
// while in the observe function causes an exception.
do_execute_soon(function() {
do_print("Observing message " + aMessage.message);
@@ -66,9 +66,8 @@ function run_test() {
do_print("Logging 1");
OS.Shared.LOG(objectDefault);
do_print("Logging 2");
OS.Shared.LOG(objectCustom);
// Once both messages are observed OS.Shared.DEBUG, and OS.Shared.TEST
// are reset to false.
}
-
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_largefiles.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_largefiles.js
@@ -57,18 +57,16 @@ async function test_setPosition_failures
"test_osfile_async_largefiles.tmp");
// Clear any left-over files from previous runs.
await removeTestFile(path);
try {
let file = await OS.File.open(path, {write: true, append: false});
try {
- let pos = 0;
-
// 1. Use an invalid position value
try {
await file.setPosition(0.5, OS.File.POS_START);
do_throw("Shouldn't have succeeded");
} catch (ex) {
do_check_true(ex.toString().includes("can't pass"));
}
// Since setPosition should have bailed, it shouldn't have moved the
@@ -109,17 +107,17 @@ async function test_setPosition_failures
}
function run_test() {
// First verify stuff works for small values.
add_task(test_setPosition.bind(null, 0, 100, 50));
add_task(test_setPosition.bind(null, 1000, 100, 50));
add_task(test_setPosition.bind(null, 1000, -100, -50));
- if (OS.Constants.Win || ctypes.off_t.size >= 8) {
+ if (OS.Constants.Win || ctypes.off_t.size >= 8) {
// Now verify stuff still works for large values.
// 1. Multiple small seeks, which add up to > MAXINT32
add_task(test_setPosition.bind(null, 0x7fffffff, 0x7fffffff, 0));
// 2. Plain large seek, that should end up at 0 again.
// 0xffffffff also happens to be the INVALID_SET_FILE_POINTER value on
// Windows, so this also tests the error handling
add_task(test_setPosition.bind(null, 0, 0xffffffff, 0xffffffff));
// 3. Multiple large seeks that should end up > MAXINT32.
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_async_setDates.js
@@ -1,10 +1,12 @@
"use strict";
+/* eslint-disable no-lone-blocks */
+
Components.utils.import("resource://gre/modules/osfile.jsm");
/**
* A test to ensure that OS.File.setDates and OS.File.prototype.setDates are
* working correctly.
* (see bug 924916)
*/
@@ -101,17 +103,17 @@ add_task(async function test_proto() {
return;
}
// First, create a file we can mess with.
let path = OS.Path.join(OS.Constants.Path.tmpDir,
"test_osfile_async_setDates_proto.tmp");
await OS.File.writeAtomic(path, new Uint8Array(1));
- try {
+ try {
let fd = await OS.File.open(path, {write: true});
try {
// 1. Try to set some well known dates.
// We choose multiples of 2000ms, because the time stamp resolution of
// the underlying OS might not support something more precise.
const accDate = 2000;
const modDate = 4000;
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_kill.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_kill.js
@@ -57,17 +57,17 @@ var Scheduler = AsyncFrontGlobal.Schedul
add_task(async function test_kill_race() {
// Ensure the worker has been created and that SET_DEBUG has taken effect.
// We have chosen OS.File.exists for our tests because it does not trigger
// a rejection and we absolutely do not care what the operation is other
// than it does not invoke a native fast-path.
await OS.File.exists("foo.foo");
do_print("issuing first request");
- let firstRequest = OS.File.exists("foo.bar");
+ let firstRequest = OS.File.exists("foo.bar"); // eslint-disable-line no-unused-vars
let secondRequest;
let secondResolved = false;
// As noted in our big block comment, we want to wait to schedule the
// second request so that it races `kill`'s call to `worker.post`. Having
// ourselves wait on the same promise, `queue`, and registering ourselves
// before we issue the kill request means we will get run before the `kill`
// task resumes and allow us to precisely create the desired race.
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_writeAtomic_backupTo_option.js
@@ -98,17 +98,16 @@ add_task(async function test_non_backupT
/**
* test when
* |backupTo| specified
* |tmpPath| not specified
* destination file not exists
* @result no back up file exists
*/
add_task(async 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");
await File.remove(path);
await File.writeAtomic(path, WRITE_CONTENTS, { backupTo: path + ".backup" });
do_check_false((await File.exists(path + ".backup")));
});
--- a/toolkit/components/osfile/tests/xpcshell/test_queue.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_queue.js
@@ -11,17 +11,17 @@ add_task(async function check_init() {
await OS.File.queue;
do_print("Function resolved");
});
// Check if Scheduler.queue returned by OS.File.queue is resolved
// after an operation is successful.
add_task(async function check_success() {
do_print("Attempting to open a file correctly");
- let openedFile = await OS.File.open(OS.Path.join(do_get_cwd().path, "test_queue.js"));
+ await OS.File.open(OS.Path.join(do_get_cwd().path, "test_queue.js"));
do_print("File opened correctly");
await OS.File.queue;
do_print("Function resolved");
});
// Check if Scheduler.queue returned by OS.File.queue is resolved
// after an operation fails.
add_task(async function check_failure() {
--- a/toolkit/components/osfile/tests/xpcshell/test_read_write.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_read_write.js
@@ -73,26 +73,26 @@ add_test_pair(async function read_write_
// Check that temporary file was removed or never created
do_check_false(new FileUtils.File(TMP_PATH).exists());
// Now write a subset
let START = 10;
let LENGTH = 100;
contents = new Uint8Array(300);
- for (var i = 0; i < contents.byteLength; i++)
+ for (let i = 0; i < contents.byteLength; i++)
contents[i] = i % 256;
view = new Uint8Array(contents.buffer, START, LENGTH);
bytesWritten = await OS.File.writeAtomic(DEST_PATH, view, options);
do_check_eq(bytesWritten, LENGTH);
let array2 = await OS.File.read(DEST_PATH);
do_check_eq(LENGTH, array2.length);
- for (var i = 0; i < LENGTH; i++)
- do_check_eq(array2[i], (i + START) % 256);
+ for (let j = 0; j < LENGTH; j++)
+ do_check_eq(array2[j], (j + START) % 256);
// Cleanup.
await OS.File.remove(DEST_PATH);
await OS.File.remove(TMP_PATH);
})();
}
await test_with_options({tmpPath: TMP_PATH}, "Renaming, not flushing");