diff --git a/services/cloudsync/CloudSyncBookmarks.jsm b/services/cloudsync/CloudSyncBookmarks.jsm index fba7f53f7a6..c3c8efbd9b9 100644 --- a/services/cloudsync/CloudSyncBookmarks.jsm +++ b/services/cloudsync/CloudSyncBookmarks.jsm @@ -554,7 +554,7 @@ var RootFolder = function (rootId, rootName) { } } - for each (let item in items) { + for (let item of items) { if (!item || 'object' !== typeof(item)) { continue; } @@ -570,7 +570,7 @@ var RootFolder = function (rootId, rootName) { let newFolderGuids = Object.keys(newFolders); let newFolderRoots = []; - for each (let guid in newFolderGuids) { + for (let guid of newFolderGuids) { let item = newFolders[guid]; if (item.parent && newFolderGuids.indexOf(item.parent) >= 0) { let parent = newFolders[item.parent]; @@ -581,7 +581,7 @@ var RootFolder = function (rootId, rootName) { }; let promises = []; - for each (let guid in newFolderRoots) { + for (let guid of newFolderRoots) { let root = newFolders[guid]; let promise = Promise.resolve(); promise = promise.then( @@ -611,15 +611,15 @@ var RootFolder = function (rootId, rootName) { let processItems = function () { let promises = []; - for each (let item in newItems) { + for (let item of newItems) { promises.push(_createItem(item)); } - for each (let item in updatedItems) { + for (let item of updatedItems) { promises.push(_updateItem(item)); } - for each (let item in deletedItems) { + for (let item of deletedItems) { _deleteItem(item); } diff --git a/services/cloudsync/CloudSyncEventSource.jsm b/services/cloudsync/CloudSyncEventSource.jsm index c17b60c594b..edb9c426b29 100644 --- a/services/cloudsync/CloudSyncEventSource.jsm +++ b/services/cloudsync/CloudSyncEventSource.jsm @@ -8,7 +8,7 @@ Components.utils.import("resource://services-common/utils.js"); var EventSource = function (types, suspendFunc, resumeFunc) { this.listeners = new Map(); - for each (let type in types) { + for (let type of types) { this.listeners.set(type, new Set()); } diff --git a/services/cloudsync/CloudSyncPlacesWrapper.jsm b/services/cloudsync/CloudSyncPlacesWrapper.jsm index 9aba94e9d43..dd8c5c52eb4 100644 --- a/services/cloudsync/CloudSyncPlacesWrapper.jsm +++ b/services/cloudsync/CloudSyncPlacesWrapper.jsm @@ -140,7 +140,7 @@ PlacesWrapper.prototype = { function (items) { let previousIds = folderCache.getChildren(folder); let currentIds = new Set(); - for each (let item in items) { + for (let item of items) { currentIds.add(item.id); } let newIds = new Set(); @@ -188,7 +188,7 @@ PlacesWrapper.prototype = { this.asyncQuery(query, ["item_id"]) .then(function (items) { let results = []; - for each(let item in items) { + for (let item of items) { results.push(item.item_id); } deferred.resolve(results); @@ -211,7 +211,7 @@ PlacesWrapper.prototype = { this.asyncQuery(query, ["name", "content"]) .then(function (results) { let annos = {}; - for each(let result in results) { + for (let result of results) { annos[result.name] = result.content; } deferred.resolve(annos); @@ -347,7 +347,7 @@ PlacesWrapper.prototype = { let row; while ((row = results.getNextRow()) != null) { let item = {}; - for each (let name in names) { + for (let name of names) { item[name] = row.getResultByName(name); } this.results.push(item); diff --git a/services/cloudsync/CloudSyncTabs.jsm b/services/cloudsync/CloudSyncTabs.jsm index acebeba2114..7debc26782b 100644 --- a/services/cloudsync/CloudSyncTabs.jsm +++ b/services/cloudsync/CloudSyncTabs.jsm @@ -87,7 +87,7 @@ TabCache.prototype = { this.clients.set(cRecord.id, cRecord); } - for each (let tab in tabs) { + for (let tab of tabs) { if (!tab || 'object' !== typeof(tab)) { continue; } @@ -158,7 +158,7 @@ this.Tabs = function () { }; let registerListenersForWindow = function (window) { - for each (let topic in topics) { + for (let topic of topics) { window.addEventListener(topic, update, false); } window.addEventListener("unload", unregisterListeners, false); @@ -166,7 +166,7 @@ this.Tabs = function () { let unregisterListenersForWindow = function (window) { window.removeEventListener("unload", unregisterListeners, false); - for each (let topic in topics) { + for (let topic of topics) { window.removeEventListener(topic, update, false); } }; diff --git a/services/common/async.js b/services/common/async.js index 6ba0de2a52a..680f5e45ff1 100644 --- a/services/common/async.js +++ b/services/common/async.js @@ -177,7 +177,7 @@ this.Async = { let row; while ((row = results.getNextRow()) != null) { let item = {}; - for each (let name in this.names) { + for (let name of this.names) { item[name] = row.getResultByName(name); } this.results.push(item); diff --git a/services/common/modules-testing/storageserver.js b/services/common/modules-testing/storageserver.js index c876b5aba22..94c787c4e2a 100644 --- a/services/common/modules-testing/storageserver.js +++ b/services/common/modules-testing/storageserver.js @@ -102,7 +102,7 @@ ServerBSO.prototype = { toJSON: function toJSON() { let obj = {}; - for each (let key in this.FIELDS) { + for (let key of this.FIELDS) { if (this[key] !== undefined) { obj[key] = this[key]; } @@ -306,7 +306,7 @@ StorageServerCollection.prototype = { get totalPayloadSize() { let size = 0; - for each (let bso in this.bsos()) { + for (let bso of this.bsos()) { size += bso.payload.length; } @@ -441,7 +441,8 @@ StorageServerCollection.prototype = { get: function get(options) { let data = []; - for each (let bso in this._bsos) { + for (let id in this._bsos) { + let bso = this._bsos[id]; if (!bso.modified) { continue; } @@ -504,7 +505,7 @@ StorageServerCollection.prototype = { // This will count records where we have an existing ServerBSO // registered with us as successful and all other records as failed. - for each (let record in input) { + for (let record of input) { count += 1; if (count > this.BATCH_MAX_COUNT) { failed[record.id] = "Max record count exceeded."; @@ -602,7 +603,7 @@ StorageServerCollection.prototype = { parseOptions: function parseOptions(request) { let options = {}; - for each (let chunk in request.queryString.split("&")) { + for (let chunk of request.queryString.split("&")) { if (!chunk) { continue; } @@ -656,7 +657,7 @@ StorageServerCollection.prototype = { let requestModified = parseInt(request.getHeader("x-if-modified-since"), 10); let newestBSO = 0; - for each (let bso in data) { + for (let bso of data) { if (bso.modified > newestBSO) { newestBSO = bso.modified; } @@ -746,7 +747,7 @@ StorageServerCollection.prototype = { return sendMozSvcError(request, response, "8"); } } else if (inputMediaType == "application/newlines") { - for each (let line in inputBody.split("\n")) { + for (let line of inputBody.split("\n")) { let record; try { record = JSON.parse(line); @@ -1078,7 +1079,8 @@ StorageServer.prototype = { throw new Error("Unknown user."); } let userCollections = this.users[username].collections; - for each (let [name, coll] in Iterator(userCollections)) { + for (let name in userCollections) { + let coll = userCollections[name]; this._log.trace("Bulk deleting " + name + " for " + username + "..."); coll.delete({}); } @@ -1099,7 +1101,8 @@ StorageServer.prototype = { newestCollectionTimestamp: function newestCollectionTimestamp(username) { let collections = this.users[username].collections; let newest = 0; - for each (let collection in collections) { + for (let name in collections) { + let collection = collections[name]; if (collection.timestamp > newest) { newest = collection.timestamp; } @@ -1149,7 +1152,9 @@ StorageServer.prototype = { infoQuota: function infoQuota(username) { let total = 0; - for each (let value in this.infoUsage(username)) { + let usage = this.infoUsage(username); + for (let key in usage) { + let value = usage[key]; total += value; } @@ -1191,9 +1196,11 @@ StorageServer.prototype = { _pruneExpired: function _pruneExpired() { let now = Date.now(); - for each (let user in this.users) { - for each (let collection in user.collections) { - for each (let bso in collection.bsos()) { + for (let username in this.users) { + let user = this.users[username]; + for (let name in user.collections) { + let collection = user.collections[name]; + for (let bso of collection.bsos()) { // ttl === 0 is a special case, so we can't simply !ttl. if (typeof(bso.ttl) != "number") { continue; @@ -1240,7 +1247,11 @@ StorageServer.prototype = { respond: function respond(req, resp, code, status, body, headers, timestamp) { this._log.info("Response: " + code + " " + status); resp.setStatusLine(req.httpVersion, code, status); - for each (let [header, value] in Iterator(headers || this.defaultHeaders)) { + if (!headers) { + headers = this.defaultHeaders; + } + for (let header in headers) { + let value = headers[header]; resp.setHeader(header, value, false); } diff --git a/services/common/stringbundle.js b/services/common/stringbundle.js index 4e6a34c0540..a07fa4831ed 100644 --- a/services/common/stringbundle.js +++ b/services/common/stringbundle.js @@ -24,7 +24,7 @@ var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; * new StringBundle("chrome://example/locale/strings.properties"); * let foo = strings.get("foo"); * let barFormatted = strings.get("bar", [arg1, arg2]); - * for each (let string in strings.getAll()) + * for (let string of strings.getAll()) * dump (string.key + " = " + string.value + "\n"); * * @param url {String} diff --git a/services/common/tests/mach_commands.py b/services/common/tests/mach_commands.py index 97977cafe61..6777b81e4ce 100644 --- a/services/common/tests/mach_commands.py +++ b/services/common/tests/mach_commands.py @@ -87,7 +87,7 @@ class SyncTestCommands(MachCommandBase): '-e', 'const SERVER_PORT = "%s";' % port, '-e', 'const INCLUDE_FILES = [%s];' % ', '.join(head_paths), '-e', '_register_protocol_handlers();', - '-e', 'for each (let name in INCLUDE_FILES) load(name);', + '-e', 'for (let name of INCLUDE_FILES) load(name);', '-e', '_fakeIdleService.activate();', '-f', js_file ] diff --git a/services/common/tests/unit/head_global.js b/services/common/tests/unit/head_global.js index d1006ab8b50..b278780bb2c 100644 --- a/services/common/tests/unit/head_global.js +++ b/services/common/tests/unit/head_global.js @@ -42,7 +42,7 @@ function addResourceAlias() { .QueryInterface(Ci.nsIResProtocolHandler); let modules = ["common", "crypto"]; - for each (let module in modules) { + for (let module of modules) { let uri = Services.io.newURI("resource://gre/modules/services-" + module + "/", null, null); handler.setSubstitution("services-" + module, uri); diff --git a/services/common/tests/unit/test_load_modules.js b/services/common/tests/unit/test_load_modules.js index 1e159dfebcb..b549c93ef09 100644 --- a/services/common/tests/unit/test_load_modules.js +++ b/services/common/tests/unit/test_load_modules.js @@ -34,7 +34,7 @@ const non_android_healthreport_test_modules = [ ]; function expectImportsToSucceed(mm, base=MODULE_BASE) { - for each (let m in mm) { + for (let m of mm) { let resource = base + m; let succeeded = false; try { @@ -49,7 +49,7 @@ function expectImportsToSucceed(mm, base=MODULE_BASE) { } function expectImportsToFail(mm, base=MODULE_BASE) { - for each (let m in mm) { + for (let m of mm) { let resource = base + m; let succeeded = false; try { diff --git a/services/common/tests/unit/test_tokenserverclient.js b/services/common/tests/unit/test_tokenserverclient.js index 65ae471eb51..b24d2fbec4f 100644 --- a/services/common/tests/unit/test_tokenserverclient.js +++ b/services/common/tests/unit/test_tokenserverclient.js @@ -60,7 +60,7 @@ add_test(function test_invalid_arguments() { ["http://example.com/", "assertion", null] ]; - for each (let arg in args) { + for (let arg of args) { try { let client = new TokenServerClient(); client.getTokenFromBrowserIDAssertion(arg[0], arg[1], arg[2]); diff --git a/services/common/utils.js b/services/common/utils.js index 69571837f60..16a18a98a36 100644 --- a/services/common/utils.js +++ b/services/common/utils.js @@ -205,16 +205,15 @@ this.CommonUtils = { }, byteArrayToString: function byteArrayToString(bytes) { - return [String.fromCharCode(byte) for each (byte in bytes)].join(""); + return bytes.map(byte => String.fromCharCode(byte)).join(""); }, stringToByteArray: function stringToByteArray(bytesString) { - return [String.charCodeAt(byte) for each (byte in bytesString)]; + return Array.prototype.slice.call(bytesString).map(c => c.charCodeAt(0)); }, bytesAsHex: function bytesAsHex(bytes) { - return [("0" + bytes.charCodeAt(byte).toString(16)).slice(-2) - for (byte in bytes)].join(""); + return Array.prototype.slice.call(bytes).map(c => ("0" + c.charCodeAt(0).toString(16)).slice(-2)).join(""); }, stringAsHex: function stringAsHex(str) { @@ -256,7 +255,7 @@ this.CommonUtils = { // is turned into 8 characters from the 32 character base. let ret = ""; for (let i = 0; i < bytes.length; i += 5) { - let c = [byte.charCodeAt() for each (byte in bytes.slice(i, i + 5))]; + let c = Array.prototype.slice.call(bytes.slice(i, i + 5)).map(byte => byte.charCodeAt(0)); ret += key[c[0] >> 3] + key[((c[0] << 2) & 0x1f) | (c[1] >> 6)] + key[(c[1] >> 1) & 0x1f] diff --git a/services/crypto/modules/utils.js b/services/crypto/modules/utils.js index ca4da86477a..0c727c2c507 100644 --- a/services/crypto/modules/utils.js +++ b/services/crypto/modules/utils.js @@ -56,7 +56,7 @@ this.CryptoUtils = { */ digestBytes: function digestBytes(message, hasher) { // No UTF-8 encoding for you, sunshine. - let bytes = [b.charCodeAt() for each (b in message)]; + let bytes = Array.prototype.slice.call(message).map(b => b.charCodeAt(0)); hasher.update(bytes, bytes.length); let result = hasher.finish(false); if (hasher instanceof Ci.nsICryptoHMAC) { diff --git a/services/crypto/tests/unit/test_load_modules.js b/services/crypto/tests/unit/test_load_modules.js index 2b9a1485643..50f5d709c5b 100644 --- a/services/crypto/tests/unit/test_load_modules.js +++ b/services/crypto/tests/unit/test_load_modules.js @@ -7,7 +7,7 @@ const modules = [ ]; function run_test() { - for each (let m in modules) { + for (let m of modules) { let resource = "resource://services-crypto/" + m; _("Attempting to import: " + resource); Components.utils.import(resource, {}); diff --git a/services/metrics/providermanager.jsm b/services/metrics/providermanager.jsm index 90be563a97e..cf26d444b29 100644 --- a/services/metrics/providermanager.jsm +++ b/services/metrics/providermanager.jsm @@ -282,7 +282,8 @@ this.ProviderManager.prototype = Object.freeze({ } } - for each (let providerType in this._pullOnlyProviders) { + for (let name in this._pullOnlyProviders) { + let providerType = this._pullOnlyProviders[name]; // Short-circuit if we're no longer registering. if (this._pullOnlyProvidersState != this.PULL_ONLY_REGISTERING) { this._log.debug("Aborting pull-only provider registration."); diff --git a/services/sync/modules/addonsreconciler.js b/services/sync/modules/addonsreconciler.js index 2c16e2e81e6..58605f55d56 100644 --- a/services/sync/modules/addonsreconciler.js +++ b/services/sync/modules/addonsreconciler.js @@ -218,11 +218,12 @@ AddonsReconciler.prototype = { } this._addons = json.addons; - for each (let record in this._addons) { + for (let id in this._addons) { + let record = this._addons[id]; record.modified = new Date(record.modified); } - for each (let [time, change, id] in json.changes) { + for (let [time, change, id] of json.changes) { this._changes.push([new Date(time), change, id]); } @@ -258,7 +259,7 @@ AddonsReconciler.prototype = { } } - for each (let [time, change, id] in this._changes) { + for (let [time, change, id] of this._changes) { state.changes.push([time.getTime(), change, id]); } @@ -350,7 +351,7 @@ AddonsReconciler.prototype = { AddonManager.getAllAddons(function (addons) { let ids = {}; - for each (let addon in addons) { + for (let addon of addons) { ids[addon.id] = true; this.rectifyStateFromAddon(addon); } @@ -373,7 +374,7 @@ AddonsReconciler.prototype = { } let installFound = false; - for each (let install in installs) { + for (let install of installs) { if (install.addon && install.addon.id == id && install.state == AddonManager.STATE_INSTALLED) { @@ -483,7 +484,7 @@ AddonsReconciler.prototype = { this._log.info("Change recorded for " + state.id); this._changes.push([date, change, state.id]); - for each (let listener in this._listeners) { + for (let listener of this._listeners) { try { listener.changeListener.call(listener, date, change, state); } catch (ex) { @@ -554,7 +555,8 @@ AddonsReconciler.prototype = { * @return Object on success on null on failure. */ getAddonStateFromSyncGUID: function getAddonStateFromSyncGUID(guid) { - for each (let addon in this.addons) { + for (let id in this.addons) { + let addon = this.addons[id]; if (addon.guid == guid) { return addon; } diff --git a/services/sync/modules/addonutils.js b/services/sync/modules/addonutils.js index 63d9578d038..3a29901c13b 100644 --- a/services/sync/modules/addonutils.js +++ b/services/sync/modules/addonutils.js @@ -248,7 +248,7 @@ AddonUtilsInternal.prototype = { } let ids = []; - for each (let addon in installs) { + for (let addon of installs) { ids.push(addon.id); } @@ -298,7 +298,7 @@ AddonUtilsInternal.prototype = { // server-side metrics aren't skewed (bug 708134). The server should // ideally send proper URLs, but this solution was deemed too // complicated at the time the functionality was implemented. - for each (let addon in addons) { + for (let addon of addons) { // sourceURI presence isn't enforced by AddonRepository. So, we skip // add-ons without a sourceURI. if (!addon.sourceURI) { @@ -342,9 +342,9 @@ AddonUtilsInternal.prototype = { // Start all the installs asynchronously. They will report back to us // as they finish, eventually triggering the global callback. - for each (let addon in toInstall) { + for (let addon of toInstall) { let options = {}; - for each (let install in installs) { + for (let install of installs) { if (install.id == addon.id) { options = install; break; diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 04e91e7b18c..21dee0324d2 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -299,7 +299,7 @@ Store.prototype = { */ applyIncomingBatch: function (records) { let failed = []; - for each (let record in records) { + for (let record of records) { try { this.applyIncoming(record); } catch (ex if (ex.code == Engine.prototype.eEngineAbortApplyIncoming)) { @@ -497,7 +497,7 @@ EngineManager.prototype = { }, get enabledEngineNames() { - return [e.name for each (e in this.getEnabled())]; + return this.getEnabled().map(e => e.name); }, persistDeclined: function () { @@ -1464,14 +1464,15 @@ SyncEngine.prototype = { + failed_ids.join(", ")); // Clear successfully uploaded objects. - for each (let id in resp.obj.success) { + for (let key in resp.obj.success) { + let id = resp.obj.success[key]; delete this._modified[id]; } up.clearRecords(); }); - for each (let id in modifiedIDs) { + for (let id of modifiedIDs) { try { let out = this._createRecord(id); if (this._log.level <= Log.Level.Trace) diff --git a/services/sync/modules/engines/addons.js b/services/sync/modules/engines/addons.js index 5bf818db708..eabc66a86ae 100644 --- a/services/sync/modules/engines/addons.js +++ b/services/sync/modules/engines/addons.js @@ -160,7 +160,7 @@ AddonsEngine.prototype = { // we assume this function is only called from within a sync. let reconcilerChanges = this._reconciler.getChangesSinceDate(lastSyncDate); let addons = this._reconciler.addons; - for each (let change in reconcilerChanges) { + for (let change of reconcilerChanges) { let changeTime = change[0]; let id = change[2]; @@ -299,7 +299,7 @@ AddonsStore.prototype = { let results = cb.wait(); let addon; - for each (let a in results.addons) { + for (let a of results.addons) { if (a.id == record.addonID) { addon = a; break; @@ -443,7 +443,8 @@ AddonsStore.prototype = { let ids = {}; let addons = this.reconciler.addons; - for each (let addon in addons) { + for (let id in addons) { + let addon = addons[id]; if (this.isAddonSyncable(addon)) { ids[addon.guid] = true; } diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 81b96344d39..d59f3b26da7 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -179,7 +179,7 @@ var kSpecialIds = { // Don't bother creating mobile: if it doesn't exist, this ID can't be it! specialGUIDForId: function specialGUIDForId(id) { - for each (let guid in this.guids) + for (let guid of this.guids) if (this.specialIdForGUID(guid, false) == id) return guid; return null; @@ -507,7 +507,8 @@ function BookmarksStore(name, engine) { // Explicitly nullify our references to our cached services so we don't leak Svc.Obs.add("places-shutdown", function() { - for each (let [query, stmt] in Iterator(this._stmts)) { + for (let query in this._stmts) { + let stmt = this._stmts[query]; stmt.finalize(); } this._stmts = {}; @@ -564,7 +565,7 @@ BookmarksStore.prototype = { this._log.debug("Tag query folder: " + tag + " = " + child.itemId); this._log.trace("Replacing folders in: " + uri); - for each (let q in queriesRef.value) + for (let q of queriesRef.value) q.setFolders([child.itemId], 1); record.bmkUri = PlacesUtils.history.queriesToQueryString( @@ -1361,7 +1362,7 @@ BookmarksStore.prototype = { if (kSpecialIds.findMobileRoot(false)) { items["mobile"] = true; } - for each (let guid in kSpecialIds.guids) { + for (let guid of kSpecialIds.guids) { if (guid != "places" && guid != "tags") this._getChildren(guid, items); } @@ -1373,7 +1374,7 @@ BookmarksStore.prototype = { Task.spawn(function() { // Save a backup before clearing out all bookmarks. yield PlacesBackups.create(null, true); - for each (let guid in kSpecialIds.guids) + for (let guid of kSpecialIds.guids) if (guid != "places") { let id = kSpecialIds.specialIdForGUID(guid); if (id) diff --git a/services/sync/modules/engines/clients.js b/services/sync/modules/engines/clients.js index 05e0974c443..96b1766b8a3 100644 --- a/services/sync/modules/engines/clients.js +++ b/services/sync/modules/engines/clients.js @@ -68,7 +68,8 @@ ClientEngine.prototype = { numClients: 1, }; - for each (let {name, type} in this._store._remoteClients) { + for (let id in this._store._remoteClients) { + let {name, type} = this._store._remoteClients[id]; stats.hasMobile = stats.hasMobile || type == "mobile"; stats.names.push(name); stats.numClients++; @@ -87,7 +88,8 @@ ClientEngine.prototype = { counts.set(this.localType, 1); - for each (let record in this._store._remoteClients) { + for (let id in this._store._remoteClients) { + let record = this._store._remoteClients[id]; let type = record.type; if (!counts.has(type)) { counts.set(type, 0); @@ -258,7 +260,11 @@ ClientEngine.prototype = { this.clearCommands(); // Process each command in order. - for each (let {command, args} in commands) { + if (!commands) { + return true; + } + for (let key in commands) { + let {command, args} = commands[key]; this._log.debug("Processing command: " + command + "(" + args + ")"); let engines = [args[0]]; diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index 3735f6262de..62c999533d9 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -70,7 +70,8 @@ function HistoryStore(name, engine) { // Explicitly nullify our references to our cached services so we don't leak Svc.Obs.add("places-shutdown", function() { - for each ([query, stmt] in Iterator(this._stmts)) { + for (let query in this._stmts) { + let stmt = this._stmts; stmt.finalize(); } this._stmts = {}; diff --git a/services/sync/modules/engines/passwords.js b/services/sync/modules/engines/passwords.js index 9ebbb4d7b5b..b570ab654f3 100644 --- a/services/sync/modules/engines/passwords.js +++ b/services/sync/modules/engines/passwords.js @@ -85,7 +85,7 @@ PasswordEngine.prototype = { this._store._sleep(0); // Yield back to main thread after synchronous operation. // Look for existing logins that match the hostname, but ignore the password. - for each (let local in logins) { + for (let local of logins) { if (login.matches(local, true) && local instanceof Ci.nsILoginMetaInfo) { return local.guid; } diff --git a/services/sync/modules/engines/prefs.js b/services/sync/modules/engines/prefs.js index 63174083e3f..e801f0147df 100644 --- a/services/sync/modules/engines/prefs.js +++ b/services/sync/modules/engines/prefs.js @@ -101,7 +101,7 @@ PrefStore.prototype = { _getAllPrefs: function () { let values = {}; - for each (let pref in this._getSyncPrefs()) { + for (let pref of this._getSyncPrefs()) { if (this._isSynced(pref)) { // Missing prefs get the null value. values[pref] = this._prefs.get(pref, null); diff --git a/services/sync/modules/engines/tabs.js b/services/sync/modules/engines/tabs.js index 5bd775fa8ac..167faf62563 100644 --- a/services/sync/modules/engines/tabs.js +++ b/services/sync/modules/engines/tabs.js @@ -302,7 +302,7 @@ TabTracker.prototype = { _registerListenersForWindow: function (window) { this._log.trace("Registering tab listeners in window"); - for each (let topic in this._topics) { + for (let topic of this._topics) { window.addEventListener(topic, this.onTab, false); } window.addEventListener("unload", this._unregisterListeners, false); @@ -315,7 +315,7 @@ TabTracker.prototype = { _unregisterListenersForWindow: function (window) { this._log.trace("Removing tab listeners in window"); window.removeEventListener("unload", this._unregisterListeners, false); - for each (let topic in this._topics) { + for (let topic of this._topics) { window.removeEventListener(topic, this.onTab, false); } }, diff --git a/services/sync/modules/identity.js b/services/sync/modules/identity.js index b1f26ac997e..66c1e4b6b98 100644 --- a/services/sync/modules/identity.js +++ b/services/sync/modules/identity.js @@ -195,7 +195,7 @@ IdentityManager.prototype = { return null; } - for each (let login in this._getLogins(PWDMGR_PASSWORD_REALM)) { + for (let login of this._getLogins(PWDMGR_PASSWORD_REALM)) { if (login.username.toLowerCase() == username) { // It should already be UTF-8 encoded, but we don't take any chances. this._basicPassword = Utils.encodeUTF8(login.password); @@ -249,7 +249,7 @@ IdentityManager.prototype = { return null; } - for each (let login in this._getLogins(PWDMGR_PASSPHRASE_REALM)) { + for (let login of this._getLogins(PWDMGR_PASSPHRASE_REALM)) { if (login.username.toLowerCase() == username) { this._syncKey = login.password; } @@ -400,7 +400,7 @@ IdentityManager.prototype = { this._setLogin(PWDMGR_PASSWORD_REALM, this.username, this._basicPassword); } else { - for each (let login in this._getLogins(PWDMGR_PASSWORD_REALM)) { + for (let login of this._getLogins(PWDMGR_PASSWORD_REALM)) { Services.logins.removeLogin(login); } } @@ -412,7 +412,7 @@ IdentityManager.prototype = { if (this._syncKey) { this._setLogin(PWDMGR_PASSPHRASE_REALM, this.username, this._syncKey); } else { - for each (let login in this._getLogins(PWDMGR_PASSPHRASE_REALM)) { + for (let login of this._getLogins(PWDMGR_PASSPHRASE_REALM)) { Services.logins.removeLogin(login); } } @@ -466,7 +466,7 @@ IdentityManager.prototype = { */ _setLogin: function _setLogin(realm, username, password) { let exists = false; - for each (let login in this._getLogins(realm)) { + for (let login of this._getLogins(realm)) { if (login.username == username && login.password == password) { exists = true; } else { @@ -502,7 +502,7 @@ IdentityManager.prototype = { deleteSyncCredentials: function deleteSyncCredentials() { for (let host of this._getSyncCredentialsHosts()) { let logins = Services.logins.findLogins({}, host, "", ""); - for each (let login in logins) { + for (let login of logins) { Services.logins.removeLogin(login); } } diff --git a/services/sync/modules/jpakeclient.js b/services/sync/modules/jpakeclient.js index 51099da08c7..625dc91b6c3 100644 --- a/services/sync/modules/jpakeclient.js +++ b/services/sync/modules/jpakeclient.js @@ -281,8 +281,7 @@ JPAKEClient.prototype = { let rng = Cc["@mozilla.org/security/random-generator;1"] .createInstance(Ci.nsIRandomGenerator); let bytes = rng.generateRandomBytes(JPAKE_LENGTH_CLIENTID / 2); - this._clientID = [("0" + byte.toString(16)).slice(-2) - for each (byte in bytes)].join(""); + this._clientID = bytes.map(byte => ("0" + byte.toString(16)).slice(-2)).join(""); }, _createSecret: function _createSecret() { @@ -291,8 +290,7 @@ JPAKEClient.prototype = { let rng = Cc["@mozilla.org/security/random-generator;1"] .createInstance(Ci.nsIRandomGenerator); let bytes = rng.generateRandomBytes(JPAKE_LENGTH_SECRET); - return [key[Math.floor(byte * key.length / 256)] - for each (byte in bytes)].join(""); + return bytes.map(byte => key[Math.floor(byte * key.length / 256)]).join(""); }, _newRequest: function _newRequest(uri) { diff --git a/services/sync/modules/record.js b/services/sync/modules/record.js index 95f70cd1ad7..654a88aef0a 100644 --- a/services/sync/modules/record.js +++ b/services/sync/modules/record.js @@ -312,7 +312,7 @@ CollectionKeyManager.prototype = { // Return a sorted, unique array. changed.sort(); let last; - changed = [x for each (x in changed) if ((x != last) && (last = x))]; + changed = changed.filter(x => (x != last) && (last = x)); return {same: changed.length == 0, changed: changed}; }, diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 8ea99a2454b..5e78051cece 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -442,7 +442,7 @@ Sync11Service.prototype = { // Map each old pref to the current pref branch let oldPref = new Preferences(oldPrefBranch); - for each (let pref in oldPrefNames) + for (let pref of oldPrefNames) Svc.Prefs.set(pref, oldPref.get(pref)); // Remove all the old prefs and remember that we've migrated @@ -901,7 +901,7 @@ Sync11Service.prototype = { // Deletion doesn't make sense if we aren't set up yet! if (this.clusterURL != "") { // Clear client-specific data from the server, including disabled engines. - for each (let engine in [this.clientsEngine].concat(this.engineManager.getAll())) { + for (let engine of [this.clientsEngine].concat(this.engineManager.getAll())) { try { engine.removeClientData(); } catch(ex) { @@ -1511,7 +1511,7 @@ Sync11Service.prototype = { // Wipe everything we know about except meta because we just uploaded it let engines = [this.clientsEngine].concat(this.engineManager.getAll()); - let collections = [engine.name for each (engine in engines)]; + let collections = engines.map(engine => engine.name); // TODO: there's a bug here. We should be calling resetClient, no? // Generate, upload, and download new keys. Do this last so we don't wipe @@ -1593,7 +1593,7 @@ Sync11Service.prototype = { } // Fully wipe each engine if it's able to decrypt data - for each (let engine in engines) { + for (let engine of engines) { if (engine.canDecrypt()) { engine.wipeClient(); } @@ -1671,7 +1671,7 @@ Sync11Service.prototype = { } // Have each engine drop any temporary meta data - for each (let engine in engines) { + for (let engine of engines) { engine.resetClient(); } })(); diff --git a/services/sync/modules/stages/declined.js b/services/sync/modules/stages/declined.js index 3c53e2c75c9..ff8a141812d 100644 --- a/services/sync/modules/stages/declined.js +++ b/services/sync/modules/stages/declined.js @@ -29,8 +29,8 @@ this.DeclinedEngines = function (service) { } this.DeclinedEngines.prototype = { updateDeclined: function (meta, engineManager=this.service.engineManager) { - let enabled = new Set([e.name for each (e in engineManager.getEnabled())]); - let known = new Set([e.name for each (e in engineManager.getAll())]); + let enabled = new Set(engineManager.getEnabled().map(e => e.name)); + let known = new Set(engineManager.getAll().map(e => e.name)); let remoteDeclined = new Set(meta.payload.declined || []); let localDeclined = new Set(engineManager.getDeclined()); diff --git a/services/sync/modules/stages/enginesync.js b/services/sync/modules/stages/enginesync.js index f174c253d44..a2fe31b0cef 100644 --- a/services/sync/modules/stages/enginesync.js +++ b/services/sync/modules/stages/enginesync.js @@ -289,7 +289,7 @@ EngineSynchronizer.prototype = { } // Any remaining engines were either enabled locally or disabled remotely. - for each (let engineName in enabled) { + for (let engineName of enabled) { let engine = engineManager.get(engineName); if (Svc.Prefs.get("engineStatusChanged." + engine.prefName, false)) { this._log.trace("The " + engineName + " engine was enabled locally."); diff --git a/services/sync/tests/unit/head_appinfo.js b/services/sync/tests/unit/head_appinfo.js index b99d4e0cb09..3ade823f7b4 100644 --- a/services/sync/tests/unit/head_appinfo.js +++ b/services/sync/tests/unit/head_appinfo.js @@ -60,7 +60,7 @@ registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}" function addResourceAlias() { const resProt = Services.io.getProtocolHandler("resource") .QueryInterface(Ci.nsIResProtocolHandler); - for each (let s in ["common", "sync", "crypto"]) { + for (let s of ["common", "sync", "crypto"]) { let uri = Services.io.newURI("resource://gre/modules/services-" + s + "/", null, null); resProt.setSubstitution("services-" + s, uri); diff --git a/services/sync/tests/unit/head_http_server.js b/services/sync/tests/unit/head_http_server.js index c78faf5eb91..f215e47fe91 100644 --- a/services/sync/tests/unit/head_http_server.js +++ b/services/sync/tests/unit/head_http_server.js @@ -309,7 +309,8 @@ ServerCollection.prototype = { // This will count records where we have an existing ServerWBO // registered with us as successful and all other records as failed. - for each (let record in input) { + for (let key in input) { + let record = input[key]; let wbo = this.wbo(record.id); if (!wbo && this.acceptNew) { this._log.debug("Creating WBO " + JSON.stringify(record.id) + @@ -354,7 +355,7 @@ ServerCollection.prototype = { // Parse queryString let options = {}; - for each (let chunk in request.queryString.split("&")) { + for (let chunk of request.queryString.split("&")) { if (!chunk) { continue; } @@ -704,7 +705,8 @@ SyncServer.prototype = { throw new Error("Unknown user."); } let userCollections = this.users[username].collections; - for each (let [name, coll] in Iterator(userCollections)) { + for (let name in userCollections) { + let coll = userCollections[name]; this._log.trace("Bulk deleting " + name + " for " + username + "..."); coll.delete({}); } @@ -768,7 +770,10 @@ SyncServer.prototype = { */ respond: function respond(req, resp, code, status, body, headers) { resp.setStatusLine(req.httpVersion, code, status); - for each (let [header, value] in Iterator(headers || this.defaultHeaders)) { + if (!headers) + headers = this.defaultHeaders; + for (let header in headers) { + let value = headers[header]; resp.setHeader(header, value); } resp.setHeader("X-Weave-Timestamp", "" + this.timestamp(), false); diff --git a/services/sync/tests/unit/test_addons_reconciler.js b/services/sync/tests/unit/test_addons_reconciler.js index 8cfa37d78f4..d93bdfc0380 100644 --- a/services/sync/tests/unit/test_addons_reconciler.js +++ b/services/sync/tests/unit/test_addons_reconciler.js @@ -71,7 +71,7 @@ add_test(function test_install_detection() { const KEYS = ["id", "guid", "enabled", "installed", "modified", "type", "scope", "foreignInstall"]; - for each (let key in KEYS) { + for (let key of KEYS) { do_check_true(key in record); do_check_neq(null, record[key]); } diff --git a/services/sync/tests/unit/test_addons_store.js b/services/sync/tests/unit/test_addons_store.js index d79c18a3f4b..6bb78787ad1 100644 --- a/services/sync/tests/unit/test_addons_store.js +++ b/services/sync/tests/unit/test_addons_store.js @@ -204,7 +204,7 @@ add_test(function test_addon_syncability() { let dummy = {}; const KEYS = ["id", "syncGUID", "type", "scope", "foreignInstall"]; - for each (let k in KEYS) { + for (let k of KEYS) { dummy[k] = addon[k]; } @@ -243,16 +243,16 @@ add_test(function test_addon_syncability() { "https://untrusted.example.com/foo", // non-trusted hostname` ]; - for each (let uri in trusted) { + for (let uri of trusted) { do_check_true(store.isSourceURITrusted(createURI(uri))); } - for each (let uri in untrusted) { + for (let uri of untrusted) { do_check_false(store.isSourceURITrusted(createURI(uri))); } Svc.Prefs.set("addons.trustedSourceHostnames", ""); - for each (let uri in trusted) { + for (let uri of trusted) { do_check_false(store.isSourceURITrusted(createURI(uri))); } @@ -278,7 +278,7 @@ add_test(function test_ignore_hotfixes() { let dummy = {}; const KEYS = ["id", "syncGUID", "type", "scope", "foreignInstall"]; - for each (let k in KEYS) { + for (let k of KEYS) { dummy[k] = addon[k]; } diff --git a/services/sync/tests/unit/test_bookmark_store.js b/services/sync/tests/unit/test_bookmark_store.js index ec6d51fba9b..ad16130852d 100644 --- a/services/sync/tests/unit/test_bookmark_store.js +++ b/services/sync/tests/unit/test_bookmark_store.js @@ -80,8 +80,8 @@ add_test(function test_bookmark_create() { _("Have the store create a new record object. Verify that it has the same data."); let newrecord = store.createRecord(fxrecord.id); do_check_true(newrecord instanceof Bookmark); - for each (let property in ["type", "bmkUri", "description", "title", - "keyword", "parentName", "parentid"]) { + for (let property of ["type", "bmkUri", "description", "title", + "keyword", "parentName", "parentid"]) { do_check_eq(newrecord[property], fxrecord[property]); } do_check_true(Utils.deepEquals(newrecord.tags.sort(), @@ -197,7 +197,7 @@ add_test(function test_folder_create() { _("Have the store create a new record object. Verify that it has the same data."); let newrecord = store.createRecord(folder.id); do_check_true(newrecord instanceof BookmarkFolder); - for each (let property in ["title", "parentName", "parentid"]) + for (let property of ["title", "parentName", "parentid"]) do_check_eq(newrecord[property], folder[property]); _("Folders have high sort index to ensure they're synced first."); diff --git a/services/sync/tests/unit/test_clients_engine.js b/services/sync/tests/unit/test_clients_engine.js index 2898d9eb334..e571be724f1 100644 --- a/services/sync/tests/unit/test_clients_engine.js +++ b/services/sync/tests/unit/test_clients_engine.js @@ -328,7 +328,7 @@ add_test(function test_command_validation() { ["__UNKNOWN__", [], false] ]; - for each (let [action, args, expectedResult] in testCommands) { + for (let [action, args, expectedResult] of testCommands) { let remoteId = Utils.makeGUID(); let rec = new ClientsRec("clients", remoteId); diff --git a/services/sync/tests/unit/test_collections_recovery.js b/services/sync/tests/unit/test_collections_recovery.js index 377a05383d6..06ec0ab8c16 100644 --- a/services/sync/tests/unit/test_collections_recovery.js +++ b/services/sync/tests/unit/test_collections_recovery.js @@ -33,7 +33,7 @@ add_identity_test(this, function test_missing_crypto_collection() { }; let collections = ["clients", "bookmarks", "forms", "history", "passwords", "prefs", "tabs"]; - for each (let coll in collections) { + for (let coll of collections) { handlers["/1.1/johndoe/storage/" + coll] = johnU(coll, new ServerCollection({}, true).handler()); } diff --git a/services/sync/tests/unit/test_jpakeclient.js b/services/sync/tests/unit/test_jpakeclient.js index 7de35fe2f4c..783edb46037 100644 --- a/services/sync/tests/unit/test_jpakeclient.js +++ b/services/sync/tests/unit/test_jpakeclient.js @@ -369,7 +369,7 @@ add_test(function test_wrongPIN() { displayPIN: function displayPIN(pin) { this.cid = pin.slice(JPAKE_LENGTH_SECRET); let secret = pin.slice(0, JPAKE_LENGTH_SECRET); - secret = [char for each (char in secret)].reverse().join(""); + secret = Array.prototype.slice.call(secret).reverse().join(""); let new_pin = secret + this.cid; _("Received PIN " + pin + ", but I'm entering " + new_pin); diff --git a/services/sync/tests/unit/test_resource.js b/services/sync/tests/unit/test_resource.js index a7be57ded3d..1dc9daec351 100644 --- a/services/sync/tests/unit/test_resource.js +++ b/services/sync/tests/unit/test_resource.js @@ -140,7 +140,7 @@ function server_headers(metadata, response) { header_names = header_names.sort(); headers = {}; - for each (let header in header_names) { + for (let header of header_names) { headers[header] = metadata.getHeader(header); } let body = JSON.stringify(headers); diff --git a/services/sync/tests/unit/test_resource_async.js b/services/sync/tests/unit/test_resource_async.js index 9420f211872..0db91a1b59f 100644 --- a/services/sync/tests/unit/test_resource_async.js +++ b/services/sync/tests/unit/test_resource_async.js @@ -140,7 +140,7 @@ function server_headers(metadata, response) { header_names = header_names.sort(); headers = {}; - for each (let header in header_names) { + for (let header of header_names) { headers[header] = metadata.getHeader(header); } let body = JSON.stringify(headers); diff --git a/services/sync/tests/unit/test_service_startup.js b/services/sync/tests/unit/test_service_startup.js index 6ced39da931..7d96cad5288 100644 --- a/services/sync/tests/unit/test_service_startup.js +++ b/services/sync/tests/unit/test_service_startup.js @@ -29,7 +29,7 @@ function run_test() { _("Engines are registered."); let engines = Service.engineManager.getAll(); - do_check_true(Utils.deepEquals([engine.name for each (engine in engines)], + do_check_true(Utils.deepEquals(engines.map(engine => engine.name), ['tabs', 'bookmarks', 'forms', 'history'])); _("Observers are notified of startup"); diff --git a/services/sync/tests/unit/test_status.js b/services/sync/tests/unit/test_status.js index bc2d67f425f..378aafe9083 100644 --- a/services/sync/tests/unit/test_status.js +++ b/services/sync/tests/unit/test_status.js @@ -18,9 +18,9 @@ function run_test() { // Check login status - for each (let code in [LOGIN_FAILED_NO_USERNAME, - LOGIN_FAILED_NO_PASSWORD, - LOGIN_FAILED_NO_PASSPHRASE]) { + for (let code of [LOGIN_FAILED_NO_USERNAME, + LOGIN_FAILED_NO_PASSWORD, + LOGIN_FAILED_NO_PASSPHRASE]) { Status.login = code; do_check_eq(Status.login, code); do_check_eq(Status.service, CLIENT_NOT_CONFIGURED); diff --git a/services/sync/tests/unit/test_tab_tracker.js b/services/sync/tests/unit/test_tab_tracker.js index f0bff3cc91d..4605b066a94 100644 --- a/services/sync/tests/unit/test_tab_tracker.js +++ b/services/sync/tests/unit/test_tab_tracker.js @@ -53,7 +53,7 @@ function run_test() { logs = fakeSvcWinMediator(); Svc.Obs.notify("weave:engine:start-tracking"); do_check_eq(logs.length, 2); - for each (let log in logs) { + for (let log of logs) { do_check_eq(log.addTopics.length, 5); do_check_true(log.addTopics.indexOf("pageshow") >= 0); do_check_true(log.addTopics.indexOf("TabOpen") >= 0); @@ -67,7 +67,7 @@ function run_test() { logs = fakeSvcWinMediator(); Svc.Obs.notify("weave:engine:stop-tracking"); do_check_eq(logs.length, 2); - for each (let log in logs) { + for (let log of logs) { do_check_eq(log.addTopics.length, 0); do_check_eq(log.remTopics.length, 5); do_check_true(log.remTopics.indexOf("pageshow") >= 0); @@ -78,7 +78,7 @@ function run_test() { } _("Test tab listener"); - for each (let evttype in ["TabOpen", "TabClose", "TabSelect"]) { + for (let evttype of ["TabOpen", "TabClose", "TabSelect"]) { // Pretend we just synced. tracker.clearChangedIDs(); do_check_false(tracker.modified); diff --git a/services/sync/tps/extensions/mozmill/resource/driver/controller.js b/services/sync/tps/extensions/mozmill/resource/driver/controller.js index 846b9fc893d..6acc078e7fe 100644 --- a/services/sync/tps/extensions/mozmill/resource/driver/controller.js +++ b/services/sync/tps/extensions/mozmill/resource/driver/controller.js @@ -44,7 +44,11 @@ waitForEvents.prototype = { node.firedEvents = {}; this.registry = {}; - for each (var e in events) { + if (!events) { + return; + } + for (var key in events) { + var e = events[key]; var listener = function (event) { this.firedEvents[event.type] = true; } diff --git a/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js b/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js index ea371e5e6e1..4bf35a3846d 100644 --- a/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js +++ b/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js @@ -304,7 +304,7 @@ var _returnResult = function (results) { var _forChildren = function (element, name, value) { var results = []; - var nodes = [e for each (e in element.childNodes) if (e)] + var nodes = Array.from(element.childNodes).filter(e => e); for (var i in nodes) { var n = nodes[i]; @@ -318,7 +318,7 @@ var _forChildren = function (element, name, value) { var _forAnonChildren = function (_document, element, name, value) { var results = []; - var nodes = [e for each (e in _document.getAnoymousNodes(element)) if (e)]; + var nodes = Array.from(_document.getAnoymousNodes(element)).filter(e => e); for (var i in nodes ) { var n = nodes[i]; @@ -381,7 +381,7 @@ var _byAnonAttrib = function (_document, parent, attributes) { } } - var nodes = [n for each (n in _document.getAnonymousNodes(parent)) if (n.getAttribute)]; + var nodes = Array.from(_document.getAnonymousNodes(parent)).filter(n => n.getAttribute); function resultsForNodes (nodes) { for (var i in nodes) { @@ -404,7 +404,7 @@ var _byAnonAttrib = function (_document, parent, attributes) { resultsForNodes(nodes); if (results.length == 0) { - resultsForNodes([n for each (n in parent.childNodes) if (n != undefined && n.getAttribute)]) + resultsForNodes(Array.from(parent.childNodes).filter(n => n != undefined && n.getAttribute)); } return _returnResult(results) @@ -440,7 +440,7 @@ function Lookup(_document, expression) { throw new Error('Lookup constructor did not recieve enough arguments.'); } - var expSplit = [e for each (e in smartSplit(expression) ) if (e != '')]; + var expSplit = smartSplit(expression).filter(e => e != ''); expSplit.unshift(_document); var nCases = {'id':_byID, 'name':_byName, 'attrib':_byAttrib, 'index':_byIndex}; diff --git a/services/sync/tps/extensions/mozmill/resource/modules/frame.js b/services/sync/tps/extensions/mozmill/resource/modules/frame.js index 9f0c325bec2..dae8276b620 100644 --- a/services/sync/tps/extensions/mozmill/resource/modules/frame.js +++ b/services/sync/tps/extensions/mozmill/resource/modules/frame.js @@ -256,7 +256,7 @@ events.pass = function (obj) { events.currentTest.__passes__.push(obj); } - for each (var timer in timers) { + for (var timer of timers) { timer.actions.push( {"currentTest": events.currentModule.__file__ + "::" + events.currentTest.__name__, "obj": obj, @@ -286,7 +286,7 @@ events.fail = function (obj) { events.currentTest.__fails__.push(obj); } - for each (var time in timers) { + for (var time of timers) { timer.actions.push( {"currentTest": events.currentModule.__file__ + "::" + events.currentTest.__name__, "obj": obj, @@ -325,7 +325,7 @@ events.fireEvent = function (name, obj) { } } - for each(var listener in this.globalListeners) { + for (var listener of this.globalListeners) { listener(name, obj); } } diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/os.js b/services/sync/tps/extensions/mozmill/resource/stdlib/os.js index 58fa5a41cf8..ce88bea8a8c 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/os.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/os.js @@ -37,7 +37,7 @@ function abspath(rel, file) { file = file.parent; } - for each(var p in relSplit) { + for (var p of relSplit) { if (p == '..') { file = file.parent; } else if (p == '.') { diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js b/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js index 794c3e2c24c..bfa7ef5a9fe 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js @@ -168,8 +168,7 @@ if (rootPaths) { if (rootPaths.constructor.name != "Array") rootPaths = [rootPaths]; - var fses = [new exports.LocalFileSystem(path) - for each (path in rootPaths)]; + var fses = rootPaths.map(path => new exports.LocalFileSystem(path)); options.fs = new exports.CompositeFileSystem(fses); } else options.fs = new exports.LocalFileSystem(); diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js b/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js index 659d6111bbc..73e13e11f16 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js @@ -83,7 +83,7 @@ function getWindows(type) { } function getMethodInWindows(methodName) { - for each (var w in getWindows()) { + for (var w of getWindows()) { if (w[methodName] != undefined) { return w[methodName]; } @@ -93,7 +93,7 @@ function getMethodInWindows(methodName) { } function getWindowByTitle(title) { - for each (var w in getWindows()) { + for (var w of getWindows()) { if (w.document.title && w.document.title == title) { return w; } diff --git a/services/sync/tps/extensions/tps/resource/modules/history.jsm b/services/sync/tps/extensions/tps/resource/modules/history.jsm index aa2c2f36155..20edfc9a6f7 100644 --- a/services/sync/tps/extensions/tps/resource/modules/history.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/history.jsm @@ -33,7 +33,7 @@ var DumpHistory = function TPS_History__DumpHistory() { let node = root.getChild(i); let uri = node.uri; let curvisits = HistoryEntry._getVisits(uri); - for each (var visit in curvisits) { + for (var visit of curvisits) { Logger.logInfo("URI: " + uri + ", type=" + visit.type + ", date=" + visit.date, true); } } @@ -110,7 +110,7 @@ var HistoryEntry = { uri: uri, visits: [] }; - for each (visit in item.visits) { + for (let visit of item.visits) { place.visits.push({ visitDate: usSinceEpoch + (visit.date * 60 * 60 * 1000 * 1000), transitionType: visit.type @@ -150,8 +150,8 @@ var HistoryEntry = { "History entry in test file must have both 'visits' " + "and 'uri' properties"); let curvisits = this._getVisits(item.uri); - for each (visit in curvisits) { - for each (itemvisit in item.visits) { + for (let visit of curvisits) { + for (let itemvisit of item.visits) { let expectedDate = itemvisit.date * 60 * 60 * 1000 * 1000 + usSinceEpoch; if (visit.type == itemvisit.type && visit.date == expectedDate) { @@ -161,7 +161,7 @@ var HistoryEntry = { } let all_items_found = true; - for each (itemvisit in item.visits) { + for (let itemvisit in item.visits) { all_items_found = all_items_found && "found" in itemvisit; Logger.logInfo("History entry for " + item.uri + ", type:" + itemvisit.type + ", date:" + itemvisit.date + diff --git a/services/sync/tps/extensions/tps/resource/modules/tabs.jsm b/services/sync/tps/extensions/tps/resource/modules/tabs.jsm index c454ef9f442..f6caf06c6cd 100644 --- a/services/sync/tps/extensions/tps/resource/modules/tabs.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/tabs.jsm @@ -50,7 +50,11 @@ var BrowserTabs = { // Find the uri in Weave's list of tabs for the given profile. let engine = Weave.Service.engineManager.get("tabs"); for (let [guid, client] in Iterator(engine.getAllClients())) { - for each (tab in client.tabs) { + if (!client.tabs) { + continue; + } + for (let key in client.tabs) { + let tab = client.tabs[key]; let weaveTabUrl = tab.urlHistory[0]; if (uri == weaveTabUrl && profile == client.clientName) if (title == undefined || title == tab.title) diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index 1a2439ab27d..422ba314551 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -285,7 +285,7 @@ var TPS = { HandleTabs: function (tabs, action) { this._tabsAdded = tabs.length; this._tabsFinished = 0; - for each (let tab in tabs) { + for (let tab of tabs) { Logger.logInfo("executing action " + action.toUpperCase() + " on tab " + JSON.stringify(tab)); switch(action) { @@ -330,7 +330,7 @@ var TPS = { }, HandlePrefs: function (prefs, action) { - for each (pref in prefs) { + for (let pref of prefs) { Logger.logInfo("executing action " + action.toUpperCase() + " on pref " + JSON.stringify(pref)); let preference = new Preference(pref); @@ -349,7 +349,7 @@ var TPS = { }, HandleForms: function (data, action) { - for each (datum in data) { + for (let datum of data) { Logger.logInfo("executing action " + action.toUpperCase() + " on form entry " + JSON.stringify(datum)); let formdata = new FormData(datum, this._usSinceEpoch); @@ -377,7 +377,7 @@ var TPS = { HandleHistory: function (entries, action) { try { - for each (entry in entries) { + for (let entry of entries) { Logger.logInfo("executing action " + action.toUpperCase() + " on history entry " + JSON.stringify(entry)); switch(action) { @@ -410,7 +410,7 @@ var TPS = { HandlePasswords: function (passwords, action) { try { - for each (password in passwords) { + for (let password of passwords) { let password_id = -1; Logger.logInfo("executing action " + action.toUpperCase() + " on password " + JSON.stringify(password)); @@ -450,7 +450,7 @@ var TPS = { }, HandleAddons: function (addons, action, state) { - for each (let entry in addons) { + for (let entry of addons) { Logger.logInfo("executing action " + action.toUpperCase() + " on addon " + JSON.stringify(entry)); let addon = new Addon(this, entry); @@ -481,9 +481,9 @@ var TPS = { HandleBookmarks: function (bookmarks, action) { try { let items = []; - for (folder in bookmarks) { + for (let folder in bookmarks) { let last_item_pos = -1; - for each (bookmark in bookmarks[folder]) { + for (let bookmark of bookmarks[folder]) { Logger.clearPotentialError(); let placesItem; bookmark['location'] = folder; @@ -525,7 +525,7 @@ var TPS = { } if (action == ACTION_DELETE || action == ACTION_MODIFY) { - for each (item in items) { + for (let item of items) { Logger.logInfo("executing action " + action.toUpperCase() + " on bookmark " + JSON.stringify(item)); switch(action) { @@ -689,7 +689,7 @@ var TPS = { // care about. if (settings.ignoreUnusedEngines && Array.isArray(this._enabledEngines)) { let names = {}; - for each (let name in this._enabledEngines) { + for (let name of this._enabledEngines) { names[name] = true; }