diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 903f04cc79cd..61096e45f502 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -554,14 +554,14 @@ var gPopupBlockerObserver = { blockedPopupAllowSite.removeAttribute("disabled"); var foundUsablePopupURI = false; - var pageReports = gBrowser.pageReport; - if (pageReports) { - for (let pageReport of pageReports) { + var pageReport = gBrowser.pageReport; + if (pageReport) { + for (var i = 0; i < pageReport.length; ++i) { // popupWindowURI will be null if the file picker popup is blocked. // xxxdz this should make the option say "Show file picker" and do it (Bug 590306) - if (!pageReport.popupWindowURI) + if (!pageReport[i].popupWindowURI) continue; - var popupURIspec = pageReport.popupWindowURI.spec; + var popupURIspec = pageReport[i].popupWindowURI.spec; // Sometimes the popup URI that we get back from the pageReport // isn't useful (for instance, netscape.com's popup URI ends up @@ -584,11 +584,11 @@ var gPopupBlockerObserver = { [popupURIspec]); menuitem.setAttribute("label", label); menuitem.setAttribute("popupWindowURI", popupURIspec); - menuitem.setAttribute("popupWindowFeatures", pageReport.popupWindowFeatures); - menuitem.setAttribute("popupWindowName", pageReport.popupWindowName); + menuitem.setAttribute("popupWindowFeatures", pageReport[i].popupWindowFeatures); + menuitem.setAttribute("popupWindowName", pageReport[i].popupWindowName); menuitem.setAttribute("oncommand", "gPopupBlockerObserver.showBlockedPopup(event);"); - menuitem.requestingWindow = pageReport.requestingWindow; - menuitem.requestingDocument = pageReport.requestingDocument; + menuitem.requestingWindow = pageReport[i].requestingWindow; + menuitem.requestingDocument = pageReport[i].requestingDocument; aEvent.target.appendChild(menuitem); } } @@ -692,7 +692,8 @@ const gXPInstallObserver = { _getBrowser: function (aDocShell) { - for (let browser of gBrowser.browsers) { + for (var i = 0; i < gBrowser.browsers.length; ++i) { + var browser = gBrowser.getBrowserAtIndex(i); if (this._findChildShell(browser.docShell, aDocShell)) return browser; } @@ -783,23 +784,23 @@ const gXPInstallObserver = { break; case "addon-install-failed": // TODO This isn't terribly ideal for the multiple failure case - for (let install of installInfo.installs) { - let host = (installInfo.originatingURI instanceof Ci.nsIStandardURL) && + installInfo.installs.forEach(function(aInstall) { + var host = (installInfo.originatingURI instanceof Ci.nsIStandardURL) && installInfo.originatingURI.host; if (!host) - host = (install.sourceURI instanceof Ci.nsIStandardURL) && - install.sourceURI.host; + host = (aInstall.sourceURI instanceof Ci.nsIStandardURL) && + aInstall.sourceURI.host; - let error = (host || install.error == 0) ? "addonError" : "addonLocalError"; - if (install.error != 0) - error += install.error; - else if (install.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) + var error = (host || aInstall.error == 0) ? "addonError" : "addonLocalError"; + if (aInstall.error != 0) + error += aInstall.error; + else if (aInstall.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) error += "Blocklisted"; else error += "Incompatible"; messageString = gNavigatorBundle.getString(error); - messageString = messageString.replace("#1", install.name); + messageString = messageString.replace("#1", aInstall.name); if (host) messageString = messageString.replace("#2", host); messageString = messageString.replace("#3", brandShortName); @@ -807,7 +808,7 @@ const gXPInstallObserver = { PopupNotifications.show(browser, notificationID, messageString, anchorID, action, null, options); - } + }); break; case "addon-install-complete": var needsRestart = installInfo.installs.some(function(i) { @@ -834,14 +835,14 @@ const gXPInstallObserver = { // installs var types = {}; var bestType = null; - for (let install of installInfo.installs) { - if (install.type in types) - types[install.type]++; + installInfo.installs.forEach(function(aInstall) { + if (aInstall.type in types) + types[aInstall.type]++; else - types[install.type] = 1; - if (!bestType || types[install.type] > types[bestType]) - bestType = install.type; - } + types[aInstall.type] = 1; + if (!bestType || types[aInstall.type] > types[bestType]) + bestType = aInstall.type; + }); BrowserOpenAddonsMgr("addons://list/" + bestType); } @@ -1137,7 +1138,7 @@ let gGestureSupport = { }); // Try each combination of key presses in decreasing order for commands - for (let subCombo of this._power(keyCombos)) { + for each (let subCombo in this._power(keyCombos)) { // Convert a gesture and pressed keys into the corresponding command // action where the preference has the gesture before "shift" before // "alt" before "ctrl" before "meta" all separated by periods @@ -1888,8 +1889,8 @@ function nonBrowserWindowStartup() { 'View:PageInfo', 'Tasks:InspectPage', 'Browser:ToggleTabView', 'Browser:ToggleAddonBar']; var element; - for (let disabledItem of disabledItems) { - element = document.getElementById(disabledItem); + for (var id in disabledItems) { + element = document.getElementById(disabledItems[id]); if (element) element.setAttribute("disabled", "true"); } @@ -1898,8 +1899,8 @@ function nonBrowserWindowStartup() { // and zoom menu commands as well if (window.location.href == "chrome://browser/content/hiddenWindow.xul") { var hiddenWindowDisabledItems = ['cmd_close', 'minimizeWindow', 'zoomWindow']; - for (let hiddenWindowDisabledItem of hiddenWindowDisabledItems) { - element = document.getElementById(hiddenWindowDisabledItem); + for (var id in hiddenWindowDisabledItems) { + element = document.getElementById(hiddenWindowDisabledItems[id]); if (element) element.setAttribute("disabled", "true"); } @@ -1992,7 +1993,7 @@ function initializeSanitizer() if (doMigrate) { let cpdBranch = gPrefService.getBranch("privacy.cpd."); let clearOnShutdownBranch = gPrefService.getBranch("privacy.clearOnShutdown."); - for (let name of itemArray) { + itemArray.forEach(function (name) { try { // don't migrate password or offlineApps clearing in the CRH dialog since // there's no UI for those anymore. They default to false. bug 497656 @@ -2003,7 +2004,7 @@ function initializeSanitizer() catch(e) { Cu.reportError("Exception thrown during privacy pref migration: " + e); } - } + }); } gPrefService.setBoolPref("privacy.sanitize.migrateFx3Prefs", true); @@ -3096,7 +3097,9 @@ function FillInHTMLTooltip(tipElement) lookingForSVGTitle = false; } if (lookingForSVGTitle) { - for (let childNode of tipElement.childNodes) { + let length = tipElement.childNodes.length; + for (let i = 0; i < length; i++) { + let childNode = tipElement.childNodes[i]; if (childNode instanceof SVGTitleElement) { SVGTitleText = childNode.textContent; break; @@ -3294,9 +3297,10 @@ const DOMLinkHandler = { var feedAdded = false; var iconAdded = false; var searchAdded = false; + var relStrings = rel.split(/\s+/); var rels = {}; - for (let relString of rel.split(/\s+/)) - rels[relString] = true; + for (let i = 0; i < relStrings.length; i++) + rels[relStrings[i]] = true; for (let relVal in rels) { switch (relVal) { @@ -3689,8 +3693,8 @@ function BrowserCustomizeToolbar() { // Disable the toolbar context menu items var menubar = document.getElementById("main-menubar"); - for (let childNode of menubar.childNodes) - childNode.setAttribute("disabled", true); + for (var i = 0; i < menubar.childNodes.length; ++i) + menubar.childNodes[i].setAttribute("disabled", true); var cmd = document.getElementById("cmd_CustomizeToolbars"); cmd.setAttribute("disabled", "true"); @@ -3787,8 +3791,8 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) { // Re-enable parts of the UI we disabled during the dialog var menubar = document.getElementById("main-menubar"); - for (let childNode of menubar.childNodes) - childNode.setAttribute("disabled", false); + for (var i = 0; i < menubar.childNodes.length; ++i) + menubar.childNodes[i].setAttribute("disabled", false); var cmd = document.getElementById("cmd_CustomizeToolbars"); cmd.removeAttribute("disabled"); @@ -4337,37 +4341,39 @@ var FullScreen = { { var els = document.getElementsByTagNameNS(this._XULNS, aTag); - for (let el of els) { + for (var i = 0; i < els.length; ++i) { // XXX don't interfere with previously collapsed toolbars - if (el.getAttribute("fullscreentoolbar") == "true") { + if (els[i].getAttribute("fullscreentoolbar") == "true") { if (!aShow) { - var toolbarMode = el.getAttribute("mode"); + var toolbarMode = els[i].getAttribute("mode"); if (toolbarMode != "text") { - el.setAttribute("saved-mode", toolbarMode); - el.setAttribute("saved-iconsize", el.getAttribute("iconsize")); - el.setAttribute("mode", "icons"); - el.setAttribute("iconsize", "small"); + els[i].setAttribute("saved-mode", toolbarMode); + els[i].setAttribute("saved-iconsize", + els[i].getAttribute("iconsize")); + els[i].setAttribute("mode", "icons"); + els[i].setAttribute("iconsize", "small"); } // Give the main nav bar and the tab bar the fullscreen context menu, // otherwise remove context menu to prevent breakage - el.setAttribute("saved-context", el.getAttribute("context")); - if (el.id == "nav-bar" || el.id == "TabsToolbar") - el.setAttribute("context", "autohide-context"); + els[i].setAttribute("saved-context", + els[i].getAttribute("context")); + if (els[i].id == "nav-bar" || els[i].id == "TabsToolbar") + els[i].setAttribute("context", "autohide-context"); else - el.removeAttribute("context"); + els[i].removeAttribute("context"); // Set the inFullscreen attribute to allow specific styling // in fullscreen mode - el.setAttribute("inFullscreen", true); + els[i].setAttribute("inFullscreen", true); } else { function restoreAttr(attrName) { var savedAttr = "saved-" + attrName; - if (el.hasAttribute(savedAttr)) { - el.setAttribute(attrName, el.getAttribute(savedAttr)); - el.removeAttribute(savedAttr); + if (els[i].hasAttribute(savedAttr)) { + els[i].setAttribute(attrName, els[i].getAttribute(savedAttr)); + els[i].removeAttribute(savedAttr); } } @@ -4375,15 +4381,15 @@ var FullScreen = { restoreAttr("iconsize"); restoreAttr("context"); - el.removeAttribute("inFullscreen"); + els[i].removeAttribute("inFullscreen"); } } else { // use moz-collapsed so it doesn't persist hidden/collapsed, // so that new windows don't have missing toolbars if (aShow) - el.removeAttribute("moz-collapsed"); + els[i].removeAttribute("moz-collapsed"); else - el.setAttribute("moz-collapsed", "true"); + els[i].setAttribute("moz-collapsed", "true"); } } @@ -4418,8 +4424,8 @@ var FullScreen = { } var controls = document.getElementsByAttribute("fullscreencontrol", "true"); - for (let control of controls) - control.hidden = aShow; + for (var i = 0; i < controls.length; ++i) + controls[i].hidden = aShow; } }; XPCOMUtils.defineLazyGetter(FullScreen, "useLionFullScreen", function() { @@ -4553,10 +4559,9 @@ var XULBrowserWindow = { if (this._busyUI) types.push("status"); types.push("jsStatus", "jsDefaultStatus", "defaultStatus"); - for (type of types) { + for (let i = 0; !text && i < types.length; i++) { + type = types[i]; text = this[type]; - if (text) - break; } // check the current value so we don't trigger an attribute change @@ -4819,12 +4824,12 @@ var XULBrowserWindow = { let findCommands = [document.getElementById("cmd_find"), document.getElementById("cmd_findAgain"), document.getElementById("cmd_findPrevious")]; - for (let elt of findCommands) { + findCommands.forEach(function (elt) { if (disableFind) elt.setAttribute("disabled", "true"); else elt.removeAttribute("disabled"); - } + }); if (gFindBarInitialized) { if (gFindBar.findMode != gFindBar.FIND_NORMAL) { @@ -5336,8 +5341,8 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) { let toolbarNodes = Array.slice(gNavToolbox.childNodes); toolbarNodes.push(document.getElementById("addon-bar")); - for (let toolbar of toolbarNodes) { - let toolbarName = toolbar.getAttribute("toolbarname"); + toolbarNodes.forEach(function(toolbar) { + var toolbarName = toolbar.getAttribute("toolbarname"); if (toolbarName) { let menuItem = document.createElement("menuitem"); let hidingAttribute = toolbar.getAttribute("type") == "menubar" ? @@ -5356,7 +5361,7 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) { menuItem.addEventListener("command", onViewToolbarCommand, false); } - } + }, this); } function onViewToolbarCommand(aEvent) { @@ -5630,14 +5635,14 @@ function toggleSidebar(commandID, forceOpen) { // ..but first update the 'checked' state of all sidebar broadcasters var broadcasters = document.getElementsByAttribute("group", "sidebar"); - for (let broadcaster of broadcasters) { + for (var i = 0; i < broadcasters.length; ++i) { // skip elements that observe sidebar broadcasters and random // other elements - if (broadcaster.localName != "broadcaster") + if (broadcasters[i].localName != "broadcaster") continue; - if (broadcaster != sidebarBroadcaster) - broadcaster.removeAttribute("checked"); + if (broadcasters[i] != sidebarBroadcaster) + broadcasters[i].removeAttribute("checked"); else sidebarBroadcaster.setAttribute("checked", "true"); } @@ -6167,7 +6172,9 @@ var gPageStyleMenu = { var haveAltSheets = false; var altStyleSelected = false; - for (let currentStyleSheet of styleSheets) { + for (let i = 0; i < styleSheets.length; ++i) { + let currentStyleSheet = styleSheets[i]; + if (!currentStyleSheet.title) continue; @@ -6376,9 +6383,9 @@ var OfflineApps = { // This depends on pseudo APIs of browser.js and tabbrowser.xml aContentWindow = aContentWindow.top; var browsers = aBrowserWindow.gBrowser.browsers; - for (let browser of browsers) { - if (browser.contentWindow == aContentWindow) - return browser; + for (var i = 0; i < browsers.length; ++i) { + if (browsers[i].contentWindow == aContentWindow) + return browsers[i]; } return null; }, @@ -6409,10 +6416,10 @@ var OfflineApps = { } var browsers = gBrowser.browsers; - for (let browser of browsers) { - uri = this._getManifestURI(browser.contentWindow); + for (var i = 0; i < browsers.length; ++i) { + uri = this._getManifestURI(browsers[i].contentWindow); if (uri && uri.equals(aCacheUpdate.manifestURI)) { - return browser; + return browsers[i]; } } @@ -6458,10 +6465,10 @@ var OfflineApps = { groups = cacheService.getGroups(); var usage = 0; - for (let group of groups) { - var uri = Services.io.newURI(group, null, null); + for (var i = 0; i < groups.length; i++) { + var uri = Services.io.newURI(groups[i], null, null); if (uri.asciiHost == host) { - var cache = cacheService.getActiveCache(group); + var cache = cacheService.getActiveCache(groups[i]); usage += cache.usage; } } @@ -6523,16 +6530,16 @@ var OfflineApps = { label: gNavigatorBundle.getString("offlineApps.allow"), accessKey: gNavigatorBundle.getString("offlineApps.allowAccessKey"), callback: function() { - for (let document of notification.documents) { - OfflineApps.allowSite(document); + for (var i = 0; i < notification.documents.length; i++) { + OfflineApps.allowSite(notification.documents[i]); } } },{ label: gNavigatorBundle.getString("offlineApps.never"), accessKey: gNavigatorBundle.getString("offlineApps.neverAccessKey"), callback: function() { - for (let document of notification.documents) { - OfflineApps.disallowSite(document); + for (var i = 0; i < notification.documents.length; i++) { + OfflineApps.disallowSite(notification.documents[i]); } } },{ @@ -6776,16 +6783,19 @@ function WindowIsClosing() return false; } - if (!closeWindow(false, warnAboutClosingWindow)) + var reallyClose = closeWindow(false, warnAboutClosingWindow); + if (!reallyClose) return false; - for (let browser of gBrowser.browsers) { - let ds = browser.docShell; + var numBrowsers = gBrowser.browsers.length; + for (let i = 0; reallyClose && i < numBrowsers; ++i) { + let ds = gBrowser.browsers[i].docShell; + if (ds.contentViewer && !ds.contentViewer.permitUnload()) - return false; + reallyClose = false; } - return true; + return reallyClose; } /** @@ -6924,6 +6934,7 @@ function AddKeywordForSearchField() { [node.ownerDocument.title]); var description = PlacesUIUtils.getDescriptionFromDocument(node.ownerDocument); + var el, type; var formData = []; function escapeNameValuePair(aName, aValue, aIsFormUrlEncoded) { @@ -6933,7 +6944,9 @@ function AddKeywordForSearchField() { return escape(aName) + "=" + escape(aValue); } - for (let el of node.form.elements) { + for (var i=0; i < node.form.elements.length; i++) { + el = node.form.elements[i]; + if (!el.type) // happens with fieldsets continue; @@ -6944,7 +6957,7 @@ function AddKeywordForSearchField() { continue; } - let type = el.type.toLowerCase(); + type = el.type.toLowerCase(); if (((el instanceof HTMLInputElement && el.mozIsTextField(true)) || type == "hidden" || type == "textarea") || @@ -7633,7 +7646,8 @@ var FeedHandler = { return false; // Build the menu showing the available feed choices for viewing. - for (let feedInfo of feeds) { + for (var i = 0; i < feeds.length; ++i) { + var feedInfo = feeds[i]; var menuItem = document.createElement("menuitem"); var baseTitle = feedInfo.title || feedInfo.href; var labelStr = gNavigatorBundle.getFormattedString("feedShowFeedNew", [baseTitle]); @@ -8856,7 +8870,9 @@ var LightWeightThemeWebInstaller = { function switchToTabHavingURI(aURI, aOpenNew) { // This will switch to the tab in aWindow having aURI, if present. function switchIfURIInWindow(aWindow) { - for (let browser of aWindow.gBrowser.browsers) { + let browsers = aWindow.gBrowser.browsers; + for (let i = 0; i < browsers.length; i++) { + let browser = browsers[i]; if (browser.currentURI.equals(aURI)) { // Focus the matching window & tab aWindow.focus(); @@ -8917,13 +8933,13 @@ var TabContextMenu = { disabled && gBrowser.tabContainer._closeWindowWithLastTab; var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple"); - for (let menuItem of menuItems) - menuItem.disabled = disabled; + for (var i = 0; i < menuItems.length; i++) + menuItems[i].disabled = disabled; disabled = gBrowser.visibleTabs.length == 1; menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple-visible"); - for (let menuItem of menuItems) - menuItem.disabled = disabled; + for (var i = 0; i < menuItems.length; i++) + menuItems[i].disabled = disabled; // Session store document.getElementById("context_undoCloseTab").disabled = @@ -9033,10 +9049,10 @@ let AddonsMgrListener = { var defaultOrNoninteractive = this.addonBar.getAttribute("defaultset") .split(",") .concat(["separator", "spacer", "spring"]); - for (let item of this.addonBar.currentSet.split(",")) { + this.addonBar.currentSet.split(",").forEach(function (item) { if (defaultOrNoninteractive.indexOf(item) == -1) itemCount++; - } + }); return itemCount; },