Bug 1217082 - Remove for-each from toolkit/. r=Gijs

This commit is contained in:
Tooru Fujisawa 2015-10-19 04:57:14 +09:00
parent 38a6aeb647
commit c127559b93
80 changed files with 202 additions and 171 deletions

View File

@ -678,7 +678,8 @@ ContentPrefService2.prototype = {
destroy: function CPS2_destroy() {
if (this._statements) {
for each (let stmt in this._statements) {
for (let sql in this._statements) {
let stmt = this._statements[sql];
stmt.finalize();
}
}

View File

@ -525,7 +525,7 @@ ContentPrefService.prototype = {
* Notify all observers about the removal of a preference.
*/
_notifyPrefRemoved: function ContentPrefService__notifyPrefRemoved(aGroup, aName) {
for each (var observer in this._getObservers(aName)) {
for (var observer of this._getObservers(aName)) {
try {
observer.onContentPrefRemoved(aGroup, aName);
}
@ -539,7 +539,7 @@ ContentPrefService.prototype = {
* Notify all observers about a preference change.
*/
_notifyPrefSet: function ContentPrefService__notifyPrefSet(aGroup, aName, aValue) {
for each (var observer in this._getObservers(aName)) {
for (var observer of this._getObservers(aName)) {
try {
observer.onContentPrefSet(aGroup, aName, aValue);
}

View File

@ -667,12 +667,12 @@ function run_single_abi_tests(decl, abi, t, toprimitive,
let setter_t = ctypes.FunctionType(abi, t, [t]).ptr;
let setter = decl(setter_t, "set_");
for each (let i in set_tests)
for (let i of set_tests)
do_check_eq(toprimitive(setter(i)), i);
let sum_t = ctypes.FunctionType(abi, t, [t, t]).ptr;
let sum = decl(sum_t, "sum_");
for each (let a in sum_tests)
for (let a of sum_tests)
do_check_eq(toprimitive(sum(a[0], a[1])), a[2]);
let sum_alignb_t = ctypes.FunctionType(abi, t,
@ -681,7 +681,7 @@ function run_single_abi_tests(decl, abi, t, toprimitive,
let sum_alignf_t = ctypes.FunctionType(abi, t,
[ctypes.float, t, ctypes.float, t, ctypes.float]).ptr;
let sum_alignf = decl(sum_alignf_t, "sum_alignf_");
for each (let a in sum_tests) {
for (let a of sum_tests) {
do_check_eq(toprimitive(sum_alignb(0, a[0], 0, a[1], 0)), a[2]);
do_check_eq(toprimitive(sum_alignb(1, a[0], 1, a[1], 1)), a[2]);
do_check_eq(toprimitive(sum_alignf(0, a[0], 0, a[1], 0)), a[2]);
@ -691,7 +691,7 @@ function run_single_abi_tests(decl, abi, t, toprimitive,
let sum_many_t = ctypes.FunctionType(abi, t,
[t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t, t]).ptr;
let sum_many = decl(sum_many_t, "sum_many_");
for each (let a in sum_many_tests)
for (let a of sum_many_tests)
do_check_eq(
toprimitive(sum_many(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7],
a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15],
@ -1281,7 +1281,7 @@ function run_char16_tests(library, t, name, limits) {
}
// Test the class and prototype hierarchy for a given type constructor 'c'.
function run_type_ctor_class_tests(c, t, t2, props, fns, instanceProps, instanceFns, specialProps)
function run_type_ctor_class_tests(c, t, t2, props=[], fns=[], instanceProps=[], instanceFns=[], specialProps=[])
{
// Test that classes and prototypes are set up correctly on the type ctor 'c'.
do_check_class(c, "Function");
@ -1292,15 +1292,15 @@ function run_type_ctor_class_tests(c, t, t2, props, fns, instanceProps, instance
do_check_true(c.prototype.constructor === c);
// Check that 'c.prototype' has the correct properties and functions.
for each (let p in props)
for (let p of props)
do_check_true(c.prototype.hasOwnProperty(p));
for each (let f in fns)
for (let f of fns)
do_check_true(c.prototype.hasOwnProperty(f));
// Check that the shared properties and functions on 'c.prototype' throw.
for each (let p in props)
for (let p of props)
do_check_throws(function() { c.prototype[p]; }, TypeError);
for each (let f in fns)
for (let f of fns)
do_check_throws(function() { c.prototype[f](); }, Error);
// Test that classes and prototypes are set up correctly on a constructed
@ -1326,28 +1326,28 @@ function run_type_ctor_class_tests(c, t, t2, props, fns, instanceProps, instance
// Check that 't.prototype.__proto__' has the correct properties and
// functions.
for each (let p in instanceProps)
for (let p of instanceProps)
do_check_true(t.prototype.__proto__.hasOwnProperty(p));
for each (let f in instanceFns)
for (let f of instanceFns)
do_check_true(t.prototype.__proto__.hasOwnProperty(f));
// Check that the shared properties and functions on 't.prototype.__proto__'
// (and thus also 't.prototype') throw.
for each (let p in instanceProps) {
for (let p of instanceProps) {
do_check_throws(function() { t.prototype.__proto__[p]; }, TypeError);
do_check_throws(function() { t.prototype[p]; }, TypeError);
}
for each (let f in instanceFns) {
for (let f of instanceFns) {
do_check_throws(function() { t.prototype.__proto__[f]() }, Error);
do_check_throws(function() { t.prototype[f]() }, Error);
}
// Check that 't.prototype' has the correct special properties.
for each (let p in specialProps)
for (let p of specialProps)
do_check_true(t.prototype.hasOwnProperty(p));
// Check that the shared special properties on 't.prototype' throw.
for each (let p in specialProps)
for (let p of specialProps)
do_check_throws(function() { t.prototype[p]; }, Error);
// Make sure we can access 'prototype' on a CTypeProto.

View File

@ -95,7 +95,7 @@ function test()
var win = Services.wm.getMostRecentWindow("Download:Manager");
// Now we can run our tests
for each (var t in testFuncs)
for (var t of testFuncs)
t(win);
finish();

View File

@ -53,7 +53,7 @@ var DownloadListener = {
} else if (aTopic == "dl-done") {
// check that no two files have the same filename in the download manager
let file = aSubject.QueryInterface(Ci.nsIDownload).targetFile;
for each (let prevFile in this.prevFiles) {
for (let prevFile of this.prevFiles) {
do_check_neq(file.leafName, prevFile.leafName);
}
this.prevFiles.push(file);
@ -93,7 +93,7 @@ var DownloadListener = {
function runNextTest()
{
if (currentTest == tests.length) {
for each (var file in DownloadListener.prevFiles) {
for (var file of DownloadListener.prevFiles) {
try {
file.remove(false);
} catch (ex) {

View File

@ -569,7 +569,7 @@ Extensions.prototype = {
// minVersion: "1.0"
// maxVersion: "2.0"
find: function exts_find(aOptions) {
return [e for each (e in this._cache)];
return Object.keys(this._cache).map(id => this._cache[id]);
},
has: function exts_has(aId) {

View File

@ -120,7 +120,7 @@ LoginManagerPromptFactory.prototype = {
prompt.inProgress = false;
self._asyncPromptInProgress = false;
for each (var consumer in prompt.consumers) {
for (var consumer of prompt.consumers) {
if (!consumer.callback)
// Not having a callback means that consumer didn't provide it
// or canceled the notification
@ -148,7 +148,8 @@ LoginManagerPromptFactory.prototype = {
var asyncPrompts = this._asyncPrompts;
this.__proto__._asyncPrompts = {};
for each (var prompt in asyncPrompts) {
for (var hashKey in asyncPrompts) {
let prompt = asyncPrompts[hashKey];
// Watch out! If this prompt is currently prompting, let it handle
// notifying the callbacks of success/failure, since it's already
// asking the user for input. Reusing a callback can be crashy.
@ -157,7 +158,7 @@ LoginManagerPromptFactory.prototype = {
continue;
}
for each (var consumer in prompt.consumers) {
for (var consumer of prompt.consumers) {
if (!consumer.callback)
continue;

View File

@ -440,7 +440,7 @@ this.LoginManagerStorage_json.prototype = {
httpRealm: httpRealm
};
let matchData = { };
for each (let field in ["hostname", "formSubmitURL", "httpRealm"])
for (let field of ["hostname", "formSubmitURL", "httpRealm"])
if (loginData[field] != '')
matchData[field] = loginData[field];
let [logins, ids] = this._searchLogins(matchData);
@ -461,7 +461,7 @@ this.LoginManagerStorage_json.prototype = {
httpRealm: httpRealm
};
let matchData = { };
for each (let field in ["hostname", "formSubmitURL", "httpRealm"])
for (let field of ["hostname", "formSubmitURL", "httpRealm"])
if (loginData[field] != '')
matchData[field] = loginData[field];
let [logins, ids] = this._searchLogins(matchData);
@ -504,7 +504,7 @@ this.LoginManagerStorage_json.prototype = {
*/
_getIdForLogin(login) {
let matchData = { };
for each (let field in ["hostname", "formSubmitURL", "httpRealm"])
for (let field of ["hostname", "formSubmitURL", "httpRealm"])
if (login[field] != '')
matchData[field] = login[field];
let [logins, ids] = this._searchLogins(matchData);
@ -566,7 +566,7 @@ this.LoginManagerStorage_json.prototype = {
_decryptLogins(logins) {
let result = [];
for each (let login in logins) {
for (let login of logins) {
try {
login.username = this._crypto.decrypt(login.username);
login.password = this._crypto.decrypt(login.password);

View File

@ -686,7 +686,7 @@ LoginManagerStorage_mozStorage.prototype = {
httpRealm: httpRealm
};
let matchData = { };
for each (let field in ["hostname", "formSubmitURL", "httpRealm"])
for (let field of ["hostname", "formSubmitURL", "httpRealm"])
if (loginData[field] != '')
matchData[field] = loginData[field];
let [logins, ids] = this._searchLogins(matchData);
@ -799,7 +799,7 @@ LoginManagerStorage_mozStorage.prototype = {
*/
_getIdForLogin : function (login) {
let matchData = { };
for each (let field in ["hostname", "formSubmitURL", "httpRealm"])
for (let field of ["hostname", "formSubmitURL", "httpRealm"])
if (login[field] != '')
matchData[field] = login[field];
let [logins, ids] = this._searchLogins(matchData);
@ -953,7 +953,7 @@ LoginManagerStorage_mozStorage.prototype = {
_decryptLogins : function (logins) {
let result = [];
for each (let login in logins) {
for (let login of logins) {
try {
login.username = this._crypto.decrypt(login.username);
login.password = this._crypto.decrypt(login.password);
@ -1147,7 +1147,7 @@ LoginManagerStorage_mozStorage.prototype = {
// Generate a GUID for each login and update the DB.
query = "UPDATE moz_logins SET guid = :guid WHERE id = :id";
for each (let id in ids) {
for (let id of ids) {
let params = {
id: id,
guid: this._uuidService.generateUUID().toString()
@ -1213,7 +1213,7 @@ LoginManagerStorage_mozStorage.prototype = {
// Determine encryption type for each login and update the DB.
query = "UPDATE moz_logins SET encType = :encType WHERE id = :id";
for each (let params in logins) {
for (let params of logins) {
try {
stmt = this._dbCreateStatement(query, params);
stmt.execute();
@ -1238,7 +1238,7 @@ LoginManagerStorage_mozStorage.prototype = {
_dbMigrateToVersion4 : function () {
let query;
// Add the new columns, if needed.
for each (let column in ["timeCreated", "timeLastUsed", "timePasswordChanged", "timesUsed"]) {
for (let column of ["timeCreated", "timeLastUsed", "timePasswordChanged", "timesUsed"]) {
if (!this._dbColumnExists(column)) {
query = "ALTER TABLE moz_logins ADD COLUMN " + column + " INTEGER";
this._dbConnection.executeSimpleSQL(query);
@ -1270,7 +1270,7 @@ LoginManagerStorage_mozStorage.prototype = {
id: null,
initTime: Date.now()
};
for each (let id in ids) {
for (let id of ids) {
params.id = id;
try {
stmt = this._dbCreateStatement(query, params);
@ -1366,7 +1366,8 @@ LoginManagerStorage_mozStorage.prototype = {
_dbClose : function () {
this.log("Closing the DB connection.");
// Finalize all statements to free memory, avoid errors later
for each (let stmt in this._dbStmts) {
for (let query in this._dbStmts) {
let stmt = this._dbStmts[query];
stmt.finalize();
}
this._dbStmts = {};

View File

@ -882,7 +882,8 @@ nsPlacesExpiration.prototype = {
*/
_finalizeInternalStatements: function PEX__finalizeInternalStatements()
{
for each (let stmt in this._cachedStatements) {
for (let queryType in this._cachedStatements) {
let stmt = this._cachedStatements[queryType];
stmt.finalize();
}
},

View File

@ -292,7 +292,7 @@ function removePages(aURIs)
function do_removePages(aURIs)
{
for each (let uri in aURIs)
for (let uri of aURIs)
histsvc.removePage(toURI(kURIs[uri]));
}

View File

@ -96,7 +96,7 @@ function run_test()
add_task(function test_transitions()
{
let timeNow = Date.now();
for each (let item in testData) {
for (let item of testData) {
yield PlacesTestUtils.addVisits({
uri: uri(item.uri),
transition: item.transType,

View File

@ -288,7 +288,7 @@ add_task(function test_execute()
// Setting item annotations on invalid item ids should throw
var invalidIds = [-1, 0, 37643];
for each (var id in invalidIds) {
for (var id of invalidIds) {
try {
annosvc.setItemAnnotation(id, "foo", "bar", 0, 0);
do_throw("setItemAnnotation* should throw for invalid item id: " + id)

View File

@ -39,7 +39,7 @@ add_task(function test_execute()
PlacesUtils.history.addObserver(observer, false);
for each (var visit in gVisits) {
for (var visit of gVisits) {
if (visit.transition == TRANSITION_TYPED)
PlacesUtils.history.markPageAsTyped(uri(visit.url));
else if (visit.transition == TRANSITION_BOOKMARK)

View File

@ -401,7 +401,7 @@ FormAutoComplete.prototype = {
_calculateScore : function (entry, aSearchString, searchTokens) {
let boundaryCalc = 0;
// for each word, calculate word boundary weights
for each (let token in searchTokens) {
for (let token of searchTokens) {
boundaryCalc += (entry.textLowerCase.indexOf(token) == 0);
boundaryCalc += (entry.textLowerCase.indexOf(" " + token) >= 0);
}

View File

@ -766,7 +766,7 @@ FormHistory.prototype = {
// Generate a GUID for each login and update the DB.
query = "UPDATE moz_formhistory SET guid = :guid WHERE id = :id";
for each (let id in ids) {
for (let id of ids) {
let params = {
id : id,
guid : this.generateGUID()
@ -844,7 +844,8 @@ FormHistory.prototype = {
* closed.
*/
_dbClose : function FH__dbClose(aBlocking) {
for each (let stmt in this.dbStmts) {
for (let query in this.dbStmts) {
let stmt = this.dbStmts[query];
stmt.finalize();
}
this.dbStmts = {};

View File

@ -3078,7 +3078,8 @@ SearchService.prototype = {
return null;
};
for each (let engine in this._engines) {
for (let name in this._engines) {
let engine = this._engines[name];
let parent = getParent(engine);
if (!parent) {
LOG("Error: no parent for engine " + engine._location + ", failing to cache it");
@ -3191,8 +3192,10 @@ SearchService.prototype = {
}
LOG("_loadEngines: loading from cache directories");
for each (let dir in cache.directories)
for (let cacheKey in cache.directories) {
let dir = cache.directories[cacheKey];
this._loadEnginesFromCache(dir);
}
LOG("_loadEngines: done");
},
@ -3327,8 +3330,10 @@ SearchService.prototype = {
}
LOG("_asyncLoadEngines: loading from cache directories");
for each (let dir in cache.directories)
for (let cacheKey in cache.directories) {
let dir = cache.directories[cacheKey];
this._loadEnginesFromCache(dir);
}
LOG("_asyncLoadEngines: done");
}.bind(this));
@ -3818,7 +3823,8 @@ SearchService.prototype = {
// Flag to keep track of whether or not we need to call _saveSortedEngineList.
let needToSaveEngineList = false;
for each (engine in this._engines) {
for (let name in this._engines) {
let engine = this._engines[name];
var orderNumber = engineMetadataService.getAttr(engine, "order");
// Since the DB isn't regularly cleared, and engine files may disappear
@ -3852,7 +3858,7 @@ SearchService.prototype = {
var extras =
Services.prefs.getChildList(BROWSER_SEARCH_PREF + "order.extra.");
for each (prefName in extras) {
for (prefName of extras) {
engineName = Services.prefs.getCharPref(prefName);
engine = this._engines[engineName];
@ -3884,7 +3890,8 @@ SearchService.prototype = {
// Array for the remaining engines, alphabetically sorted.
let alphaEngines = [];
for each (engine in this._engines) {
for (let name in this._engines) {
let engine = this._engines[name];
if (!(engine.name in addedEngines))
alphaEngines.push(this._engines[engine.name]);
}
@ -3993,7 +4000,7 @@ SearchService.prototype = {
try {
var extras = Services.prefs.getChildList(BROWSER_SEARCH_PREF + "order.extra.");
for each (var prefName in extras) {
for (var prefName of extras) {
engineName = Services.prefs.getCharPref(prefName);
if (!(engineName in engineOrder))
@ -4209,7 +4216,8 @@ SearchService.prototype = {
restoreDefaultEngines: function SRCH_SVC_resetDefaultEngines() {
this._ensureInitialized();
for each (var e in this._engines) {
for (let name in this._engines) {
let e = this._engines[name];
// Unhide all default engines
if (e.hidden && e._isDefault)
e.hidden = false;
@ -4601,8 +4609,8 @@ SearchService.prototype = {
// Therefore, we need to walk our engine-list, looking for expired engines
var currentTime = Date.now();
LOG("currentTime: " + currentTime);
for each (let engine in this._engines) {
engine = engine.wrappedJSObject;
for (let name in this._engines) {
let engine = this._engines[name].wrappedJSObject;
if (!engine._hasUpdates)
continue;

View File

@ -217,7 +217,7 @@ var tests = {
let expected_data = false;
worker.port.onmessage = function(e) {
is(e.data.topic, "ready");
for each (let attr in ['appName', 'appVersion', 'platform', 'userAgent']) {
for (let attr of ['appName', 'appVersion', 'platform', 'userAgent']) {
// each attribute must be a string with length > 0.
is(typeof e.data.data[attr], "string");
ok(e.data.data[attr].length > 0);

View File

@ -809,7 +809,7 @@ var Impl = {
}
if (si.process) {
for each (let field in Object.keys(si)) {
for (let field of Object.keys(si)) {
if (field == "process")
continue;
ret[field] = si[field] - si.process

View File

@ -60,7 +60,7 @@ function test_histogram(histogram_type, name, min, max, bucket_count) {
}
// there should be exactly one element per bucket
for each(var i in s.counts) {
for (var i of s.counts) {
do_check_eq(i, 1);
}
var hgrams = Telemetry.histogramSnapshots
@ -80,7 +80,7 @@ function test_histogram(histogram_type, name, min, max, bucket_count) {
// Check that clearing works.
h.clear();
var s = h.snapshot();
for each(var i in s.counts) {
for (var i of s.counts) {
do_check_eq(i, 0);
}
do_check_eq(s.sum, 0);
@ -235,7 +235,7 @@ function test_histogramFrom() {
"TELEMETRY_TEST_COUNT", // COUNT
];
for each (let name in names) {
for (let name of names) {
let [min, max, bucket_count] = [1, INT_MAX - 1, 10]
let original = Telemetry.getHistogramById(name);
let clone = Telemetry.histogramFrom("clone" + name, name);
@ -877,7 +877,7 @@ function run_test()
test_instantiate();
let kinds = [Telemetry.HISTOGRAM_EXPONENTIAL, Telemetry.HISTOGRAM_LINEAR]
for each (let histogram_type in kinds) {
for (let histogram_type of kinds) {
let [min, max, bucket_count] = [1, INT_MAX - 1, 10]
test_histogram(histogram_type, "test::"+histogram_type, min, max, bucket_count);

View File

@ -183,7 +183,7 @@ G_Preferences.prototype.removeObserver = function(which, callback) {
*/
G_Preferences.prototype.removeAllObservers = function() {
for (var which in this.observers_) {
for each (var observer in this.observers_[which].observers) {
for (var observer of this.observers_[which].observers) {
this.prefs_.removeObserver(which, observer);
}
}

View File

@ -200,11 +200,11 @@ function run_test() {
}
// Fix up the completions before running the test.
for each (let completionSet in completionSets) {
for each (let completion in completionSet) {
for (let completionSet of completionSets) {
for (let completion of completionSet) {
// Pad the right of each |hash| so that the length is COMPLETE_LENGTH.
if (completion.multipleCompletions) {
for each (let responseCompletion in completion.completions) {
for (let responseCompletion of completion.completions) {
let numChars = COMPLETE_LENGTH - responseCompletion.hash.length;
responseCompletion.hash += (new Array(numChars + 1)).join("\u0000");
}
@ -241,7 +241,7 @@ function runNextCompletion() {
completionSets[currentCompletionSet].length + "\n");
// Number of finished completions for this set.
finishedCompletions = 0;
for each (let completion in completionSets[currentCompletionSet]) {
for (let completion of completionSets[currentCompletionSet]) {
completer.complete(completion.hash.substring(0,4), gethashUrl,
(new callback(completion)));
}
@ -267,7 +267,7 @@ function hashCompleterServer(aRequest, aResponse) {
// As per the spec, a server should response with a 204 if there are no
// full-length hashes that match the prefixes.
let httpStatus = 204;
for each (let completion in completionSets[currentCompletionSet]) {
for (let completion of completionSets[currentCompletionSet]) {
if (completion.expectCompletion &&
(completedHashes.indexOf(completion.hash) == -1)) {
completedHashes.push(completion.hash);
@ -300,7 +300,7 @@ callback.prototype = {
completion: function completion(hash, table, chunkId, trusted) {
do_check_true(this._completion.expectCompletion);
if (this._completion.multipleCompletions) {
for each (let completion in this._completion.completions) {
for (let completion of this._completion.completions) {
if (completion.hash == hash) {
do_check_eq(JSON.stringify(hash), JSON.stringify(completion.hash));
do_check_eq(table, completion.table);

View File

@ -22,7 +22,7 @@
var gBrowser;
var imports = ["SimpleTest", "ok"];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -22,7 +22,7 @@
var gBrowser;
var imports = ["SimpleTest", "ok"];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -20,7 +20,7 @@
var gBrowser;
var imports = ["SimpleTest", "ok", "is"];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -31,7 +31,7 @@
var imports = ["SimpleTest", "ok", "snapshotWindow", "compareSnapshots",
"parentFinish"];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -29,7 +29,7 @@
}
var imports = [ "SimpleTest", "ok"];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -22,7 +22,7 @@
var gBrowser;
var imports = ["SimpleTest", "ok", "is"];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -20,7 +20,7 @@ function bind(f, thisObj) {
}
function bindSome(instance, methodNames) {
for each (let methodName in methodNames)
for (let methodName of methodNames)
if (methodName in instance)
instance[methodName] = bind(instance[methodName], instance);
}
@ -124,7 +124,7 @@ TileManager.prototype = {
let criticalIsDirty = false;
let criticalRect = this._criticalRect;
for each (let rect in rects) {
for (let rect of rects) {
this._tileCache.forEachIntersectingRect(rect, false, this._dirtyTile, this);
if (criticalRect && rect.intersects(criticalRect))
@ -909,7 +909,7 @@ TileManager.CrawlIterator = function CrawlIterator(tileCache, startRect) {
outOfBounds = true;
// top, bottom borders
for each (let y in [rect.top, rect.bottom]) {
for (let y of [rect.top, rect.bottom]) {
for (let x = rect.left; x <= rect.right - dx; x += kTileWidth) {
let i = x >> kTileExponentWidth;
let j = y >> kTileExponentHeight;
@ -921,7 +921,7 @@ TileManager.CrawlIterator = function CrawlIterator(tileCache, startRect) {
}
// left, right borders
for each (let x in [rect.left, rect.right]) {
for (let x of [rect.left, rect.right]) {
for (let y = rect.top; y <= rect.bottom - dy; y += kTileHeight) {
let i = x >> kTileExponentWidth;
let j = y >> kTileExponentHeight;

View File

@ -551,7 +551,8 @@ WidgetStack.prototype = {
this.globalOffsetX += x;
this.globalOffsetY += y;
for each (let state in this._widgetState) {
for (let wid in this._widgetState) {
let state = this._widgetState[wid];
state.rect.x += x;
state.rect.y += y;
@ -600,7 +601,8 @@ WidgetStack.prototype = {
//log2("setViewportBounds dltrb", dleft, dtop, dright, dbottom);
// move all vp-relative widgets to be the right offset from the bounds again
for each (let state in this._widgetState) {
for (let wid in this._widgetState) {
let state = this._widgetState[wid];
if (state.vpRelative) {
//log2("vpRelative widget", state.id, state.rect.x, dleft, dright);
if (state.vpOffsetXBefore) {
@ -769,8 +771,10 @@ WidgetStack.prototype = {
// XXX these methods aren't working correctly yet, but they aren't strictly
// necessary in Fennec's default config
//for each (let s in this._widgetState)
//for (let wid in this._widgetState) {
// let s = this._widgetState[wid];
// this._updateWidgetRect(s);
//}
//this._updateViewportOverflow();
this._viewingRect.width = width;
@ -1112,7 +1116,8 @@ WidgetStack.prototype = {
// will be ignored in commitState.
// The widget rects are in real stack space though, so we need to subtract
// our (now negated) dx, dy from their coordinates.
for each (let state in this._widgetState) {
for (let wid in this._widgetState) {
let state = this._widgetState[wid];
if (!state.ignoreX)
state.rect.x -= dx;
if (!state.ignoreY)
@ -1175,7 +1180,7 @@ WidgetStack.prototype = {
if (w.hasAttribute("constraint")) {
let cs = w.getAttribute("constraint").split(",");
for each (let s in cs) {
for (let s of cs) {
if (s == "ignore-x")
state.ignoreX = true;
else if (s == "ignore-y")
@ -1239,7 +1244,8 @@ WidgetStack.prototype = {
let ofRect = this._viewingRect.clone();
for each (let state in this._widgetState) {
for (let wid in this._widgetState) {
let state = this._widgetState[wid];
if (vp && state.vpRelative) {
// compute the vpOffset from 0,0 assuming that the viewport rect is 0,0
if (state.rect.left >= vp.rect.right) {
@ -1273,7 +1279,8 @@ WidgetStack.prototype = {
let ofRect = new wsRect(0, 0, this._viewingRect.width, this._viewingRect.height);
for each (let state in this._widgetState) {
for (let wid in this._widgetState) {
let state = this._widgetState[wid];
if (vp && state.vpRelative) {
ofRect.left = Math.min(ofRect.left, state.rect.left);
ofRect.top = Math.min(ofRect.top, state.rect.top);
@ -1300,8 +1307,10 @@ WidgetStack.prototype = {
_widgetBounds: function () {
let r = new wsRect(0,0,0,0);
for each (let state in this._widgetState)
for (let wid in this._widgetState) {
let state = this._widgetState[wid];
r = r.union(state.rect);
}
return r;
},
@ -1390,7 +1399,7 @@ WidgetStack.prototype = {
if (el.hasAttribute("constraint")) {
let cs = el.getAttribute("constraint").split(",");
for each (let s in cs) {
for (let s of cs) {
if (s == "ignore-x")
barrier.ignoreX = true;
else if (s == "ignore-y")

View File

@ -118,7 +118,7 @@ function onKeyPress(e) {
break;
case t:
let ijstrs = window.prompt('row,col plz').split(' ');
for each (let ijstr in ijstrs) {
for (let ijstr of ijstrs) {
let [i, j] = ijstr.split(',').map(x => parseInt(x));
debugTile(i, j);
}

View File

@ -1437,7 +1437,7 @@ extends="chrome://global/content/bindings/popup.xml#popup">
// Find which regions of text match the search terms
let regions = [];
for each (let search in aSearchTokens) {
for (let search of Array.prototype.slice.call(aSearchTokens)) {
let matchIndex;
let startIndex = 0;
let searchLen = search.length;

View File

@ -1177,7 +1177,7 @@
var ourFieldValues = {};
var otherFieldValues = {};
for each (var field in fieldsToSwap) {
for (var field of fieldsToSwap) {
ourFieldValues[field] = this[field];
otherFieldValues[field] = aOtherBrowser[field];
}
@ -1195,7 +1195,7 @@
aOtherBrowser.detachFormFill();
}
for each (var field in fieldsToSwap) {
for (var field of fieldsToSwap) {
this[field] = otherFieldValues[field];
aOtherBrowser[field] = ourFieldValues[field];
}

View File

@ -695,10 +695,10 @@
clearInterval(this.statsInterval);
this.statsInterval = null;
}
for each (let event in this.videoEvents)
for (let event of this.videoEvents)
this.video.removeEventListener(event, this, false);
for each(let element in this.controlListeners)
for (let element of this.controlListeners)
element.item.removeEventListener(element.event, element.func, false);
delete this.controlListeners;
@ -1492,7 +1492,7 @@
// Use the handleEvent() callback for all media events.
// The "error" event listener must capture, so that it can trap error events
// from the <source> children, which don't bubble.
for each (let event in this.videoEvents)
for (let event of this.videoEvents)
this.video.addEventListener(event, this, (event == "error") ? true : false);
var self = this;
@ -1690,7 +1690,7 @@
},
terminateEventListeners : function () {
for each (var event in this.videoEvents)
for (var event of this.videoEvents)
this.Utils.video.removeEventListener(event, this, false);
},
@ -1831,10 +1831,10 @@
"playing"],
controlListeners: [],
terminateEventListeners : function () {
for each (let event in this.videoEvents)
for (let event of this.videoEvents)
this.video.removeEventListener(event, this, false);
for each(let element in this.controlListeners)
for (let element of this.controlListeners)
element.item.removeEventListener(element.event, element.func, false);
delete this.controlListeners;
@ -1904,7 +1904,7 @@
addListener(this.clickToPlay, "click", this.clickToPlayClickHandler);
addListener(this.video, "MozNoControlsBlockedVideo", this.blockedVideoHandler);
for each (let event in this.videoEvents) {
for (let event of this.videoEvents) {
this.video.addEventListener(event, this, false);
}

View File

@ -105,7 +105,7 @@ function check_submit_pending(tab, crashes) {
}
// try submitting the pending report
for each(let crash in crashes) {
for (let crash of crashes) {
if (crash.pending) {
SubmittedCrash = crash;
break;

View File

@ -128,7 +128,7 @@ function handleRequest(request, response)
{
if (request.method == "GET") {
let id = null;
for each(p in request.queryString.split('&')) {
for (let p of request.queryString.split('&')) {
let [key, value] = p.split('=');
if (key == 'id')
id = value;

View File

@ -12,7 +12,7 @@ const modules = [
];
function run_test() {
for each (let m in modules) {
for (let m of modules) {
let resource = "resource://gre/modules/identity/" + m;
Components.utils.import(resource, {});
do_print("loaded " + resource);

View File

@ -43,7 +43,7 @@ this.readCertPrefs =
break;
let certAttrs = {};
for each (let prefCertAttr in prefCertAttrs)
for (let prefCertAttr of prefCertAttrs)
certAttrs[prefCertAttr] = prefBranchCert.getCharPref(prefCertAttr);
certs.push(certAttrs);

View File

@ -71,7 +71,7 @@ Point.prototype = {
};
}
for each (let f in ['add', 'subtract', 'equals', 'set'])
for (let f of ['add', 'subtract', 'equals', 'set'])
Point.prototype[f] = takePointOrArgs(Point.prototype[f]);
})();

View File

@ -260,7 +260,7 @@ BinaryPropertyListReader.prototype = {
* It can be called on the prototype.
*/
canProcess: function BPLR_canProcess(aBuffer) {
return [String.fromCharCode(c) for each (c in new Uint8Array(aBuffer, 0, 8))].
return Array.from(new Uint8Array(aBuffer, 0, 8)).map(c => String.fromCharCode(c)).
join("") == "bplist00";
},
@ -377,7 +377,7 @@ BinaryPropertyListReader.prototype = {
function BPLR__readString(aByteOffset, aNumberOfChars, aUnicode) {
let codes = this._readUnsignedInts(aByteOffset, aUnicode ? 2 : 1,
aNumberOfChars);
return [String.fromCharCode(c) for each (c in codes)].join("");
return codes.map(c => String.fromCharCode(c)).join("");
},
/**

View File

@ -32,7 +32,7 @@ var WindowsRegistry = {
case kRegMultiSz:
// nsIWindowsRegKey doesn't support REG_MULTI_SZ type out of the box.
let str = registry.readStringValue(aKey);
return [v for each (v in str.split("\0")) if (v)];
return str.split("\0").filter(v => v);
case Ci.nsIWindowsRegKey.TYPE_STRING:
return registry.readStringValue(aKey);
case Ci.nsIWindowsRegKey.TYPE_INT:

View File

@ -67,7 +67,7 @@ function checkMainPropertyList(aPropertyListRoot) {
// Data
checkLazyGetterValue(array, 6, PropertyListUtils.TYPE_UINT8_ARRAY);
let dataAsString = [String.fromCharCode(b) for each (b in array[6])].join("");
let dataAsString = Array.from(array[6]).map(b => String.fromCharCode(b)).join("");
do_check_eq(dataAsString, "2011-12-31T11:15:33Z");
// Dict

View File

@ -94,7 +94,7 @@ function test()
"state, currBytes, maxBytes, preferredAction, autoResume) " +
"VALUES (:name, :source, :target, :startTime, :endTime, :state, " +
":currBytes, :maxBytes, :preferredAction, :autoResume)");
for each (var dl in DownloadData) {
for (var dl of DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];

View File

@ -160,7 +160,7 @@ function test()
"state, currBytes, maxBytes, preferredAction, autoResume) " +
"VALUES (:name, :source, :target, :startTime, :endTime, :state, " +
":currBytes, :maxBytes, :preferredAction, :autoResume)");
for each (var dl in DownloadData) {
for (var dl of DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
@ -189,7 +189,7 @@ function test()
win.focus();
// Now we can run our tests
for each (let t in testFuncs)
for (let t of testFuncs)
t(win);
win.close();

View File

@ -113,7 +113,7 @@ function test() {
var stmt = db.createStatement(
"INSERT INTO moz_downloads ( name, source, target, state)" +
"VALUES (:name, :source, :target, :state)");
for each (var dl in DownloadData) {
for (var dl of DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
stmt.execute();

View File

@ -49,7 +49,7 @@ function test()
"VALUES (?1, ?2, ?3, ?4)");
try {
for each (let site in ["delete.me", "i.live"]) {
for (let site of ["delete.me", "i.live"]) {
stmt.bindByIndex(0, "Super Pimped Download");
stmt.bindByIndex(1, filePath);
stmt.bindByIndex(2, "http://" + site + "/file");

View File

@ -100,7 +100,7 @@ function test()
"state, currBytes, maxBytes, preferredAction, autoResume) " +
"VALUES (:name, :source, :target, :startTime, :endTime, :state, " +
":currBytes, :maxBytes, :preferredAction, :autoResume)");
for each (var dl in DownloadData) {
for (var dl of DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];

View File

@ -42,7 +42,7 @@ function test()
"VALUES (?1, ?2, ?3, ?4)");
try {
for each (let site in ["ed.agadak.net", "mozilla.org", "mozilla.com", "mozilla.net"]) {
for (let site of ["ed.agadak.net", "mozilla.org", "mozilla.com", "mozilla.net"]) {
let file = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
file.append(site);
@ -160,7 +160,7 @@ function test()
};
// Run two tests: single selected, double selected
for each (let whichTest in ["single", "double"]) {
for (let whichTest of ["single", "double"]) {
let expected = allExpected[whichTest];
// Select the first download
@ -170,7 +170,7 @@ function test()
if (whichTest == "double")
synthesizeKey("VK_DOWN", { shiftKey: true }, win);
for each (let [command, func, test, value] in commandTests) {
for (let [command, func, test, value] of commandTests) {
// Make a copy of the original function and replace it with a test
let copy;
[copy, win[func]] = [win[func], test];

View File

@ -47,7 +47,7 @@ function test()
"VALUES (?1, ?2, ?3, ?4, ?5, ?6)");
try {
for each (let site in ["ed.agadak.net", "mozilla.org"]) {
for (let site of ["ed.agadak.net", "mozilla.org"]) {
stmt.bindByIndex(0, "Super Pimped Download");
stmt.bindByIndex(1, filePath);
stmt.bindByIndex(2, "http://" + site + "/file");

View File

@ -64,7 +64,7 @@ function test()
"state, currBytes, maxBytes, preferredAction, autoResume, entityID) " +
"VALUES (:name, :source, :target, :startTime, :endTime, :state, " +
":currBytes, :maxBytes, :preferredAction, :autoResume, :entityID)");
for each (var dl in DownloadData) {
for (var dl of DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];

View File

@ -55,7 +55,7 @@ function test()
"state, currBytes, maxBytes, preferredAction, autoResume) " +
"VALUES (:name, :source, :target, :startTime, :endTime, :state, " +
":currBytes, :maxBytes, :preferredAction, :autoResume)");
for each (var dl in DownloadData) {
for (var dl of DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];

View File

@ -55,7 +55,7 @@ function test()
sites.push(searchTerm);
try {
for each (let site in sites) {
for (let site of sites) {
stmt.bindByIndex(0, filePath);
stmt.bindByIndex(1, "http://" + site + "/file");
stmt.bindByIndex(2, dm.DOWNLOAD_FINISHED);

View File

@ -75,7 +75,7 @@ function test()
function continueTest(win) {
// Now we can run our tests
for each (let t in testFuncs)
for (let t of testFuncs)
t(win);
win.close();

View File

@ -49,7 +49,7 @@ function test()
let sites = ["mozilla.org", "mozilla.com", "select.all"];
try {
for each (let site in sites) {
for (let site of sites) {
stmt.bindByIndex(0, filePath);
stmt.bindByIndex(1, "http://" + site + "/file");
stmt.bindByIndex(2, dm.DOWNLOAD_FINISHED);

View File

@ -110,7 +110,7 @@ function populateDM(DownloadData)
"state, currBytes, maxBytes, preferredAction, autoResume) " +
"VALUES (:name, :source, :target, :startTime, :endTime, :state, " +
":currBytes, :maxBytes, :preferredAction, :autoResume)");
for each (let dl in DownloadData) {
for (let dl of DownloadData) {
for (let prop in dl)
stmt.params[prop] = dl[prop];

View File

@ -15,7 +15,7 @@ function run_test()
{
// Simulate having multiple downloads requesting time left
let downloadTimes = {};
for each (let time in [1, 30, 60, 3456, 9999])
for (let time of [1, 30, 60, 3456, 9999])
downloadTimes[time] = DownloadUtils.getTimeLeft(time)[0];
// Pretend we're a download status bar also asking for a time left, but we're

View File

@ -449,7 +449,7 @@ this.LightweightThemeManager = {
return;
}
aCallback([new AddonWrapper(a) for each (a in this.usedThemes)]);
aCallback(this.usedThemes.map(a => new AddonWrapper(a)));
},
};

View File

@ -638,8 +638,10 @@ var gViewController = {
this.viewObjects["detail"] = gDetailView;
this.viewObjects["updates"] = gUpdatesView;
for each (let view in this.viewObjects)
for (let type in this.viewObjects) {
let view = this.viewObjects[type];
view.initialize();
}
window.controllers.appendController(this);
@ -655,7 +657,8 @@ var gViewController = {
this.currentViewObj.hide();
this.currentViewRequest = 0;
for each(let view in this.viewObjects) {
for (let type in this.viewObjects) {
let view = this.viewObjects[type];
if ("shutdown" in view) {
try {
view.shutdown();

View File

@ -856,7 +856,8 @@ this.AddonRepository = {
// Include any compatibility overrides for addons not hosted by the
// remote repository.
for each (let addonCompat in aCompatData) {
for (let id in aCompatData) {
let addonCompat = aCompatData[id];
if (addonCompat.hosted)
continue;
@ -963,7 +964,7 @@ this.AddonRepository = {
this._searching = false;
this._request = null;
// The callback may want to trigger a new search so clear references early
let addons = [result.addon for each(result in aResults)];
let addons = aResults.map(result => result.addon);
let callback = this._callback;
this._callback = null;
callback.searchSucceeded(addons, addons.length, aTotalResults);
@ -1501,7 +1502,7 @@ this.AddonRepository = {
let localAddonIds = {ids: null, sourceURIs: null};
AddonManager.getAllAddons(function getLocalAddonIds_getAllAddons(aAddons) {
localAddonIds.ids = [a.id for each (a in aAddons)];
localAddonIds.ids = aAddons.map(a => a.id);
if (localAddonIds.sourceURIs)
aCallback(localAddonIds);
});

View File

@ -141,8 +141,10 @@ this.AddonRepository_SQLiteMigrator = {
},
_closeConnection: function() {
for each (let stmt in this.asyncStatementsCache)
for (let key in this.asyncStatementsCache) {
let stmt = this.asyncStatementsCache[key];
stmt.finalize();
}
this.asyncStatementsCache = {};
if (this.connection)
@ -315,8 +317,10 @@ this.AddonRepository_SQLiteMigrator = {
}
let returnedAddons = {};
for each (let addon in addons)
for (let id in addons) {
let addon = addons[id];
returnedAddons[addon.id] = addon;
}
aCallback(returnedAddons);
}
});

View File

@ -228,11 +228,11 @@ var PluginProvider = {
updatePluginList: function PL_updatePluginList() {
let newList = this.getPluginList();
let lostPlugins = [this.buildWrapper(this.plugins[id])
for each (id in Object.keys(this.plugins)) if (!(id in newList))];
let newPlugins = [this.buildWrapper(newList[id])
for each (id in Object.keys(newList)) if (!(id in this.plugins))];
let matchedIDs = [id for each (id in Object.keys(newList)) if (id in this.plugins)];
let lostPlugins = Object.keys(this.plugins).filter(id => !(id in newList)).
map(id => this.buildWrapper(this.plugins[id]));
let newPlugins = Object.keys(newList).filter(id => !(id in this.plugins)).
map(id => this.buildWrapper(newList[id]));
let matchedIDs = Object.keys(newList).filter(id => id in this.plugins);
// The plugin host generates new tags for every plugin after a scan and
// if the plugin's filename has changed then the disabled state won't have

View File

@ -1182,8 +1182,7 @@ function defineSyncGUID(aAddon) {
let rng = Cc["@mozilla.org/security/random-generator;1"].
createInstance(Ci.nsIRandomGenerator);
let bytes = rng.generateRandomBytes(9);
let byte_string = [String.fromCharCode(byte) for each (byte in bytes)]
.join("");
let byte_string = bytes.map(byte => String.fromCharCode(byte)).join("");
// Base64 encode
let guid = btoa(byte_string).replace(/\+/g, '-')
.replace(/\//g, '_');
@ -3746,7 +3745,7 @@ this.XPIProvider = {
let typesToGet = getAllAliasesForTypes(aTypes);
XPIDatabase.getVisibleAddons(typesToGet, function getAddonsByTypes_getVisibleAddons(aAddons) {
aCallback([createWrapper(a) for each (a in aAddons)]);
aCallback(aAddons.map(a => createWrapper(a)));
});
},
@ -3778,7 +3777,7 @@ this.XPIProvider = {
XPIDatabase.getVisibleAddonsWithPendingOperations(typesToGet,
function getAddonsWithOpsByTypes_getVisibleAddonsWithPendingOps(aAddons) {
let results = [createWrapper(a) for each (a in aAddons)];
let results = aAddons.map(a => createWrapper(a));
XPIProvider.installs.forEach(function(aInstall) {
if (aInstall.state == AddonManager.STATE_INSTALLED &&
!(aInstall.addon.inDatabase))
@ -5971,7 +5970,7 @@ function AddonInstallWrapper(aInstall) {
this.__defineGetter__("linkedInstalls", function AIW_linkedInstallsGetter() {
if (!aInstall.linkedInstalls)
return null;
return [i.wrapper for each (i in aInstall.linkedInstalls)];
return aInstall.linkedInstalls.map(i => i.wrapper);
});
this.install = function AIW_install() {

View File

@ -1101,7 +1101,7 @@ Blocklist.prototype = {
if (!toolkitVersion)
toolkitVersion = gApp.platformVersion;
for each (var blockEntry in pluginEntries) {
for (var blockEntry of pluginEntries) {
var matchFailed = false;
for (var name in blockEntry.matches) {
if (!(name in plugin) ||

View File

@ -286,7 +286,7 @@ function check_results(aQuery, aSortBy, aReverseOrder, aShowLocal) {
// Get actual order of results
var actualResults = get_actual_results();
var actualOrder = [result.name for each(result in actualResults)];
var actualOrder = actualResults.map(result => result.name);
// Reverse array of actual results if supposed to be in reverse order.
// Reverse actualOrder instead of expectedOrder so can always check

View File

@ -1378,7 +1378,9 @@ function check_test_completed(aArgs) {
if (gExpectedInstalls instanceof Array &&
gExpectedInstalls.length > 0)
return undefined;
else for each (let installList in gExpectedInstalls) {
for (let id in gExpectedInstalls) {
let installList = gExpectedInstalls[id];
if (installList.length > 0)
return undefined;
}

View File

@ -149,7 +149,7 @@ function run_test() {
startupManager();
dump("\n\n*** INSTALLING NEW ITEMS\n\n");
installAllFiles([do_get_addon(a.addon) for each (a in ADDONS)], run_test_pt2,
installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), run_test_pt2,
true);
}
@ -161,7 +161,7 @@ function run_test_pt2() {
dump("\n\n*** RESTARTING EXTENSION MANAGER\n\n");
restartManager();
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(items) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(items) {
dump("\n\n*** REQUESTING UPDATE\n\n");
// checkListener will call run_test_pt3().
next_test = run_test_pt3;
@ -186,7 +186,7 @@ function run_test_pt2() {
function run_test_pt3() {
// Install the new items.
dump("\n\n*** UPDATING ITEMS\n\n");
completeAllInstalls([a.newInstall for each(a in ADDONS) if (a.newInstall)],
completeAllInstalls(ADDONS.filter(a => a.newInstall).map(a => a.newInstall),
run_test_pt4);
}
@ -198,7 +198,7 @@ function run_test_pt4() {
restartManager();
dump("\n\n*** FINAL CHECKS\n\n");
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(items) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(items) {
for (var i = 0; i < ADDONS.length; i++) {
var item = items[i];
do_check_item(item, "0.2", ADDONS[i]);

View File

@ -136,7 +136,7 @@ function run_test() {
startupManager();
installAllFiles([do_get_addon(a.addon) for each (a in ADDONS)], function() {
installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), function() {
restartManager();
AddonManager.getAddonByID(ADDONS[0].id, callback_soon(function(addon) {
do_check_true(!(!addon));

View File

@ -154,7 +154,7 @@ function run_test() {
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "en-US");
startupManager();
installAllFiles([do_get_addon(a.addon) for each (a in ADDONS)], function() {
installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), function() {
restartManager();
AddonManager.getAddonByID(ADDONS[1].id, callback_soon(function(addon) {
@ -162,7 +162,7 @@ function run_test() {
addon.userDisabled = true;
restartManager();
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(installedItems) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(installedItems) {
installedItems.forEach(function(item) {
updateListener.pendingCount++;
item.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);

View File

@ -317,7 +317,7 @@ function create_addon(addon) {
* the newly blocked items compared to the previous test.
*/
function check_state(test, lastTest, callback) {
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
for (var i = 0; i < ADDONS.length; i++) {
var blocked = addons[i].blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED;
if (blocked != ADDONS[i][test])
@ -386,7 +386,7 @@ function run_test() {
function check_test_pt1() {
dump("Checking pt 1\n");
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
for (var i = 0; i < ADDONS.length; i++) {
if (!addons[i])
do_throw("Addon " + (i + 1) + " did not get installed correctly");

View File

@ -239,7 +239,7 @@ function run_test() {
// Before every main test this is the state the add-ons are meant to be in
function check_initial_state(callback) {
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
do_check_eq(check_addon_state(addons[0]), "true,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[2]), "false,false,false");
@ -263,7 +263,7 @@ function check_initial_state(callback) {
function check_test_pt1() {
dump("Checking pt 1\n");
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], callback_soon(function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), callback_soon(function(addons) {
for (var i = 0; i < ADDONS.length; i++) {
if (!addons[i])
do_throw("Addon " + (i + 1) + " did not get installed correctly");
@ -335,7 +335,7 @@ function check_test_pt2() {
restartManager();
dump("Checking results pt 2\n");
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], callback_soon(function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), callback_soon(function(addons) {
// Should have disabled this add-on as requested
do_check_eq(check_addon_state(addons[2]), "true,true,false");
do_check_eq(check_plugin_state(PLUGINS[2]), "true,false");
@ -421,7 +421,7 @@ function check_test_pt3() {
let blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
getService(Ci.nsIBlocklistService);
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
// All should have gained the blocklist state, user disabled as previously
do_check_eq(check_addon_state(addons[0]), "true,false,true");
do_check_eq(check_addon_state(addons[1]), "false,false,true");
@ -488,7 +488,7 @@ function check_test_pt4() {
restartManager();
dump("Checking results pt 4\n");
AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
// This should have become unblocked
do_check_eq(check_addon_state(addons[5]), "false,false,false");
do_check_eq(check_plugin_state(PLUGINS[5]), "false,false");

View File

@ -28,7 +28,7 @@ function run_test() {
startupManager();
installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
installAllFiles(ADDONS.map(a => do_get_addon(a)), function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",

View File

@ -28,7 +28,7 @@ function run_test() {
startupManager();
installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
installAllFiles(ADDONS.map(a => do_get_addon(a)), function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",

View File

@ -28,7 +28,7 @@ function run_test() {
startupManager();
AddonManager.checkCompatibility = false;
installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
installAllFiles(ADDONS.map(a => do_get_addon(a)), function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",

View File

@ -132,7 +132,7 @@ function prepare_profile() {
a6.userDisabled = true;
a9.userDisabled = false;
for each (let addon in [a1, a2, a3, a4, a5, a6]) {
for (let addon of [a1, a2, a3, a4, a5, a6]) {
oldSyncGUIDs[addon.id] = addon.syncGUID;
}

View File

@ -111,7 +111,7 @@ add_test(function test_error_on_duplicate_syncguid_insert() {
AddonManager.addInstallListener(listener);
let getInstallCB = function(install) { install.install(); };
for each (let name in installNames) {
for (let name of installNames) {
AddonManager.getInstallForFile(do_get_addon(name), getInstallCB);
}
});

View File

@ -665,7 +665,7 @@ function run_test_8() {
item_maxappversion, item_status,
app_id, app_version, current_app_version,
app_os, app_abi, app_locale, update_type] =
[decodeURIComponent(a) for each (a in request.queryString.split("/"))];
request.queryString.split("/").map(a => decodeURIComponent(a));
do_check_eq(req_version, "2");

View File

@ -585,7 +585,7 @@ function run_test_8() {
item_maxappversion, item_status,
app_id, app_version, current_app_version,
app_os, app_abi, app_locale, update_type] =
[decodeURIComponent(a) for each (a in request.queryString.split("/"))];
request.queryString.split("/").map(a => decodeURIComponent(a));
do_check_eq(req_version, "2");

View File

@ -58,7 +58,7 @@ nsContentDispatchChooser.prototype =
let SupportsString = Components.Constructor(
"@mozilla.org/supports-string;1",
"nsISupportsString");
for each (let text in arr) {
for (let text of arr) {
let string = new SupportsString;
string.data = text;
params.appendElement(string, false);

View File

@ -70,7 +70,7 @@ function get_modules_under(uri) {
function load_modules_under(spec, uri) {
var entries = get_modules_under(uri).sort();
for each (let entry in entries) {
for (let entry of entries) {
try {
dump(spec + entry + "\n");
Cu.import(spec + entry, null);

View File

@ -64,7 +64,7 @@ function dirContainsOnly(dir, expectedFiles) {
let ret = true;
// Find unexpected files
for each (let {path} in entries) {
for (let {path} of entries) {
if (expectedFiles.indexOf(path) == -1) {
info("Unexpected file: " + path);
ret = false;
@ -72,7 +72,7 @@ function dirContainsOnly(dir, expectedFiles) {
}
// Find missing files
for each (let expectedPath in expectedFiles) {
for (let expectedPath of expectedFiles) {
if (entries.findIndex(({path}) => path == expectedPath) == -1) {
info("Missing file: " + expectedPath);
ret = false;
@ -95,7 +95,7 @@ var dirSize = Task.async(function*(aDir) {
let size = 0;
for each (let entry in entries) {
for (let entry of entries) {
if (entry.isDir) {
size += yield dirSize(entry.path);
} else {