Commit f955b1f9 authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Use let/const in ui/file_manager/file_manager/test.

Following errors by eslint are not automatically fixed.
I fixed these manually.
(Used eslint-disable-next-line for redefining global object.)

/ui/file_manager/file_manager/test/js/chrome_api_test_impl.js
   13:1  error  Unexpected var, use let or const instead  no-var
  152:9  error  Unexpected var, use let or const instead  no-var
/ui/file_manager/file_manager/test/js/chrome_file_manager_private_test_impl.js
  283:1  error  Unexpected var, use let or const instead  no-var
/ui/file_manager/file_manager/test/js/test_util.js
    8:1  error  Unexpected var, use let or const instead  no-var
  376:3  error  Unexpected var, use let or const instead  no-var

Bug: 778674
Test: Run browser_tests/closure_compiler
Change-Id: Ifeccd95fd0c459c5752855ef7f218d646bd6c6ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014600
Commit-Queue: Noel Gordon <noel@chromium.org>
Auto-Submit: Naoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734146}
parent f32982c9
...@@ -11,7 +11,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => { ...@@ -11,7 +11,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
// Save old fmp.getFileTasks and replace with version that returns // Save old fmp.getFileTasks and replace with version that returns
// the internal linux package install handler // the internal linux package install handler
let oldGetFileTasks = chrome.fileManagerPrivate.getFileTasks; const oldGetFileTasks = chrome.fileManagerPrivate.getFileTasks;
chrome.fileManagerPrivate.getFileTasks = (entries, callback) => { chrome.fileManagerPrivate.getFileTasks = (entries, callback) => {
setTimeout( setTimeout(
callback, 0, [{ callback, 0, [{
...@@ -24,7 +24,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => { ...@@ -24,7 +24,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
// Save old fmp.getLinuxPackageInfo and replace with version that saves the // Save old fmp.getLinuxPackageInfo and replace with version that saves the
// callback to manually call later // callback to manually call later
let oldGetLinuxPackageInfo = chrome.fileManagerPrivate.getLinuxPackageInfo; const oldGetLinuxPackageInfo = chrome.fileManagerPrivate.getLinuxPackageInfo;
let packageInfoCallback = null; let packageInfoCallback = null;
chrome.fileManagerPrivate.getLinuxPackageInfo = (entry, callback) => { chrome.fileManagerPrivate.getLinuxPackageInfo = (entry, callback) => {
packageInfoCallback = callback; packageInfoCallback = callback;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*/ */
// All testing functions in namespace 'test'. // All testing functions in namespace 'test'.
// eslint-disable-next-line
var test = test || {}; var test = test || {};
test.Event = class { test.Event = class {
...@@ -30,7 +31,7 @@ test.Event = class { ...@@ -30,7 +31,7 @@ test.Event = class {
/** @param {...*} args */ /** @param {...*} args */
dispatchEvent(...args) { dispatchEvent(...args) {
setTimeout(() => { setTimeout(() => {
for (let listener of this.listeners_) { for (const listener of this.listeners_) {
listener(...args); listener(...args);
} }
}, 0); }, 0);
...@@ -149,9 +150,9 @@ chrome = { ...@@ -149,9 +150,9 @@ chrome = {
state_: {}, state_: {},
local: { local: {
get: (keys, callback) => { get: (keys, callback) => {
var keys = keys instanceof Array ? keys : [keys]; const inKeys = keys instanceof Array ? keys : [keys];
var result = {}; const result = {};
keys.forEach(key => { inKeys.forEach(key => {
if (key in chrome.storage.state_) { if (key in chrome.storage.state_) {
result[key] = chrome.storage.state_[key]; result[key] = chrome.storage.state_[key];
} }
...@@ -159,7 +160,7 @@ chrome = { ...@@ -159,7 +160,7 @@ chrome = {
setTimeout(callback, 0, result); setTimeout(callback, 0, result);
}, },
set: (items, opt_callback) => { set: (items, opt_callback) => {
for (var key in items) { for (const key in items) {
chrome.storage.state_[key] = items[key]; chrome.storage.state_[key] = items[key];
} }
if (opt_callback) { if (opt_callback) {
......
...@@ -79,9 +79,9 @@ chrome.fileManagerPrivate = { ...@@ -79,9 +79,9 @@ chrome.fileManagerPrivate = {
}, },
getEntryProperties: (entries, names, callback) => { getEntryProperties: (entries, names, callback) => {
// Returns chrome.fileManagerPrivate.EntryProperties[]. // Returns chrome.fileManagerPrivate.EntryProperties[].
var results = []; const results = [];
entries.forEach(entry => { entries.forEach(entry => {
var props = {}; const props = {};
names.forEach(name => { names.forEach(name => {
props[name] = entry.metadata[name]; props[name] = entry.metadata[name];
}); });
...@@ -91,7 +91,7 @@ chrome.fileManagerPrivate = { ...@@ -91,7 +91,7 @@ chrome.fileManagerPrivate = {
}, },
getFileTasks: (entries, callback) => { getFileTasks: (entries, callback) => {
// Returns chrome.fileManagerPrivate.FileTask[]. // Returns chrome.fileManagerPrivate.FileTask[].
var results = []; const results = [];
// Support for view-in-browser on single text file used by QuickView. // Support for view-in-browser on single text file used by QuickView.
if (entries.length == 1 && entries[0].metadata && if (entries.length == 1 && entries[0].metadata &&
entries[0].metadata.contentMimeType == 'text/plain') { entries[0].metadata.contentMimeType == 'text/plain') {
...@@ -142,8 +142,8 @@ chrome.fileManagerPrivate = { ...@@ -142,8 +142,8 @@ chrome.fileManagerPrivate = {
setTimeout(callback, 0, loadTimeData.data_); setTimeout(callback, 0, loadTimeData.data_);
}, },
getVolumeMetadataList: (callback) => { getVolumeMetadataList: (callback) => {
var list = []; const list = [];
for (var i = 0; i < mockVolumeManager.volumeInfoList.length; i++) { for (let i = 0; i < mockVolumeManager.volumeInfoList.length; i++) {
list.push(mockVolumeManager.volumeInfoList.item(i)); list.push(mockVolumeManager.volumeInfoList.item(i));
} }
setTimeout(callback, 0, list); setTimeout(callback, 0, list);
...@@ -205,7 +205,7 @@ chrome.fileManagerPrivate = { ...@@ -205,7 +205,7 @@ chrome.fileManagerPrivate = {
nextCopyId_: 0, nextCopyId_: 0,
startCopy: (entry, parentEntry, newName, callback) => { startCopy: (entry, parentEntry, newName, callback) => {
// Returns copyId immediately. // Returns copyId immediately.
var copyId = chrome.fileManagerPrivate.nextCopyId_++; const copyId = chrome.fileManagerPrivate.nextCopyId_++;
callback(copyId); callback(copyId);
chrome.fileManagerPrivate.onCopyProgress.listeners_.forEach(l => { chrome.fileManagerPrivate.onCopyProgress.listeners_.forEach(l => {
l(copyId, {type: 'begin_copy_entry', sourceUrl: entry.toURL()}); l(copyId, {type: 'begin_copy_entry', sourceUrl: entry.toURL()});
...@@ -280,16 +280,17 @@ chrome.fileSystem = { ...@@ -280,16 +280,17 @@ chrome.fileSystem = {
* @param {function(!MockEntry)} successCallback Success callback. * @param {function(!MockEntry)} successCallback Success callback.
* @param {function(!Error)} errorCallback Error callback. * @param {function(!Error)} errorCallback Error callback.
*/ */
// eslint-disable-next-line
var webkitResolveLocalFileSystemURL = (url, successCallback, errorCallback) => { var webkitResolveLocalFileSystemURL = (url, successCallback, errorCallback) => {
var match = url.match(/^filesystem:(\w+)(\/.*)/); const match = url.match(/^filesystem:(\w+)(\/.*)/);
if (match) { if (match) {
var volumeType = /** @type {VolumeManagerCommon.VolumeType} */ (match[1]); const volumeType = /** @type {VolumeManagerCommon.VolumeType} */ (match[1]);
var path = match[2]; let path = match[2];
var volume = mockVolumeManager.getCurrentProfileVolumeInfo(volumeType); const volume = mockVolumeManager.getCurrentProfileVolumeInfo(volumeType);
if (volume) { if (volume) {
// Decode URI in file paths. // Decode URI in file paths.
path = path.split('/').map(decodeURIComponent).join('/'); path = path.split('/').map(decodeURIComponent).join('/');
var entry = volume.fileSystem.entries[path]; const entry = volume.fileSystem.entries[path];
if (entry) { if (entry) {
setTimeout(successCallback, 0, entry); setTimeout(successCallback, 0, entry);
return; return;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
'use strict'; 'use strict';
// All testing functions in namespace 'test'. // All testing functions in namespace 'test'.
// eslint-disable-next-line
var test = test || {}; var test = test || {};
// Update paths for testing. // Update paths for testing.
...@@ -31,7 +32,7 @@ test.DATA = { ...@@ -31,7 +32,7 @@ test.DATA = {
test.loadData = function() { test.loadData = function() {
return Promise.all(Object.keys(test.DATA).map(filename => { return Promise.all(Object.keys(test.DATA).map(filename => {
return new Promise(resolve => { return new Promise(resolve => {
var req = new XMLHttpRequest(); const req = new XMLHttpRequest();
req.responseType = 'blob'; req.responseType = 'blob';
req.onload = () => { req.onload = () => {
test.DATA[filename] = req.response; test.DATA[filename] = req.response;
...@@ -342,10 +343,10 @@ test.REPEAT_UNTIL_LOG_INTERVAL = 3000; ...@@ -342,10 +343,10 @@ test.REPEAT_UNTIL_LOG_INTERVAL = 3000;
* pending. * pending.
*/ */
test.pending = function(message, var_args) { test.pending = function(message, var_args) {
var index = 1; let index = 1;
var args = arguments; const args = arguments;
var formattedMessage = message.replace(/%[sdj]/g, function(pattern) { const formattedMessage = message.replace(/%[sdj]/g, function(pattern) {
var arg = args[index++]; const arg = args[index++];
switch (pattern) { switch (pattern) {
case '%s': case '%s':
return String(arg); return String(arg);
...@@ -357,7 +358,7 @@ test.pending = function(message, var_args) { ...@@ -357,7 +358,7 @@ test.pending = function(message, var_args) {
return pattern; return pattern;
} }
}); });
var pendingMarker = Object.create(test.pending.prototype); const pendingMarker = Object.create(test.pending.prototype);
pendingMarker.message = formattedMessage; pendingMarker.message = formattedMessage;
return pendingMarker; return pendingMarker;
}; };
...@@ -371,9 +372,9 @@ test.pending = function(message, var_args) { ...@@ -371,9 +372,9 @@ test.pending = function(message, var_args) {
* marker. * marker.
*/ */
test.repeatUntil = function(checkFunction) { test.repeatUntil = function(checkFunction) {
var logTime = Date.now() + test.REPEAT_UNTIL_LOG_INTERVAL; let logTime = Date.now() + test.REPEAT_UNTIL_LOG_INTERVAL;
var loopCount = 0; let loopCount = 0;
var step = function() { const step = function() {
loopCount++; loopCount++;
return Promise.resolve(checkFunction()).then(function(result) { return Promise.resolve(checkFunction()).then(function(result) {
if (!(result instanceof test.pending)) { if (!(result instanceof test.pending)) {
...@@ -384,7 +385,7 @@ test.repeatUntil = function(checkFunction) { ...@@ -384,7 +385,7 @@ test.repeatUntil = function(checkFunction) {
logTime += test.REPEAT_UNTIL_LOG_INTERVAL; logTime += test.REPEAT_UNTIL_LOG_INTERVAL;
} }
// Repeat immediately for the first few, then wait between repeats. // Repeat immediately for the first few, then wait between repeats.
var interval = loopCount <= test.REPEAT_UNTIL_IMMEDIATE_COUNT ? const interval = loopCount <= test.REPEAT_UNTIL_IMMEDIATE_COUNT ?
0 : 0 :
test.REPEAT_UNTIL_INTERVAL; test.REPEAT_UNTIL_INTERVAL;
return new Promise(resolve => { return new Promise(resolve => {
...@@ -403,7 +404,7 @@ test.repeatUntil = function(checkFunction) { ...@@ -403,7 +404,7 @@ test.repeatUntil = function(checkFunction) {
*/ */
test.waitForElement = function(query) { test.waitForElement = function(query) {
return test.repeatUntil(() => { return test.repeatUntil(() => {
let element = document.querySelector(query); const element = document.querySelector(query);
if (element) { if (element) {
return element; return element;
} }
...@@ -418,7 +419,7 @@ test.waitForElement = function(query) { ...@@ -418,7 +419,7 @@ test.waitForElement = function(query) {
*/ */
test.waitForElementLost = function(query) { test.waitForElementLost = function(query) {
return test.repeatUntil(() => { return test.repeatUntil(() => {
var element = document.querySelector(query); const element = document.querySelector(query);
if (element) { if (element) {
return test.pending('Elements %s still exists.', query); return test.pending('Elements %s still exists.', query);
} }
...@@ -528,10 +529,10 @@ test.mountAndroidFiles = function() { ...@@ -528,10 +529,10 @@ test.mountAndroidFiles = function() {
* given contents. * given contents.
*/ */
test.waitForFiles = function(expected, opt_options) { test.waitForFiles = function(expected, opt_options) {
var options = opt_options || {}; const options = opt_options || {};
var nextLog = Date.now() + test.REPEAT_UNTIL_LOG_INTERVAL; let nextLog = Date.now() + test.REPEAT_UNTIL_LOG_INTERVAL;
return test.repeatUntil(function() { return test.repeatUntil(function() {
var files = test.getFileList(); const files = test.getFileList();
if (Date.now() > nextLog) { if (Date.now() > nextLog) {
console.debug('waitForFiles', expected, files); console.debug('waitForFiles', expected, files);
nextLog = Date.now() + test.REPEAT_UNTIL_LOG_INTERVAL; nextLog = Date.now() + test.REPEAT_UNTIL_LOG_INTERVAL;
...@@ -545,7 +546,7 @@ test.waitForFiles = function(expected, opt_options) { ...@@ -545,7 +546,7 @@ test.waitForFiles = function(expected, opt_options) {
if (a.length != b.length) { if (a.length != b.length) {
return false; return false;
} }
for (var i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
// Each row is [name, size, type, date]. // Each row is [name, size, type, date].
if ((!options.ignoreName && a[i][0] != b[i][0]) || if ((!options.ignoreName && a[i][0] != b[i][0]) ||
(!options.ignoreSize && a[i][1] != b[i][1]) || (!options.ignoreSize && a[i][1] != b[i][1]) ||
......
...@@ -10,7 +10,7 @@ const progressCenter = {}; ...@@ -10,7 +10,7 @@ const progressCenter = {};
* @return {!ProgressCenterItem} * @return {!ProgressCenterItem}
*/ */
progressCenter.createItem = function(id, message) { progressCenter.createItem = function(id, message) {
let item = new ProgressCenterItem(); const item = new ProgressCenterItem();
item.id = id; item.id = id;
item.message = message; item.message = message;
return item; return item;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment