Bug 1508989 - Enable ESLint for dom/filesystem / (automatic changes) r=Standard8

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Adam Pucciano 2018-12-05 02:24:58 +00:00
parent dcee012964
commit 244c269756
12 changed files with 94 additions and 95 deletions

View File

@ -184,7 +184,6 @@ dom/encoding/**
dom/events/**
dom/fetch/**
dom/file/**
dom/filesystem/**
dom/flex/**
dom/grid/**
dom/html/**

View File

@ -2,41 +2,41 @@ Cu.importGlobalProperties(["File", "Directory"]);
var tmpFile, tmpDir;
addMessageListener("entries.open", function (e) {
addMessageListener("entries.open", function(e) {
tmpFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties)
.get('TmpD', Ci.nsIFile)
tmpFile.append('file.txt');
.get("TmpD", Ci.nsIFile);
tmpFile.append("file.txt");
tmpFile.createUnique(Ci.nsIFile.FILE_TYPE, 0o600);
tmpDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties)
.get('TmpD', Ci.nsIFile)
.get("TmpD", Ci.nsIFile);
tmpDir.append('dir-test');
tmpDir.append("dir-test");
tmpDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
var file1 = tmpDir.clone();
file1.append('foo.txt');
file1.append("foo.txt");
file1.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
var dir1 = tmpDir.clone();
dir1.append('subdir');
dir1.append("subdir");
dir1.create(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
var file2 = dir1.clone();
file2.append('bar..txt'); // Note the double ..
file2.append("bar..txt"); // Note the double ..
file2.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
var dir2 = dir1.clone();
dir2.append('subsubdir');
dir2.append("subsubdir");
dir2.create(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
File.createFromNsIFile(tmpFile).then(function(file) {
sendAsyncMessage("entries.opened", {
data: [ new Directory(tmpDir.path), file ]
data: [ new Directory(tmpDir.path), file ],
});
});
});

View File

@ -25,7 +25,7 @@ function populate_entries() {
script = SpecialPowers.loadChromeScript(url);
function onOpened(message) {
var entries = document.getElementById('entries');
var entries = document.getElementById("entries");
SpecialPowers.wrap(entries).mozSetDndFilesAndDirectories(message.data);
next();
}
@ -35,7 +35,7 @@ function populate_entries() {
}
function test_entries() {
var entries = document.getElementById('entries');
var entries = document.getElementById("entries");
ok("webkitEntries" in entries, "HTMLInputElement.webkitEntries");
is(entries.webkitEntries.length, 2, "HTMLInputElement.webkitEntries.length == 2");
is(entries.files.length, 1, "HTMLInputElement.files is still populated");
@ -399,7 +399,7 @@ function test_getParent(entry, parentEntry, nested) {
entry.getParent(function(e) {
ok(e, "We have a parent Entry.");
if (!nested) {
is (e, parentEntry, "Parent entry matches");
is(e, parentEntry, "Parent entry matches");
next();
} else {
test_getParent(e, parentEntry, false);

View File

@ -29,7 +29,7 @@ function setup_tests() {
iframe.onload = function() {
info("Frame loaded!");
next();
}
};
SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
["dom.webkitBlink.dirPicker.enabled", true],
@ -45,13 +45,13 @@ function populate_entries(webkitDirectory) {
form.removeChild(input);
}
input = document.createElement('input');
input.setAttribute('id', 'input');
input.setAttribute('type', 'file');
input.setAttribute('name', 'input');
input = document.createElement("input");
input.setAttribute("id", "input");
input.setAttribute("type", "file");
input.setAttribute("name", "input");
if (webkitDirectory) {
input.setAttribute('webkitdirectory', 'true');
input.setAttribute("webkitdirectory", "true");
}
form.appendChild(input);

View File

@ -21,8 +21,8 @@ function setup_tests() {
}
function populate_entries() {
entries = document.createElement('input');
entries.setAttribute('type', 'file');
entries = document.createElement("input");
entries.setAttribute("type", "file");
document.body.appendChild(entries);
var url = SimpleTest.getTestFileURL("script_entries.js");

View File

@ -1,5 +1,5 @@
function createPath(parentDir, dirOrFile) {
return parentDir.path + (parentDir.path == '/' ? '' : '/') + dirOrFile.name;
return parentDir.path + (parentDir.path == "/" ? "" : "/") + dirOrFile.name;
}
function createRelativePath(parentDir, dirOrFile) {
@ -18,7 +18,7 @@ function setup_tests(aNext) {
function test_basic(aDirectory, aNext) {
ok(aDirectory, "Directory exists.");
ok(aDirectory instanceof Directory, "We have a directory.");
is(aDirectory.path, '/' + aDirectory.name, "directory.path must be '/'+name");
is(aDirectory.path, "/" + aDirectory.name, "directory.path must be '/'+name");
aNext();
}
@ -27,10 +27,10 @@ function test_getFilesAndDirectories(aDirectory, aRecursive, aNext) {
return dir.getFilesAndDirectories().then(
function(data) {
for (var i = 0; i < data.length; ++i) {
ok (data[i] instanceof File || data[i] instanceof Directory, "Just Files or Directories");
ok(data[i] instanceof File || data[i] instanceof Directory, "Just Files or Directories");
if (data[i] instanceof Directory) {
isnot(data[i].name, '/', "Subdirectory should be called with the leafname");
isnot(data[i].path, '/', "Subdirectory path should be called with the leafname");
isnot(data[i].name, "/", "Subdirectory should be called with the leafname");
isnot(data[i].path, "/", "Subdirectory path should be called with the leafname");
isnot(data[i].path, dir.path, "Subdirectory path should contain the parent path.");
is(data[i].path, createPath(dir, data[i]), "Subdirectory path should be called parentdir.path + '/' + leafname: " + data[i].path);
}
@ -48,9 +48,9 @@ function test_getFilesAndDirectories(aDirectory, aRecursive, aNext) {
ok(data.length, "We should have some data.");
var promises = [];
for (var i = 0; i < data.length; ++i) {
ok (data[i] instanceof File || data[i] instanceof Directory, "Just Files or Directories: " + data[i].name);
ok(data[i] instanceof File || data[i] instanceof Directory, "Just Files or Directories: " + data[i].name);
if (data[i] instanceof Directory) {
isnot(data[i].name, '/', "Subdirectory should be called with the leafname");
isnot(data[i].name, "/", "Subdirectory should be called with the leafname");
is(data[i].path, createPath(aDirectory, data[i]), "Subdirectory path should be called parentdir.path + '/' + leafname: " + data[i].path);
if (aRecursive) {
promises.push(checkSubDir(data[i]));
@ -75,9 +75,9 @@ function test_getFiles(aDirectory, aRecursive, aNext) {
function(data) {
for (var i = 0; i < data.length; ++i) {
ok(data[i] instanceof File, "File: " + data[i].name);
is(aDirectory.path[0], '/', "Directory path must start with '/'");
is(aDirectory.path[0], "/", "Directory path must start with '/'");
ok(data[i].webkitRelativePath.indexOf(aDirectory.path.substring(1)) == 0 &&
data[i].webkitRelativePath.indexOf('/' + data[i].name) + ('/' + data[i].name).length == data[i].webkitRelativePath.length,
data[i].webkitRelativePath.indexOf("/" + data[i].name) + ("/" + data[i].name).length == data[i].webkitRelativePath.length,
"File.webkitRelativePath should be called dir.path + '/' + file.name: " + data[i].webkitRelativePath);
}
},
@ -90,13 +90,13 @@ function test_getFiles(aDirectory, aRecursive, aNext) {
function test_getFiles_recursiveComparison(aDirectory, aNext) {
aDirectory.getFiles(true).then(function(data) {
is(data.length, 2, "Only 2 files for this test.");
ok(data[0].name == 'foo.txt' || data[0].name == 'bar.txt', "First filename matches");
ok(data[1].name == 'foo.txt' || data[1].name == 'bar.txt', "Second filename matches");
ok(data[0].name == "foo.txt" || data[0].name == "bar.txt", "First filename matches");
ok(data[1].name == "foo.txt" || data[1].name == "bar.txt", "Second filename matches");
}).then(function() {
return aDirectory.getFiles(false);
}).then(function(data) {
is(data.length, 1, "Only 1 file for this test.");
ok(data[0].name == 'foo.txt' || data[0].name == 'bar.txt', "First filename matches");
ok(data[0].name == "foo.txt" || data[0].name == "bar.txt", "First filename matches");
}).catch(function() {
ok(false, "Something when wrong");
}).then(aNext);

View File

@ -4,7 +4,7 @@ function createProfDFile() {
return Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties)
.get('ProfD', Ci.nsIFile);
.get("ProfD", Ci.nsIFile);
}
// Creates a parametric arity directory hierarchy as a function of depth.
@ -26,17 +26,17 @@ function createTreeFile(depth, parent) {
parent = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties)
.get('TmpD', Ci.nsIFile);
parent.append('dir-tree-test');
.get("TmpD", Ci.nsIFile);
parent.append("dir-tree-test");
parent.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
}
var nextFile = parent.clone();
if (depth == 0) {
nextFile.append('file.txt');
nextFile.append("file.txt");
nextFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
} else {
nextFile.append('subdir' + depth);
nextFile.append("subdir" + depth);
nextFile.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
// Decrement the maximal depth by one for each level of nesting.
for (i = 0; i < depth; i++) {
@ -67,55 +67,55 @@ function createTestFile() {
var tmpFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties)
.get('TmpD', Ci.nsIFile)
tmpFile.append('dir-test');
.get("TmpD", Ci.nsIFile);
tmpFile.append("dir-test");
tmpFile.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
var file1 = tmpFile.clone();
file1.append('foo.txt');
file1.append("foo.txt");
file1.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
var dir = tmpFile.clone();
dir.append('subdir');
dir.append("subdir");
dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o700);
var file2 = dir.clone();
file2.append('bar.txt');
file2.append("bar.txt");
file2.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
return tmpFile;
}
addMessageListener("dir.open", function (e) {
addMessageListener("dir.open", function(e) {
var testFile;
switch (e.path) {
case 'ProfD':
case "ProfD":
// Note that files in the profile directory are not guaranteed to persist-
// see bug 1284742.
testFile = createProfDFile();
break;
case 'root':
case "root":
testFile = createRootFile();
break;
case 'test':
case "test":
testFile = createTestFile();
break;
case 'tree':
case "tree":
testFile = createTreeFile(3);
break;
}
sendAsyncMessage("dir.opened", {
dir: testFile.path,
name: testFile.leafName
name: testFile.leafName,
});
});
addMessageListener("file.open", function (e) {
addMessageListener("file.open", function(e) {
var testFile = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIDirectoryService)
.QueryInterface(Ci.nsIProperties)

View File

@ -14,8 +14,8 @@ var directory;
var fileList;
function create_fileList(aPath) {
fileList = document.createElement('input');
fileList.setAttribute('type', 'file');
fileList = document.createElement("input");
fileList.setAttribute("type", "file");
document.body.appendChild(fileList);
var url = SimpleTest.getTestFileURL("script_fileList.js");
@ -23,7 +23,7 @@ function create_fileList(aPath) {
function onOpened(message) {
SpecialPowers.wrap(fileList).mozSetDirectory(message.dir);
fileList.setAttribute('data-name', message.name);
fileList.setAttribute("data-name", message.name);
fileList.getFilesAndDirectories().then(function(array) {
is(array.length, 1, "We want just 1 directory.");
@ -76,7 +76,7 @@ function test_duplicateGetFilesAndDirectories() {
}
script.addMessageListener("dir.opened", onOpened);
script.sendAsyncMessage("dir.open", { path: 'test' });
script.sendAsyncMessage("dir.open", { path: "test" });
}
function test_inputGetFiles() {
@ -85,7 +85,7 @@ function test_inputGetFiles() {
function onOpened(message) {
SpecialPowers.wrap(fileList).mozSetDirectory(message.dir);
fileList.setAttribute('data-name', message.name);
fileList.setAttribute("data-name", message.name);
fileList.getFilesAndDirectories()
.then(function(result) {
@ -97,8 +97,8 @@ function test_inputGetFiles() {
.then(function(result) {
is(result.length, 1, "getFiles should return 1 element");
ok(result[0] instanceof File, "getFile should return 1 file");
is(result[0].name, 'foo.txt', "getFiles()[0].name should be 'foo.txt'");
is(result[0].webkitRelativePath, fileList.dataset.name + '/foo.txt', "getFiles()[0].webkitRelativePath should be '/foo.txt'");
is(result[0].name, "foo.txt", "getFiles()[0].name should be 'foo.txt'");
is(result[0].webkitRelativePath, fileList.dataset.name + "/foo.txt", "getFiles()[0].webkitRelativePath should be '/foo.txt'");
return fileList.getFiles(true);
})
@ -107,11 +107,11 @@ function test_inputGetFiles() {
function checkFile(file) {
ok(file instanceof File, "getFile[x] should return a file");
if (file.name == 'foo.txt') {
is(file.webkitRelativePath, fileList.dataset.name + '/foo.txt', "getFiles()[x].webkitRelativePath should be '/foo.txt'");
if (file.name == "foo.txt") {
is(file.webkitRelativePath, fileList.dataset.name + "/foo.txt", "getFiles()[x].webkitRelativePath should be '/foo.txt'");
} else {
is(file.name, 'bar.txt', "getFiles()[x].name should be 'bar.txt'");
is(file.webkitRelativePath, fileList.dataset.name + '/subdir/bar.txt', "getFiles()[x].webkitRelativePath should be '/subdir/bar.txt'");
is(file.name, "bar.txt", "getFiles()[x].name should be 'bar.txt'");
is(file.webkitRelativePath, fileList.dataset.name + "/subdir/bar.txt", "getFiles()[x].webkitRelativePath should be '/subdir/bar.txt'");
}
}
@ -125,29 +125,29 @@ function test_inputGetFiles() {
}
script.addMessageListener("dir.opened", onOpened);
script.sendAsyncMessage("dir.open", { path: 'test' });
script.sendAsyncMessage("dir.open", { path: "test" });
}
var tests = [
function() { setup_tests(next); },
function() { create_fileList('tree') },
function() { create_fileList("tree"); },
function() { test_basic(directory, next); },
function() { test_getFilesAndDirectories(directory, true, next); },
function() { test_getFiles(directory, false, next); },
function() { test_getFiles(directory, true, next); },
function() { create_fileList('test') },
function() { create_fileList("test"); },
function() { test_getFiles_recursiveComparison(directory, next); },
function() { create_fileList('root'); },
function() { create_fileList("root"); },
function() { test_basic(directory, next); },
function() { test_getFilesAndDirectories(directory, false, next); },
function() { test_getFiles(directory, false, next); },
test_duplicateGetFilesAndDirectories,
test_inputGetFiles,
test_simpleFilePicker
test_simpleFilePicker,
];
function next() {

View File

@ -36,7 +36,7 @@ function checkBug() {
var input = document.getElementById("input");
is(input.files[0].webkitRelativePath, "", "No relative path!");
let form = document.createElement('form');
let form = document.createElement("form");
form.appendChild(input);
is(input.files[0].webkitRelativePath, "", "No relative path!");

View File

@ -25,8 +25,8 @@ function populateInputFile(aInputFile) {
MockFilePicker.useDirectory(message.dir);
var input = document.getElementById(aInputFile);
input.setAttribute('data-name', message.name);
input.addEventListener('change', function() {
input.setAttribute("data-name", message.name);
input.addEventListener("change", function() {
MockFilePicker.cleanup();
script.destroy();
next();
@ -36,7 +36,7 @@ function populateInputFile(aInputFile) {
}
script.addMessageListener("dir.opened", onOpened);
script.sendAsyncMessage("dir.open", { path: 'test' });
script.sendAsyncMessage("dir.open", { path: "test" });
}
function checkFile(file, fileList, dirName) {
@ -101,7 +101,7 @@ function test_changeDataWhileWorking() {
}
script.addMessageListener("dir.opened", onOpened);
script.sendAsyncMessage("dir.open", { path: 'root' });
script.sendAsyncMessage("dir.open", { path: "root" });
})
// input.click() pointing to the root dir
@ -123,7 +123,7 @@ function test_changeDataWhileWorking() {
}
script.addMessageListener("dir.opened", onOpened);
script.sendAsyncMessage("dir.open", { path: 'test' });
script.sendAsyncMessage("dir.open", { path: "test" });
});
})
@ -135,17 +135,17 @@ function test_changeDataWhileWorking() {
MockFilePicker.useDirectory(aDir);
var input = document.getElementById("inputFileDirectoryChange");
input.addEventListener('change', function() {
input.addEventListener("change", function() {
MockFilePicker.cleanup();
resolve();
});
input.click();
})
});
})
.then(function() {
test_fileList('inputFileWebkitDirectory', testDirData);
test_fileList("inputFileWebkitDirectory", testDirData);
});
}
@ -155,19 +155,19 @@ function test_setup() {
["dom.webkitBlink.dirPicker.enabled", true]]}, next);
}
var testDirData = [ { name: 'foo.txt', path: '/foo.txt' },
{ name: 'bar.txt', path: '/subdir/bar.txt' }];
var testDirData = [ { name: "foo.txt", path: "/foo.txt" },
{ name: "bar.txt", path: "/subdir/bar.txt" }];
var tests = [
test_setup,
function() { populateInputFile('inputFileWebkitDirectory'); },
function() { populateInputFile('inputFileWebkitDirectoryAndDirectory'); },
function() { populateInputFile('inputFileDirectory'); },
function() { populateInputFile("inputFileWebkitDirectory"); },
function() { populateInputFile("inputFileWebkitDirectoryAndDirectory"); },
function() { populateInputFile("inputFileDirectory"); },
function() { test_fileList('inputFileWebkitDirectory', testDirData) },
function() { test_fileList('inputFileWebkitDirectoryAndDirectory', testDirData) },
function() { test_fileList('inputFileDirectory', null); },
function() { test_fileList("inputFileWebkitDirectory", testDirData); },
function() { test_fileList("inputFileWebkitDirectoryAndDirectory", testDirData); },
function() { test_fileList("inputFileDirectory", null); },
test_webkitdirectory_attribute,

View File

@ -13,8 +13,8 @@
var fileList;
function create_fileList() {
fileList = document.createElement('input');
fileList.setAttribute('type', 'file');
fileList = document.createElement("input");
fileList.setAttribute("type", "file");
document.body.appendChild(fileList);
var url = SimpleTest.getTestFileURL("script_fileList.js");
@ -27,22 +27,22 @@ function create_fileList() {
}
script.addMessageListener("dir.opened", onOpened);
script.sendAsyncMessage("dir.open", { path: 'test' });
script.sendAsyncMessage("dir.open", { path: "test" });
}
function test_worker() {
fileList.getFilesAndDirectories().then(function(array) {
var worker = new Worker('worker_basic.js');
var worker = new Worker("worker_basic.js");
worker.onmessage = function(e) {
if (e.data.type == 'finish') {
if (e.data.type == "finish") {
next();
return;
}
if (e.data.type == 'test') {
if (e.data.type == "test") {
ok(e.data.test, e.data.message);
}
}
};
worker.postMessage(array[0]);
});

View File

@ -1,11 +1,11 @@
importScripts('filesystem_commons.js');
importScripts("filesystem_commons.js");
function finish() {
postMessage({ type: 'finish' });
postMessage({ type: "finish" });
}
function ok(a, msg) {
postMessage({ type: 'test', test: !!a, message: msg });
postMessage({ type: "test", test: !!a, message: msg });
}
function is(a, b, msg) {
@ -38,4 +38,4 @@ var directory;
onmessage = function(e) {
directory = e.data;
next();
}
};