merge m-c to fx-team

This commit is contained in:
Tim Taubert 2012-05-29 10:22:01 +02:00
commit ab5c22ed82
32 changed files with 191 additions and 222 deletions

View File

@ -1195,9 +1195,9 @@ var AddonManagerInternal = {
if (!aUrl || !aMimetype || !aCallback)
throw new TypeError("Invalid arguments");
for (let i = 0; i < this.providers.length; i++) {
if (callProvider(this.providers[i], "supportsMimetype", false, aMimetype)) {
callProvider(this.providers[i], "getInstallForURL", null,
for (let provider of this.providers) {
if (callProvider(provider, "supportsMimetype", false, aMimetype)) {
callProvider(provider, "getInstallForURL", null,
aUrl, aHash, aName, aIconURL, aVersion, aLoadGroup,
function(aInstall) {
safeCall(aCallback, aInstall);
@ -1289,9 +1289,9 @@ var AddonManagerInternal = {
* @return true if installation is enabled for the mimetype
*/
isInstallEnabled: function AMI_isInstallEnabled(aMimetype) {
for (let i = 0; i < this.providers.length; i++) {
if (callProvider(this.providers[i], "supportsMimetype", false, aMimetype) &&
callProvider(this.providers[i], "isInstallEnabled"))
for (let provider of this.providers) {
if (callProvider(provider, "supportsMimetype", false, aMimetype) &&
callProvider(provider, "isInstallEnabled"))
return true;
}
return false;
@ -1308,9 +1308,9 @@ var AddonManagerInternal = {
* @return true if the source is allowed to install this mimetype
*/
isInstallAllowed: function AMI_isInstallAllowed(aMimetype, aURI) {
for (let i = 0; i < this.providers.length; i++) {
if (callProvider(this.providers[i], "supportsMimetype", false, aMimetype) &&
callProvider(this.providers[i], "isInstallAllowed", null, aURI))
for (let provider of this.providers) {
if (callProvider(provider, "supportsMimetype", false, aMimetype) &&
callProvider(provider, "isInstallAllowed", null, aURI))
return true;
}
return false;

View File

@ -1298,8 +1298,7 @@ var AddonRepository = {
function findMatchingAppRange(aNodes) {
let toolkitAppRange = null;
for (let i = 0; i < aNodes.length; i++) {
let node = aNodes[i];
for (let node of aNodes) {
let appID = this._getDescendantTextContent(node, "appID");
if (appID != Services.appinfo.ID && appID != TOOLKIT_ID)
continue;
@ -1470,8 +1469,7 @@ var AddonRepository = {
aCompatOverrides,
aAppVersion,
aPlatformVersion) {
for (let i = 0; i < aCompatOverrides.length; i++) {
let override = aCompatOverrides[i];
for (let override of aCompatOverrides) {
let appVersion = null;
if (override.appID == TOOLKIT_ID)

View File

@ -625,8 +625,7 @@ function matchesVersions(aUpdate, aAppVersion, aPlatformVersion,
aIgnoreMaxVersion = false;
let result = false;
for (let i = 0; i < aUpdate.targetApplications.length; i++) {
let app = aUpdate.targetApplications[i];
for (let app of aUpdate.targetApplications) {
if (app.id == Services.appinfo.ID) {
return (Services.vc.compare(aAppVersion, app.minVersion) >= 0) &&
(aIgnoreMaxVersion || (Services.vc.compare(aAppVersion, app.maxVersion) <= 0));
@ -684,18 +683,18 @@ var AddonUpdateChecker = {
if (!aPlatformVersion)
aPlatformVersion = Services.appinfo.platformVersion;
for (let i = 0; i < aUpdates.length; i++) {
if (Services.vc.compare(aUpdates[i].version, aVersion) == 0) {
for (let update of aUpdates) {
if (Services.vc.compare(update.version, aVersion) == 0) {
if (aIgnoreCompatibility) {
for (let j = 0; j < aUpdates[i].targetApplications.length; j++) {
let id = aUpdates[i].targetApplications[j].id;
for (let targetApp of update.targetApplications) {
let id = targetApp.id;
if (id == Services.appinfo.ID || id == TOOLKIT_ID)
return aUpdates[i];
return update;
}
}
else if (matchesVersions(aUpdates[i], aAppVersion, aPlatformVersion,
else if (matchesVersions(update, aAppVersion, aPlatformVersion,
aIgnoreMaxVersion, aIgnoreStrictCompat)) {
return aUpdates[i];
return update;
}
}
}
@ -734,18 +733,18 @@ var AddonUpdateChecker = {
getService(Ci.nsIBlocklistService);
let newest = null;
for (let i = 0; i < aUpdates.length; i++) {
if (!aUpdates[i].updateURL)
for (let update of aUpdates) {
if (!update.updateURL)
continue;
let state = blocklist.getAddonBlocklistState(aUpdates[i].id, aUpdates[i].version,
let state = blocklist.getAddonBlocklistState(update.id, update.version,
aAppVersion, aPlatformVersion);
if (state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
continue;
if ((newest == null || (Services.vc.compare(newest.version, aUpdates[i].version) < 0)) &&
matchesVersions(aUpdates[i], aAppVersion, aPlatformVersion,
if ((newest == null || (Services.vc.compare(newest.version, update.version) < 0)) &&
matchesVersions(update, aAppVersion, aPlatformVersion,
aIgnoreMaxVersion, aIgnoreStrictCompat,
aCompatOverrides)) {
newest = aUpdates[i];
newest = update;
}
}
return newest;

View File

@ -110,9 +110,9 @@ var LightweightThemeManager = {
getUsedTheme: function (aId) {
var usedThemes = this.usedThemes;
for (let i = 0; i < usedThemes.length; i++) {
if (usedThemes[i].id == aId)
return usedThemes[i];
for (let usedTheme of usedThemes) {
if (usedTheme.id == aId)
return usedTheme;
}
return null;
},
@ -643,18 +643,18 @@ function _sanitizeTheme(aData, aBaseURI, aLocal) {
}
let result = {};
for (let i = 0; i < MANDATORY.length; i++) {
let val = sanitizeProperty(MANDATORY[i]);
for (let mandatoryProperty of MANDATORY) {
let val = sanitizeProperty(mandatoryProperty);
if (!val)
throw Components.results.NS_ERROR_INVALID_ARG;
result[MANDATORY[i]] = val;
result[mandatoryProperty] = val;
}
for (let i = 0; i < OPTIONAL.length; i++) {
let val = sanitizeProperty(OPTIONAL[i]);
for (let optionalProperty of OPTIONAL) {
let val = sanitizeProperty(optionalProperty);
if (!val)
continue;
result[OPTIONAL[i]] = val;
result[optionalProperty] = val;
}
return result;

View File

@ -7120,17 +7120,17 @@ UpdateChecker.prototype = {
compatOverrides);
if (update && Services.vc.compare(this.addon.version, update.version) < 0) {
for (let i = 0; i < XPIProvider.installs.length; i++) {
for (let currentInstall of XPIProvider.installs) {
// Skip installs that don't match the available update
if (XPIProvider.installs[i].existingAddon != this.addon ||
XPIProvider.installs[i].version != update.version)
if (currentInstall.existingAddon != this.addon ||
currentInstall.version != update.version)
continue;
// If the existing install has not yet started downloading then send an
// available update notification. If it is already downloading then
// don't send any available update notification
if (XPIProvider.installs[i].state == AddonManager.STATE_AVAILABLE)
sendUpdateAvailableMessages(this, XPIProvider.installs[i]);
if (currentInstall.state == AddonManager.STATE_AVAILABLE)
sendUpdateAvailableMessages(this, currentInstall);
else
sendUpdateAvailableMessages(this, null);
return;
@ -7219,8 +7219,7 @@ AddonInternal.prototype = {
}
catch (e) { }
for (let i = 0; i < this.targetPlatforms.length; i++) {
let platform = this.targetPlatforms[i];
for (let platform of this.targetPlatforms) {
if (platform.os == Services.appinfo.OS) {
if (platform.abi) {
needsABI = true;
@ -7288,11 +7287,11 @@ AddonInternal.prototype = {
get matchingTargetApplication() {
let app = null;
for (let i = 0; i < this.targetApplications.length; i++) {
if (this.targetApplications[i].id == Services.appinfo.ID)
return this.targetApplications[i];
if (this.targetApplications[i].id == TOOLKIT_ID)
app = this.targetApplications[i];
for (let targetApp of this.targetApplications) {
if (targetApp.id == Services.appinfo.ID)
return targetApp;
if (targetApp.id == TOOLKIT_ID)
app = targetApp;
}
return app;
},
@ -7413,8 +7412,7 @@ function DBAddonInternal() {
this.__defineGetter__("pendingUpgrade", function() {
delete this.pendingUpgrade;
for (let i = 0; i < XPIProvider.installs.length; i++) {
let install = XPIProvider.installs[i];
for (let install of XPIProvider.installs) {
if (install.state == AddonManager.STATE_INSTALLED &&
!(install.addon instanceof DBAddonInternal) &&
install.addon.id == this.id &&

View File

@ -99,8 +99,7 @@ Installer.prototype = {
var failed = [];
var installs = [];
for (let i = 0; i < this.downloads.length; i++) {
let install = this.downloads[i];
for (let install of this.downloads) {
switch (install.state) {
case AddonManager.STATE_AVAILABLE:
case AddonManager.STATE_DOWNLOADING:
@ -194,8 +193,7 @@ Installer.prototype = {
checkAllInstalled: function() {
var failed = [];
for (let i = 0; i < this.downloads.length; i++) {
let install = this.downloads[i];
for (let install of this.downloads) {
switch(install.state) {
case AddonManager.STATE_DOWNLOADED:
case AddonManager.STATE_INSTALLING:

View File

@ -80,9 +80,9 @@ function appendToList(aHeaderId, aNodeId, aItems) {
return 0;
}
for (let i = 0; i < aItems.length; i++) {
for (let currentItem of aItems) {
var label = document.createElement("label");
label.textContent = aItems[i];
label.textContent = currentItem;
label.setAttribute("class", "contributor");
node.appendChild(label);
}

View File

@ -25,12 +25,12 @@ function init() {
var richlist = document.getElementById("addonList");
var list = gArgs.list;
list.sort(function(a, b) { return String.localeCompare(a.name, b.name); });
for (let i = 0; i < list.length; i++) {
for (let listItem of list) {
let item = document.createElement("richlistitem");
item.setAttribute("name", list[i].name);
item.setAttribute("version", list[i].version);
item.setAttribute("icon", list[i].icon);
if (list[i].blocked) {
item.setAttribute("name", listItem.name);
item.setAttribute("version", listItem.version);
item.setAttribute("icon", listItem.icon);
if (listItem.blocked) {
item.setAttribute("class", "hardBlockedAddon");
hasHardBlocks = true;
}

View File

@ -311,9 +311,9 @@ var gEventManager = {
var menuSep = document.getElementById("addonitem-menuseparator");
var countEnabledMenuCmds = 0;
for (var i = 0; i < contextMenu.children.length; i++) {
if (contextMenu.children[i].nodeName == "menuitem" &&
gViewController.isCommandEnabled(contextMenu.children[i].command)) {
for (let child of contextMenu.children) {
if (child.nodeName == "menuitem" &&
gViewController.isCommandEnabled(child.command)) {
countEnabledMenuCmds++;
}
}
@ -366,8 +366,7 @@ var gEventManager = {
return;
var listeners = this._listeners[addon.id];
for (let i = 0; i < listeners.length; i++) {
let listener = listeners[i];
for (let listener of listeners) {
if (!(aEvent in listener))
continue;
try {
@ -386,8 +385,7 @@ var gEventManager = {
if (existingAddon)
this.delegateAddonEvent(aEvent, [existingAddon].concat(aParams));
for (let i = 0; i < this._installListeners.length; i++) {
let listener = this._installListeners[i];
for (let listener of this._installListeners) {
if (!(aEvent in listener))
continue;
try {
@ -2158,8 +2156,8 @@ var gSearchView = {
if (!this.isSearching) {
var isEmpty = true;
var results = this._listBox.getElementsByTagName("richlistitem");
for (let i = 0; i < results.length; i++) {
var isRemote = (results[i].getAttribute("remote") == "true");
for (let result of results) {
var isRemote = (result.getAttribute("remote") == "true");
if ((isRemote && !showLocal) || (!isRemote && showLocal)) {
isEmpty = false;
break;
@ -2196,13 +2194,13 @@ var gSearchView = {
var haystack = aStr.split(/\s+/);
var needles = aQuery.split(/\s+/);
for (let n = 0; n < needles.length; n++) {
for (let h = 0; h < haystack.length; h++) {
if (haystack[h] == needles[n]) {
for (let needle of needles) {
for (let hay of haystack) {
if (hay == needle) {
// matching whole words is best
score += SEARCH_SCORE_MATCH_WHOLEWORD;
} else {
let i = haystack[h].indexOf(needles[n]);
let i = hay.indexOf(needle);
if (i == 0) // matching on word boundries is also good
score += SEARCH_SCORE_MATCH_WORDBOUNDRY;
else if (i > 0) // substring matches not so good
@ -2286,8 +2284,7 @@ var gSearchView = {
},
removeInstall: function(aInstall) {
for (let i = 0; i < this._listBox.childNodes.length; i++) {
let item = this._listBox.childNodes[i];
for (let item of this._listBox.childNodes) {
if (item.mInstall == aInstall) {
this._listBox.removeChild(item);
return;
@ -2353,11 +2350,11 @@ var gListView = {
var elements = [];
for (let i = 0; i < aAddonsList.length; i++)
elements.push(createItem(aAddonsList[i]));
for (let addonItem of aAddonsList)
elements.push(createItem(addonItem));
for (let i = 0; i < aInstallsList.length; i++)
elements.push(createItem(aInstallsList[i], true));
for (let installItem of aInstallsList)
elements.push(createItem(installItem, true));
self.showEmptyNotice(elements.length == 0);
if (elements.length > 0) {
@ -2699,10 +2696,10 @@ var gDetailView = {
// Look for an add-on pending install
AddonManager.getAllInstalls(function(aInstalls) {
for (let i = 0; i < aInstalls.length; i++) {
if (aInstalls[i].state == AddonManager.STATE_INSTALLED &&
aInstalls[i].addon.id == aAddonId) {
self._updateView(aInstalls[i].addon, false);
for (let install of aInstalls) {
if (install.state == AddonManager.STATE_INSTALLED &&
install.addon.id == aAddonId) {
self._updateView(install.addon, false);
return;
}
}
@ -2853,8 +2850,7 @@ var gDetailView = {
var settings = xml.querySelectorAll(":root > setting");
var firstSetting = null;
for (var i = 0; i < settings.length; i++) {
var setting = settings[i];
for (let setting of settings) {
var desc = stripTextNodes(setting).trim();
if (!setting.hasAttribute("desc"))
@ -3143,8 +3139,7 @@ var gUpdatesView = {
},
maybeDisableUpdateSelected: function() {
for (let i = 0; i < this._listBox.childNodes.length; i++) {
let item = this._listBox.childNodes[i];
for (let item of this._listBox.childNodes) {
if (item.includeUpdate) {
this._updateSelected.disabled = false;
return;
@ -3154,8 +3149,7 @@ var gUpdatesView = {
},
installSelected: function() {
for (let i = 0; i < this._listBox.childNodes.length; i++) {
let item = this._listBox.childNodes[i];
for (let item of this._listBox.childNodes) {
if (item.includeUpdate)
item.upgrade();
}

View File

@ -1077,8 +1077,7 @@
// so try to detect that and return early
if (!("onNewInstall" in self))
return;
for (let i = 0; i < aInstallsList.length; i++) {
let install = aInstallsList[i];
for (let install of aInstallsList) {
if (install.existingAddon &&
install.existingAddon.id == self.mAddon.id &&
install.state == AddonManager.STATE_AVAILABLE) {

View File

@ -93,11 +93,11 @@ function init() {
document.getElementById("addonsTree").hidden = false;
// Fill the addons list
for (var i = 0; i < items.length; ++i) {
for (var item of items) {
var treeitem = document.createElementNS(kXULNS, "treeitem");
var treerow = document.createElementNS(kXULNS, "treerow");
var treecell = document.createElementNS(kXULNS, "treecell");
treecell.setAttribute("label", items[i]);
treecell.setAttribute("label", item);
treerow.appendChild(treecell);
treeitem.appendChild(treerow);
addons.appendChild(treeitem);
@ -105,11 +105,11 @@ function init() {
// Set the messages
var messages = ["message1", "message2", "message3"];
for (i = 0; i < messages.length; ++i) {
if (messages[i] in params) {
var message = document.getElementById(messages[i]);
for (let messageEntry of messages) {
if (messageEntry in params) {
var message = document.getElementById(messageEntry);
message.hidden = false;
message.appendChild(document.createTextNode(params[messages[i]]));
message.appendChild(document.createTextNode(params[messageEntry]));
}
}

View File

@ -347,8 +347,8 @@ var gFoundPage = {
var oneChecked = false;
var foundUpdates = document.getElementById("found.updates");
var updates = foundUpdates.getElementsByTagName("listitem");
for (var i = 0; i < updates.length; ++i) {
if (!updates[i].checked)
for (let update of updates) {
if (!update.checked)
continue;
oneChecked = true;
break;
@ -378,10 +378,10 @@ var gInstallingPage = {
var foundUpdates = document.getElementById("found.updates");
var updates = foundUpdates.getElementsByTagName("listitem");
for (var i = 0; i < updates.length; ++i) {
if (!updates[i].checked)
for (let update of updates) {
if (!update.checked)
continue;
this._installs.push(updates[i].install);
this._installs.push(update.install);
}
this._strings = document.getElementById("updateStrings");

View File

@ -379,9 +379,9 @@ Blocklist.prototype = {
if (!blItem)
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
for (var i = 0; i < blItem.length; ++i) {
if (blItem[i].includesItem(version, appVersion, toolkitVersion))
return blItem[i].severity >= gBlocklistLevel ? Ci.nsIBlocklistService.STATE_BLOCKED :
for (let currentblItem of blItem) {
if (currentblItem.includesItem(version, appVersion, toolkitVersion))
return currentblItem.severity >= gBlocklistLevel ? Ci.nsIBlocklistService.STATE_BLOCKED :
Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
}
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
@ -675,8 +675,7 @@ Blocklist.prototype = {
}
var childNodes = doc.documentElement.childNodes;
for (var i = 0; i < childNodes.length; ++i) {
var element = childNodes[i];
for (let element of childNodes) {
if (!(element instanceof Ci.nsIDOMElement))
continue;
switch (element.localName) {
@ -827,12 +826,12 @@ Blocklist.prototype = {
if (matchFailed)
continue;
for (var i = 0; i < blockEntry.versions.length; i++) {
if (blockEntry.versions[i].includesItem(plugin.version, appVersion,
for (let blockEntryVersion of blockEntry.versions) {
if (blockEntryVersion.includesItem(plugin.version, appVersion,
toolkitVersion)) {
if (blockEntry.versions[i].severity >= gBlocklistLevel)
if (blockEntryVersion.severity >= gBlocklistLevel)
return Ci.nsIBlocklistService.STATE_BLOCKED;
if (blockEntry.versions[i].severity == SEVERITY_OUTDATED)
if (blockEntryVersion.severity == SEVERITY_OUTDATED)
return Ci.nsIBlocklistService.STATE_OUTDATED;
return Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
}
@ -876,14 +875,14 @@ Blocklist.prototype = {
var self = this;
AddonManager.getAddonsByTypes(["extension", "theme", "locale", "dictionary"], function(addons) {
for (let i = 0; i < addons.length; i++) {
for (let addon of addons) {
let oldState = Ci.nsIBlocklistService.STATE_NOTBLOCKED;
if (oldAddonEntries)
oldState = self._getAddonBlocklistState(addons[i].id, addons[i].version,
oldState = self._getAddonBlocklistState(addon.id, addon.version,
oldAddonEntries);
let state = self.getAddonBlocklistState(addons[i].id, addons[i].version);
let state = self.getAddonBlocklistState(addon.id, addon.version);
LOG("Blocklist state for " + addons[i].id + " changed from " +
LOG("Blocklist state for " + addon.id + " changed from " +
oldState + " to " + state);
// We don't want to re-warn about add-ons
@ -892,7 +891,7 @@ Blocklist.prototype = {
// Ensure that softDisabled is false if the add-on is not soft blocked
if (state != Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
addons[i].softDisabled = false;
addon.softDisabled = false;
// Don't warn about add-ons becoming unblocked.
if (state == Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
@ -902,23 +901,23 @@ Blocklist.prototype = {
// soft disabled and don't warn about it.
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED &&
oldState == Ci.nsIBlocklistService.STATE_BLOCKED) {
addons[i].softDisabled = true;
addon.softDisabled = true;
continue;
}
// If the add-on is already disabled for some reason then don't warn
// about it
if (!addons[i].isActive)
if (!addon.isActive)
continue;
addonList.push({
name: addons[i].name,
version: addons[i].version,
icon: addons[i].iconURL,
name: addon.name,
version: addon.version,
icon: addon.iconURL,
disable: false,
blocked: state == Ci.nsIBlocklistService.STATE_BLOCKED,
item: addons[i],
url: self.getAddonBlocklistURL(addons[i].id),
item: addon,
url: self.getAddonBlocklistURL(addon.id),
});
}
@ -928,38 +927,38 @@ Blocklist.prototype = {
getService(Ci.nsIPluginHost);
var plugins = phs.getPluginTags();
for (let i = 0; i < plugins.length; i++) {
for (let plugin of plugins) {
let oldState = -1;
if (oldPluginEntries)
oldState = self._getPluginBlocklistState(plugins[i], oldPluginEntries);
let state = self.getPluginBlocklistState(plugins[i]);
LOG("Blocklist state for " + plugins[i].name + " changed from " +
oldState = self._getPluginBlocklistState(plugin, oldPluginEntries);
let state = self.getPluginBlocklistState(plugin);
LOG("Blocklist state for " + plugin.name + " changed from " +
oldState + " to " + state);
// We don't want to re-warn about items
if (state == oldState)
continue;
if (plugins[i].blocklisted) {
if (plugin.blocklisted) {
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
plugins[i].disabled = true;
plugin.disabled = true;
}
else if (!plugins[i].disabled && state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED) {
else if (!plugin.disabled && state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED) {
if (state == Ci.nsIBlocklistService.STATE_OUTDATED) {
gPref.setBoolPref(PREF_PLUGINS_NOTIFYUSER, true);
}
else {
addonList.push({
name: plugins[i].name,
version: plugins[i].version,
name: plugin.name,
version: plugin.version,
icon: "chrome://mozapps/skin/plugins/pluginGeneric.png",
disable: false,
blocked: state == Ci.nsIBlocklistService.STATE_BLOCKED,
item: plugins[i],
url: self.getPluginBlocklistURL(plugins[i]),
item: plugin,
url: self.getPluginBlocklistURL(plugin),
});
}
}
plugins[i].blocklisted = state == Ci.nsIBlocklistService.STATE_BLOCKED;
plugin.blocklisted = state == Ci.nsIBlocklistService.STATE_BLOCKED;
}
if (addonList.length == 0) {
@ -991,14 +990,14 @@ Blocklist.prototype = {
that can be sent programatically
*/
let applyBlocklistChanges = function() {
for (let i = 0; i < addonList.length; i++) {
if (!addonList[i].disable)
for (let addon of addonList) {
if (!addon.disable)
continue;
if (addonList[i].item instanceof Ci.nsIPluginTag)
addonList[i].item.disabled = true;
if (addon.item instanceof Ci.nsIPluginTag)
addon.item.disabled = true;
else
addonList[i].item.softDisabled = true;
addon.item.softDisabled = true;
}
if (args.restart)
@ -1127,8 +1126,8 @@ BlocklistItemData.prototype = {
if (!blTargetApp)
return false;
for (var x = 0; x < blTargetApp.length; ++x) {
if (this.matchesRange(appVersion, blTargetApp[x].minVersion, blTargetApp[x].maxVersion))
for (let app of blTargetApp) {
if (this.matchesRange(appVersion, app.minVersion, app.maxVersion))
return true;
}

View File

@ -45,8 +45,7 @@ function test() {
function test_about_window(aAddonItemName, aExpectedAboutUri, aCallback) {
var addonList = gManagerWindow.document.getElementById("addon-list");
for (var i = 0; i < addonList.childNodes.length; i++) {
var addonItem = addonList.childNodes[i];
for (var addonItem of addonList.childNodes) {
if (addonItem.hasAttribute("name") &&
addonItem.getAttribute("name") === aAddonItemName)
break;

View File

@ -28,8 +28,7 @@ function test() {
open_manager("addons://list/extension", function(aManager) {
var addonList = aManager.document.getElementById("addon-list");
for (var i = 0; i < addonList.childNodes.length; i++) {
var addonItem = addonList.childNodes[i];
for (var addonItem of addonList.childNodes) {
if (addonItem.hasAttribute("name") &&
addonItem.getAttribute("name") == "Test add-on 1")
break;
@ -39,8 +38,7 @@ function test() {
"preferences-btn");
is(prefsBtn.hidden, true, "Prefs button should be hidden for addon with no optionsURL set")
for (i = 0; i < addonList.childNodes.length; i++) {
addonItem = addonList.childNodes[i];
for (addonItem of addonList.childNodes) {
if (addonItem.hasAttribute("name") &&
addonItem.getAttribute("name") == "Test add-on 2")
break;

View File

@ -35,8 +35,7 @@ function test() {
open_manager("addons://list/extension", function(aWindow) {
let addonList = aWindow.document.getElementById("addon-list");
let ed_r_Item, un_r_Item, no_r_Item;
for (let i = 0; i < addonList.childNodes.length; i++) {
let addonItem = addonList.childNodes[i];
for (let addonItem of addonList.childNodes) {
let name = addonItem.getAttribute("name");
switch (name) {
case "restart-enable-disable":

View File

@ -27,8 +27,7 @@ function test() {
function end_test() {
close_manager(gManagerWindow, function() {
AddonManager.getAllInstalls(function(aInstallsList) {
for (var i = 0; i < aInstallsList.length; i++) {
var install = aInstallsList[i];
for (var install of aInstallsList) {
var sourceURI = install.sourceURI.spec;
if (sourceURI.match(/^http:\/\/example\.com\/(.+)\.xpi$/) != null)
install.cancel();
@ -61,8 +60,7 @@ function get_addon_item(aName) {
var id = aName + "@tests.mozilla.org";
var list = gManagerWindow.document.getElementById("search-list");
var rows = list.getElementsByTagName("richlistitem");
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
for (let row of rows) {
if (row.mAddon && row.mAddon.id == id)
return row;
}

View File

@ -102,8 +102,7 @@ function get_addon_item(aName) {
var id = aName + "@tests.mozilla.org";
var list = gManagerWindow.document.getElementById("search-list");
var rows = list.getElementsByTagName("richlistitem");
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
for (let row of rows) {
if (row.mAddon && row.mAddon.id == id)
return row;
}

View File

@ -97,8 +97,7 @@ function test() {
let instantApply = Services.prefs.getBoolPref("browser.preferences.instantApply");
function getAddonByName(aName) {
for (let i = 0; i < addonList.childNodes.length; i++) {
let addonItem = addonList.childNodes[i];
for (let addonItem of addonList.childNodes) {
if (addonItem.hasAttribute("name") &&
addonItem.getAttribute("name") == aName)
return addonItem;

View File

@ -75,8 +75,7 @@ add_test(function() {
function check_order(expected) {
var items = updatesList.getElementsByTagName("richlistitem");
var possible = ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org", "addon3@tests.mozilla.org"];
for (let i = 0; i < items.length; i++) {
let item = items[i];
for (let item of items) {
let itemId = item.mAddon.id;
if (possible.indexOf(itemId) == -1)
continue; // skip over any other addons, such as shipped addons that would update on every build

View File

@ -92,8 +92,7 @@ function end_test() {
installedAddon.uninstall();
AddonManager.getAllInstalls(function(aInstallsList) {
for (var i = 0; i < aInstallsList.length; i++) {
var install = aInstallsList[i];
for (var install of aInstallsList) {
var sourceURI = install.sourceURI.spec;
if (sourceURI == REMOTE_INSTALL_URL ||
sourceURI.match(/^http:\/\/example\.com\/(.+)\.xpi$/) != null)
@ -177,8 +176,7 @@ function get_actual_results() {
var rows = list.getElementsByTagName("richlistitem");
var results = [];
for (var i = 0; i < rows.length; i++) {
var item = rows[i];
for (var item of rows) {
// Only consider items that are currently showing
var style = gManagerWindow.document.defaultView.getComputedStyle(item, "");
@ -380,8 +378,7 @@ function get_addon_item(aName) {
var id = aName + "@tests.mozilla.org";
var list = gManagerWindow.document.getElementById("search-list");
var rows = list.getElementsByTagName("richlistitem");
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
for (var row of rows) {
if (row.mAddon && row.mAddon.id == id)
return row;
}
@ -400,8 +397,7 @@ function get_install_item(aName) {
var sourceURI = "http://example.com/" + aName + ".xpi";
var list = gManagerWindow.document.getElementById("search-list");
var rows = list.getElementsByTagName("richlistitem");
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
for (var row of rows) {
if (row.mInstall && row.mInstall.sourceURI.spec == sourceURI)
return row;
}
@ -441,8 +437,7 @@ add_test(function() {
var list = gManagerWindow.document.getElementById("search-list");
var results = get_actual_results();
for (var i = 0; i < results.length; i++) {
var result = results[i];
for (var result of results) {
var installBtn = get_install_button(result.item);
is(installBtn.hidden, result.name.indexOf("remote") != 0,
"Install button should only be showing for remote items");

View File

@ -218,17 +218,17 @@ function check_all_in_list(aManager, aIds, aIgnoreExtras) {
node = node.nextSibling;
}
for (var i = 0; i < aIds.length; i++) {
if (inlist.indexOf(aIds[i]) == -1)
ok(false, "Should find " + aIds[i] + " in the list");
for (let id of aIds) {
if (inlist.indexOf(id) == -1)
ok(false, "Should find " + id + " in the list");
}
if (aIgnoreExtras)
return;
for (i = 0; i < inlist.length; i++) {
if (aIds.indexOf(inlist[i]) == -1)
ok(false, "Shouldn't have seen " + inlist[i] + " in the list");
for (let inlistItem of inlist) {
if (aIds.indexOf(inlistItem) == -1)
ok(false, "Shouldn't have seen " + inlistItem + " in the list");
}
}
@ -756,9 +756,9 @@ MockProvider.prototype = {
* A callback to pass the Addon to
*/
getAddonByID: function MP_getAddon(aId, aCallback) {
for (let i = 0; i < this.addons.length; i++) {
if (this.addons[i].id == aId) {
this._delayCallback(aCallback, this.addons[i]);
for (let addon of this.addons) {
if (addon.id == aId) {
this._delayCallback(aCallback, addon);
return;
}
}

View File

@ -149,8 +149,8 @@ var InstallLocation = {
getItemFile: function(id, filePath) {
var itemLocation = this.getItemLocation(id).clone();
var parts = filePath.split("/");
for (var i = 0; i < parts.length; ++i)
itemLocation.append(parts[i]);
for (let part of parts)
itemLocation.append(part);
return itemLocation;
},

View File

@ -11,10 +11,10 @@ const checkListener = {
pendingCount: 0,
onUpdateAvailable: function onUpdateAvailable(aAddon, aInstall) {
for (var i = 0; i < ADDONS.length; i++) {
if (ADDONS[i].id == aAddon.id) {
ADDONS[i].newInstall = aInstall;
return;
for (let currentAddon of ADDONS) {
if (currentAddon.id == aAddon.id) {
currentAddon.newInstall = aInstall;
return;
}
}
},

View File

@ -145,22 +145,22 @@ function run_test() {
AddonManager.getAddonsByTypes(["extension"], function(installedItems) {
var items = [];
for (let k = 0; k < ADDONS.length; k++) {
for (let i = 0; i < installedItems.length; i++) {
if (ADDONS[k].id != installedItems[i].id)
for (let addon of ADDONS) {
for (let installedItem of installedItems) {
if (addon.id != installedItem.id)
continue;
if (installedItems[i].userDisabled)
if (installedItem.userDisabled)
continue;
if (ADDONS[k].shouldCheck == installedItems[i].isCompatibleWith("3", "3")) {
do_throw(installedItems[i].id + " had the wrong compatibility: " +
installedItems[i].isCompatibleWith("3", "3"));
if (addon.shouldCheck == installedItem.isCompatibleWith("3", "3")) {
do_throw(installedItem.id + " had the wrong compatibility: " +
installedItem.isCompatibleWith("3", "3"));
}
if (ADDONS[k].shouldCheck) {
gItemsNotChecked.push(ADDONS[k].id);
if (addon.shouldCheck) {
gItemsNotChecked.push(addon.id);
updateListener.pendingCount++;
installedItems[i].findUpdates(updateListener,
installedItem.findUpdates(updateListener,
AddonManager.UPDATE_WHEN_USER_REQUESTED,
"3", "3");
}

View File

@ -400,8 +400,8 @@ var WindowWatcher = {
gNewBlocks = [];
var list = args.list;
for (var i = 0; i < list.length; i++)
gNewBlocks.push(list[i].name + " " + list[i].version);
for (let listItem of list)
gNewBlocks.push(listItem.name + " " + listItem.version);
// Call the callback after the blocklist has finished up
do_timeout(0, gCallback);
@ -515,8 +515,8 @@ function run_test() {
dump("Setting up tests\n");
// Rather than keeping lots of identical add-ons in version control, just
// write them into the profile.
for (var i = 0; i < ADDONS.length; i++)
create_addon(ADDONS[i]);
for (let addon of ADDONS)
create_addon(addon);
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
startupManager();

View File

@ -232,8 +232,8 @@ function run_test() {
dump("Setting up tests\n");
// Rather than keeping lots of identical add-ons in version control, just
// write them into the profile.
for (var i = 0; i < ADDONS.length; i++)
create_addon(ADDONS[i]);
for (let addon of ADDONS)
create_addon(addon);
// Copy the initial blocklist into the profile to check add-ons start in the
// right state.
@ -319,8 +319,7 @@ function check_notification_pt2(args) {
dump("Checking notification pt 2\n");
do_check_eq(args.list.length, 4);
for (let i = 0; i < args.list.length; i++) {
let addon = args.list[i];
for (let addon of args.list) {
if (addon.item instanceof Ci.nsIPluginTag) {
switch (addon.item.name) {
case "test_bug455906_2":
@ -399,8 +398,7 @@ function check_notification_pt3(args) {
dump("Checking notification pt 3\n");
do_check_eq(args.list.length, 6);
for (let i = 0; i < args.list.length; i++) {
let addon = args.list[i];
for (let addon of args.list) {
if (addon.item instanceof Ci.nsIPluginTag) {
switch (addon.item.name) {
case "test_bug455906_2":

View File

@ -11,9 +11,9 @@ const nsIBLS = Ci.nsIBlocklistService;
function get_test_plugintag() {
var host = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var tags = host.getPluginTags();
for (var i = 0; i < tags.length; i++) {
if (tags[i].name == "Test Plug-in")
return tags[i];
for (let tag of tags) {
if (tag.name == "Test Plug-in")
return tag;
}
return null;
}

View File

@ -22,9 +22,9 @@ function test() {
}
function get_item(items, url) {
for (let i = 0; i < items.length; i++) {
if (items[i].url == url)
return items[i];
for (let item of items) {
if (item.url == url)
return item;
}
ok(false, "Item for " + url + " was not listed");
return null;

View File

@ -11,9 +11,9 @@ function test() {
}
function get_item(items, name) {
for (let i = 0; i < items.length; i++) {
if (items[i].name == name)
return items[i];
for (let item of items) {
if (item.name == name)
return item;
}
ok(false, "Item for " + name + " was not listed");
return null;

View File

@ -22,9 +22,9 @@ function test() {
}
function get_item(items, url) {
for (let i = 0; i < items.length; i++) {
if (items[i].url == url)
return items[i];
for (let item of items) {
if (item.url == url)
return item;
}
ok(false, "Item for " + url + " was not listed");
return null;

View File

@ -21,9 +21,9 @@ function test() {
}
function get_item(items, url) {
for (let i = 0; i < items.length; i++) {
if (items[i].url == url)
return items[i];
for (let item of items) {
if (item.url == url)
return item;
}
ok(false, "Item for " + url + " was not listed");
return null;