Bug 1217093 - Remove for-each from dom/. r=smaug

This commit is contained in:
Tooru Fujisawa 2015-10-19 02:00:50 +09:00
parent 9bef79efc8
commit 8a3eb7d1bb
22 changed files with 52 additions and 47 deletions

View File

@ -591,7 +591,7 @@ this.expandPermissions = function expandPermissions(aPermName, aAccess) {
// Add the same suffix to each of the additions. // Add the same suffix to each of the additions.
if (tableEntry.additional) { if (tableEntry.additional) {
for each (let additional in tableEntry.additional) { for (let additional of tableEntry.additional) {
permArr = permArr.concat(appendAccessToPermName(additional, requestedSuffixes)); permArr = permArr.concat(appendAccessToPermName(additional, requestedSuffixes));
} }
} }

View File

@ -21,7 +21,7 @@
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
var imports = [ "SimpleTest", "is", "isnot", "ok" ]; var imports = [ "SimpleTest", "is", "isnot", "ok" ];
for each (var name in imports) { for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name]; window[name] = window.opener.wrappedJSObject[name];
} }

View File

@ -13,7 +13,7 @@ function handleRequest(request, response) {
invalidHeaders.push("Authorization"); invalidHeaders.push("Authorization");
} }
for each (let header in invalidHeaders) { for (let header of invalidHeaders) {
if (request.hasHeader(header)) { if (request.hasHeader(header)) {
response.setStatusLine(null, 500, "Server Error"); response.setStatusLine(null, 500, "Server Error");
headers[header.toLowerCase()] = request.getHeader(header); headers[header.toLowerCase()] = request.getHeader(header);

View File

@ -119,7 +119,7 @@
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();", mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
false); false);
for each (let message in messages) { for (let message of messages) {
mm.sendAsyncMessage("test:ipcClonedMessage", message); mm.sendAsyncMessage("test:ipcClonedMessage", message);
} }
}); });

View File

@ -338,7 +338,7 @@ BrowserElementAuthPrompt.prototype = {
prompt.authInfo.password = password; prompt.authInfo.password = password;
} }
for each (let consumer in prompt.consumers) { for (let consumer of prompt.consumers) {
if (!consumer.callback) { if (!consumer.callback) {
// Not having a callback means that consumer didn't provide it // Not having a callback means that consumer didn't provide it
// or canceled the notification. // or canceled the notification.

View File

@ -38,7 +38,7 @@ addLoadEvent(function() {
} }
} }
for each(var event in ["online", "offline"]) { for (var event of ["online", "offline"]) {
document.documentElement.addEventListener( document.documentElement.addEventListener(
event, event,
makeHandler("document.body.addEventListener('%1', ..., false)", makeHandler("document.body.addEventListener('%1', ..., false)",

View File

@ -67,12 +67,12 @@ function createTestEventValue(name) {
is(ev.pointerId, pointerId, "Correct pointerId"); is(ev.pointerId, pointerId, "Correct pointerId");
} }
for each (let target in [document, window, testTarget, parent]) for (let target of [document, window, testTarget, parent])
target.addEventListener(name, check, false); target.addEventListener(name, check, false);
testTarget.dispatchEvent(event); testTarget.dispatchEvent(event);
for each (let target in [document, window, testTarget, parent]) for (let target of [document, window, testTarget, parent])
target.removeEventListener(name, check, false); target.removeEventListener(name, check, false);

View File

@ -34,7 +34,7 @@ var group2;
var group3; var group3;
var tags = ["input", "menuitem"]; var tags = ["input", "menuitem"];
for each (let tag in tags) { for (let tag of tags) {
function bounce(node) { function bounce(node) {
let n = node.nextSibling; let n = node.nextSibling;
@ -46,7 +46,7 @@ function bounce(node) {
var createdNodes = []; var createdNodes = [];
function cleanup() { function cleanup() {
for each (let node in createdNodes) { for (let node of createdNodes) {
if (node.parentNode) { if (node.parentNode) {
node.parentNode.removeChild(node); node.parentNode.removeChild(node);
} }
@ -79,7 +79,7 @@ var types = ['c', 'r'];
// First make sure that setting .checked makes .defaultChecked changes no // First make sure that setting .checked makes .defaultChecked changes no
// longer affect .checked. // longer affect .checked.
for each (let type in types) { for (let type of types) {
let n = createNode(type, '', false); let n = createNode(type, '', false);
is(n.defaultChecked, false, "Bogus defaultChecked on " + typeMapper[type]); is(n.defaultChecked, false, "Bogus defaultChecked on " + typeMapper[type]);
is(n.checked, false, "Bogus checked on " + typeMapper[type]); is(n.checked, false, "Bogus checked on " + typeMapper[type]);
@ -109,7 +109,7 @@ cleanup();
// Now check that bouncing a control that's the only one of its kind has no // Now check that bouncing a control that's the only one of its kind has no
// effect // effect
for each (let type in types) { for (let type of types) {
let n = createNode(type, 'test1', true); let n = createNode(type, 'test1', true);
$(tag == "input" ? "f1" : "m1").appendChild(n); $(tag == "input" ? "f1" : "m1").appendChild(n);
n.checked = false; n.checked = false;

View File

@ -1647,7 +1647,7 @@ MmsService.prototype = {
savable.receivers = []; savable.receivers = [];
// We don't have Bcc in recevied MMS message. // We don't have Bcc in recevied MMS message.
for each (let type in ["cc", "to"]) { for (let type of ["cc", "to"]) {
if (intermediate.headers[type]) { if (intermediate.headers[type]) {
if (intermediate.headers[type] instanceof Array) { if (intermediate.headers[type] instanceof Array) {
for (let index in intermediate.headers[type]) { for (let index in intermediate.headers[type]) {

View File

@ -673,7 +673,7 @@ MobileMessageDB.prototype = {
stores = txn.objectStore(storeNames[0]); stores = txn.objectStore(storeNames[0]);
} else { } else {
stores = []; stores = [];
for each (let storeName in storeNames) { for (let storeName of storeNames) {
if (DEBUG) debug("Retrieving object store " + storeName); if (DEBUG) debug("Retrieving object store " + storeName);
stores.push(txn.objectStore(storeName)); stores.push(txn.objectStore(storeName));
} }
@ -1460,7 +1460,7 @@ MobileMessageDB.prototype = {
let timestamp = messageRecord.timestamp; let timestamp = messageRecord.timestamp;
// Setup participantIdsIndex. // Setup participantIdsIndex.
messageRecord.participantIdsIndex = []; messageRecord.participantIdsIndex = [];
for each (let id in participantIds) { for (let id of participantIds) {
messageRecord.participantIdsIndex.push([id, timestamp]); messageRecord.participantIdsIndex.push([id, timestamp]);
} }
if (threadRecord) { if (threadRecord) {
@ -2857,7 +2857,7 @@ MobileMessageDB.prototype = {
aMessageRecord.threadIdIndex = [threadId, timestamp]; aMessageRecord.threadIdIndex = [threadId, timestamp];
// Setup participantIdsIndex. // Setup participantIdsIndex.
aMessageRecord.participantIdsIndex = []; aMessageRecord.participantIdsIndex = [];
for each (let id in participantIds) { for (let id of participantIds) {
aMessageRecord.participantIdsIndex.push([id, timestamp]); aMessageRecord.participantIdsIndex.push([id, timestamp]);
} }

View File

@ -171,7 +171,7 @@ var LEGACY = {
aMessageRecord.threadIdIndex = [threadId, timestamp]; aMessageRecord.threadIdIndex = [threadId, timestamp];
// Setup participantIdsIndex. // Setup participantIdsIndex.
aMessageRecord.participantIdsIndex = []; aMessageRecord.participantIdsIndex = [];
for each (let id in participantIds) { for (let id of participantIds) {
aMessageRecord.participantIdsIndex.push([id, timestamp]); aMessageRecord.participantIdsIndex.push([id, timestamp]);
} }

View File

@ -45,7 +45,7 @@ var PaymentManager = {
} }
} catch(e) {} } catch(e) {}
for each (let msgname in PAYMENT_IPC_MSG_NAMES) { for (let msgname of PAYMENT_IPC_MSG_NAMES) {
ppmm.addMessageListener(msgname, this); ppmm.addMessageListener(msgname, this);
} }
@ -401,7 +401,7 @@ var PaymentManager = {
observe: function observe(subject, topic, data) { observe: function observe(subject, topic, data) {
if (topic == "xpcom-shutdown") { if (topic == "xpcom-shutdown") {
for each (let msgname in PAYMENT_IPC_MSG_NAMES) { for (let msgname of PAYMENT_IPC_MSG_NAMES) {
ppmm.removeMessageListener(msgname, this); ppmm.removeMessageListener(msgname, this);
} }
this.registeredProviders = null; this.registeredProviders = null;

View File

@ -79,13 +79,13 @@ var tests = [
{ values: "foo bar baz qux", length: 4 } ] } { values: "foo bar baz qux", length: 4 } ] }
]; ];
for each (let test in tests) { for (let test of tests) {
let list = test.element; let list = test.element;
for each (let property in test.listProperty.split(".")) { for (let property of test.listProperty.split(".")) {
list = list[property]; list = list[property];
} }
for each (let subtest in test.subtests) { for (let subtest of test.subtests) {
if (subtest.values) { if (subtest.values) {
test.element.setAttribute(test.attribute, subtest.values); test.element.setAttribute(test.attribute, subtest.values);
} }

View File

@ -267,7 +267,7 @@ function isValidInterpolation(aFromType, aToType)
// Runs the test. // Runs the test.
function run() function run()
{ {
for each (let additive in [false, true]) { for (let additive of [false, true]) {
let indexOfExpectedArguments = additive ? 3 : 2; let indexOfExpectedArguments = additive ? 3 : 2;
// Add subtests for each combination of prefix and suffix, and additive // Add subtests for each combination of prefix and suffix, and additive
@ -279,7 +279,7 @@ function run()
toArguments = suffixEntry[1], toArguments = suffixEntry[1],
expectedArguments = suffixEntry[indexOfExpectedArguments]; expectedArguments = suffixEntry[indexOfExpectedArguments];
for each (let prefixEntry in gPrefixes) { for (let prefixEntry of gPrefixes) {
let [prefixLength, prefix] = prefixEntry; let [prefixLength, prefix] = prefixEntry;
addTest(prefixLength, prefix, fromType, fromArguments, addTest(prefixLength, prefix, fromType, fromArguments,
toType, toArguments, toType, expectedArguments, additive); toType, toArguments, toType, expectedArguments, additive);
@ -298,9 +298,9 @@ function run()
"a", [60, 70, 80, 1, 0, 90, 100], additive); "a", [60, 70, 80, 1, 0, 90, 100], additive);
// Test all pairs of segment types that cannot be interpolated between. // Test all pairs of segment types that cannot be interpolated between.
for each (let fromType in gTypes) { for (let fromType of gTypes) {
let fromArguments = generatePathSegmentArguments(fromType, 0); let fromArguments = generatePathSegmentArguments(fromType, 0);
for each (let toType in gTypes) { for (let toType of gTypes) {
if (!isValidInterpolation(fromType, toType)) { if (!isValidInterpolation(fromType, toType)) {
let toArguments = generatePathSegmentArguments(toType, 1000); let toArguments = generatePathSegmentArguments(toType, 1000);
addTest(1, "M100,100", fromType, fromArguments, addTest(1, "M100,100", fromType, fromArguments,
@ -314,7 +314,7 @@ function run()
gSVG.setCurrentTime(4); gSVG.setCurrentTime(4);
// Inspect the results of each subtest. // Inspect the results of each subtest.
for each (let test in gTests) { for (let test of gTests) {
let list = test.element.animatedPathSegList; let list = test.element.animatedPathSegList;
is(list.numberOfItems, test.prefixLength + 1, is(list.numberOfItems, test.prefixLength + 1,
"Length of animatedPathSegList for interpolation " + "Length of animatedPathSegList for interpolation " +

View File

@ -236,7 +236,8 @@ NetworkManager.prototype = {
let excludeFota = aMsg.json.excludeFota; let excludeFota = aMsg.json.excludeFota;
let interfaces = []; let interfaces = [];
for each (let network in this.networkInterfaces) { for (let key in this.networkInterfaces) {
let network = this.networkInterfaces[key];
let i = network.info; let i = network.info;
if ((i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS && excludeMms) || if ((i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
(i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) || (i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
@ -825,7 +826,8 @@ NetworkManager.prototype = {
this._activeNetwork = null; this._activeNetwork = null;
let anyConnected = false; let anyConnected = false;
for each (let network in this.networkInterfaces) { for (let key in this.networkInterfaces) {
let network = this.networkInterfaces[key];
if (network.info.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) { if (network.info.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
continue; continue;
} }

View File

@ -363,7 +363,8 @@ TetheringService.prototype = {
}, },
getNetworkInfo: function(aType, aServiceId) { getNetworkInfo: function(aType, aServiceId) {
for each (let networkInfo in gNetworkManager.allNetworkInfo) { for (let networkId in gNetworkManager.allNetworkInfo) {
let networkInfo = gNetworkManager.allNetworkInfo[networkId];
if (networkInfo.type == aType) { if (networkInfo.type == aType) {
try { try {
if (networkInfo instanceof Ci.nsIRilNetworkInfo) { if (networkInfo instanceof Ci.nsIRilNetworkInfo) {

View File

@ -3786,7 +3786,8 @@ RilObject.prototype = {
} }
let list = null; let list = null;
for each (let ll in usedCellBroadcastConfigs) { for (let key in usedCellBroadcastConfigs) {
let ll = usedCellBroadcastConfigs[key];
if (ll == null) { if (ll == null) {
continue; continue;
} }

View File

@ -141,7 +141,7 @@ TVSimulatorService.prototype = {
this._internalTuners = new Map(); this._internalTuners = new Map();
// TVTunerData // TVTunerData
for each (let tunerData in settingsObj.tuners) { for (let tunerData of settingsObj.tuners) {
let tuner = Cc["@mozilla.org/tv/tvtunerdata;1"] let tuner = Cc["@mozilla.org/tv/tvtunerdata;1"]
.createInstance(Ci.nsITVTunerData); .createInstance(Ci.nsITVTunerData);
tuner.id = tunerData.id; tuner.id = tunerData.id;
@ -156,11 +156,11 @@ TVSimulatorService.prototype = {
}; };
// TVSource // TVSource
for each (let sourceData in tunerData.sources) { for (let sourceData of tunerData.sources) {
wrapTunerData.sourceType = sourceData.type; wrapTunerData.sourceType = sourceData.type;
// TVChannel // TVChannel
for each (let channelData in sourceData.channels) { for (let channelData of sourceData.channels) {
let channel = Cc["@mozilla.org/tv/tvchanneldata;1"] let channel = Cc["@mozilla.org/tv/tvchanneldata;1"]
.createInstance(Ci.nsITVChannelData); .createInstance(Ci.nsITVChannelData);
channel.networkId = channelData.networkId; channel.networkId = channelData.networkId;
@ -179,7 +179,7 @@ TVSimulatorService.prototype = {
}; };
// TVProgram // TVProgram
for each (let programData in channelData.programs) { for (let programData of channelData.programs) {
let program = Cc["@mozilla.org/tv/tvprogramdata;1"] let program = Cc["@mozilla.org/tv/tvprogramdata;1"]
.createInstance(Ci.nsITVProgramData); .createInstance(Ci.nsITVProgramData);
program.eventId = programData.eventId; program.eventId = programData.eventId;
@ -386,7 +386,7 @@ TVSimulatorService.prototype = {
return Cr.NS_ERROR_INVALID_ARG; return Cr.NS_ERROR_INVALID_ARG;
} }
for each (let program in wrapChannelData.programs) { for (let program of wrapChannelData.programs) {
programArray.appendElement(program, false); programArray.appendElement(program, false);
} }
@ -461,7 +461,7 @@ TVSimulatorService.prototype = {
_validateTuners: function TVSimValidateTuners(aTunersObject) { _validateTuners: function TVSimValidateTuners(aTunersObject) {
let tunerIds = new Array(); let tunerIds = new Array();
for each (let tuner in aTunersObject) { for (let tuner of aTunersObject) {
if (!tuner.id || if (!tuner.id ||
!tuner.supportedType || !tuner.supportedType ||
!tuner.supportedType.length || !tuner.supportedType.length ||
@ -480,7 +480,7 @@ TVSimulatorService.prototype = {
}, },
_validateSources: function TVSimValidateSources(aSourcesObject) { _validateSources: function TVSimValidateSources(aSourcesObject) {
for each (let source in aSourcesObject) { for (let source of aSourcesObject) {
if (!source.type || if (!source.type ||
!TV_SOURCE_TYPES.includes(source.type)) { !TV_SOURCE_TYPES.includes(source.type)) {
debug("invalid source data."); debug("invalid source data.");
@ -496,7 +496,7 @@ TVSimulatorService.prototype = {
_validateChannels: function TVSimValidateChannels(aChannelsObject) { _validateChannels: function TVSimValidateChannels(aChannelsObject) {
let channelNumbers = new Array(); let channelNumbers = new Array();
for each (let channel in aChannelsObject) { for (let channel of aChannelsObject) {
if (!channel.networkId || if (!channel.networkId ||
!channel.transportStreamId || !channel.transportStreamId ||
!channel.serviceId || !channel.serviceId ||
@ -519,7 +519,7 @@ TVSimulatorService.prototype = {
_validatePrograms: function TVSimValidatePrograms(aProgramsObject) { _validatePrograms: function TVSimValidatePrograms(aProgramsObject) {
let eventIds = new Array(); let eventIds = new Array();
for each (let program in aProgramsObject) { for (let program of aProgramsObject) {
if (!program.eventId || if (!program.eventId ||
eventIds.includes(program.eventId) || eventIds.includes(program.eventId) ||
!program.title || !program.title ||

View File

@ -128,7 +128,7 @@ var PDUBuilder = {
let headerLength = 0; let headerLength = 0;
this.buf = ""; this.buf = "";
if (options.headers) { if (options.headers) {
for each (let header in options.headers) { for (let header of options.headers) {
headerLength += 2; // id + length octets headerLength += 2; // id + length octets
if (header.octets) { if (header.octets) {
headerLength += header.octets.length; headerLength += header.octets.length;
@ -149,12 +149,12 @@ var PDUBuilder = {
if (options.headers) { if (options.headers) {
this.writeHexOctet(headerLength); this.writeHexOctet(headerLength);
for each (let header in options.headers) { for (let header of options.headers) {
this.writeHexOctet(header.id); this.writeHexOctet(header.id);
this.writeHexOctet(header.length); this.writeHexOctet(header.length);
if (header.octets) { if (header.octets) {
for each (let octet in header.octets) { for (let octet of header.octets) {
this.writeHexOctet(octet); this.writeHexOctet(octet);
} }
} }

View File

@ -2608,7 +2608,8 @@ WifiWorker.prototype = {
// connect to which ever network it thinks is best, so when we select the // connect to which ever network it thinks is best, so when we select the
// proper network (or fail to), we need to re-enable the rest. // proper network (or fail to), we need to re-enable the rest.
_enableAllNetworks: function() { _enableAllNetworks: function() {
for each (let net in this.configuredNetworks) { for (let key in this.configuredNetworks) {
let net = this.configuredNetworks[key];
WifiManager.enableNetwork(net.netId, false, function(ok) { WifiManager.enableNetwork(net.netId, false, function(ok) {
net.disabled = ok ? 1 : 0; net.disabled = ok ? 1 : 0;
}); });

View File

@ -11,7 +11,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function testForExpectedSymbols(stage, data) { function testForExpectedSymbols(stage, data) {
const expectedSymbols = [ "Worker", "ChromeWorker" ]; const expectedSymbols = [ "Worker", "ChromeWorker" ];
for each (var symbol in expectedSymbols) { for (var symbol of expectedSymbols) {
Services.prefs.setBoolPref("workertest.bootstrap." + stage + "." + symbol, Services.prefs.setBoolPref("workertest.bootstrap." + stage + "." + symbol,
symbol in this); symbol in this);
} }

View File

@ -31,8 +31,8 @@
const stages = [ "install", "startup", "shutdown", "uninstall" ]; const stages = [ "install", "startup", "shutdown", "uninstall" ];
const symbols = [ "Worker", "ChromeWorker" ]; const symbols = [ "Worker", "ChromeWorker" ];
for each (var stage in stages) { for (var stage of stages) {
for each (var symbol in symbols) { for (var symbol of symbols) {
is(Services.prefs.getBoolPref("workertest.bootstrap." + stage + is(Services.prefs.getBoolPref("workertest.bootstrap." + stage +
"." + symbol), "." + symbol),
true, true,