зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1484496: Part 5a - Convert browser/ nsISimpleEnumerator users to use JS iteration. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D3729 --HG-- extra : rebase_source : e187b8e9a6b6db7ebc762adda5e489b25c7a7e43 extra : histedit_source : 868cb99d09954a51d6be321fcb516475ef70eb33
This commit is contained in:
Родитель
2dee0aae3c
Коммит
80327d3561
|
@ -83,12 +83,9 @@ class NetErrorChild extends ActorChild {
|
|||
_getCertValidityRange(docShell) {
|
||||
let {securityInfo} = docShell.failedChannel;
|
||||
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||
let certs = securityInfo.failedCertChain.getEnumerator();
|
||||
let notBefore = 0;
|
||||
let notAfter = Number.MAX_SAFE_INTEGER;
|
||||
while (certs.hasMoreElements()) {
|
||||
let cert = certs.getNext();
|
||||
cert.QueryInterface(Ci.nsIX509Cert);
|
||||
for (let cert of securityInfo.failedCertChain.getEnumerator()) {
|
||||
notBefore = Math.max(notBefore, cert.validity.notBefore);
|
||||
notAfter = Math.min(notAfter, cert.validity.notAfter);
|
||||
}
|
||||
|
|
|
@ -336,10 +336,8 @@ function isInitialPage(url) {
|
|||
return gInitialPages.includes(url) || url == BROWSER_NEW_TAB_URL;
|
||||
}
|
||||
|
||||
function* browserWindows() {
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements())
|
||||
yield windows.getNext();
|
||||
function browserWindows() {
|
||||
return Services.wm.getEnumerator("navigator:browser");
|
||||
}
|
||||
|
||||
function UpdateBackForwardCommands(aWebNavigation) {
|
||||
|
@ -2636,13 +2634,11 @@ function BrowserPageInfo(documentURL, initialTab, imageElement, frameOuterWindow
|
|||
}
|
||||
|
||||
let args = { initialTab, imageElement, frameOuterWindowID, browser };
|
||||
var windows = Services.wm.getEnumerator("Browser:page-info");
|
||||
|
||||
documentURL = documentURL || window.gBrowser.selectedBrowser.currentURI.spec;
|
||||
|
||||
// Check for windows matching the url
|
||||
while (windows.hasMoreElements()) {
|
||||
var currentWindow = windows.getNext();
|
||||
for (let currentWindow of Services.wm.getEnumerator("Browser:page-info")) {
|
||||
if (currentWindow.closed) {
|
||||
continue;
|
||||
}
|
||||
|
@ -3309,10 +3305,7 @@ function getDetailedCertErrorInfo(location, securityInfo) {
|
|||
|
||||
let certChain = "";
|
||||
if (securityInfo.failedCertChain) {
|
||||
let certs = securityInfo.failedCertChain.getEnumerator();
|
||||
while (certs.hasMoreElements()) {
|
||||
let cert = certs.getNext();
|
||||
cert.QueryInterface(Ci.nsIX509Cert);
|
||||
for (let cert of securityInfo.failedCertChain.getEnumerator()) {
|
||||
certChain += getPEMString(cert);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -496,10 +496,7 @@ function getCertChain(securityInfoAsString) {
|
|||
.getService(Ci.nsISerializationHelper);
|
||||
let securityInfo = serhelper.deserializeObject(securityInfoAsString);
|
||||
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||
let certs = securityInfo.failedCertChain.getEnumerator();
|
||||
while (certs.hasMoreElements()) {
|
||||
let cert = certs.getNext();
|
||||
cert.QueryInterface(Ci.nsIX509Cert);
|
||||
for (let cert of securityInfo.failedCertChain.getEnumerator()) {
|
||||
certChain += getPEMString(cert);
|
||||
}
|
||||
return certChain;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
function test() {
|
||||
var contentWin = window.open("about:blank", "", "width=100,height=100");
|
||||
var enumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let win = enumerator.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (win.content == contentWin) {
|
||||
Services.prefs.setBoolPref("browser.tabs.closeWindowWithLastTab", false);
|
||||
win.gBrowser.removeCurrentTab();
|
||||
|
|
|
@ -65,9 +65,7 @@ function triggerSave(aWindow, aCallback) {
|
|||
}
|
||||
|
||||
function continueDownloading() {
|
||||
let windows = Services.wm.getEnumerator("");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("")) {
|
||||
if (win.location && win.location.href == UCT_URI) {
|
||||
win.document.documentElement._fireButtonEvent("accept");
|
||||
win.close();
|
||||
|
|
|
@ -533,24 +533,13 @@ async function loadBadCertPage(url) {
|
|||
// Utility function to get a handle on the certificate exception dialog.
|
||||
// Modified from toolkit/components/passwordmgr/test/prompt_common.js
|
||||
function getCertExceptionDialog(aLocation) {
|
||||
let enumerator = Services.wm.getXULWindowEnumerator(null);
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let win = enumerator.getNext();
|
||||
let windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell;
|
||||
|
||||
let containedDocShells = windowDocShell.getDocShellEnumerator(
|
||||
Ci.nsIDocShellTreeItem.typeChrome,
|
||||
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
||||
while (containedDocShells.hasMoreElements()) {
|
||||
// Get the corresponding document for this docshell
|
||||
let childDocShell = containedDocShells.getNext();
|
||||
let childDoc = childDocShell.QueryInterface(Ci.nsIDocShell)
|
||||
.contentViewer
|
||||
.DOMDocument;
|
||||
|
||||
if (childDoc.location.href == aLocation) {
|
||||
return childDoc;
|
||||
for (let {docShell} of Services.wm.getXULWindowEnumerator(null)) {
|
||||
let containedDocShells = docShell.getDocShellEnumerator(
|
||||
docShell.typeChrome,
|
||||
docShell.ENUMERATE_FORWARDS);
|
||||
for (let {domWindow} of containedDocShells) {
|
||||
if (domWindow.location.href == aLocation) {
|
||||
return domWindow.document;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@ const PLUGIN_SMALL_PAGE = gTestRoot + "plugin_small.html";
|
|||
*/
|
||||
function convertPropertyBag(aBag) {
|
||||
let result = {};
|
||||
let enumerator = aBag.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let { name, value } = enumerator.getNext().QueryInterface(Ci.nsIProperty);
|
||||
for (let { name, value } of aBag.enumerator) {
|
||||
if (value instanceof Ci.nsIPropertyBag) {
|
||||
value = convertPropertyBag(value);
|
||||
}
|
||||
|
|
|
@ -294,24 +294,15 @@ async function loadBadCertPage(url) {
|
|||
// Utility function to get a handle on the certificate exception dialog.
|
||||
// Modified from toolkit/components/passwordmgr/test/prompt_common.js
|
||||
function getCertExceptionDialog(aLocation) {
|
||||
let enumerator = Services.wm.getXULWindowEnumerator(null);
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let win = enumerator.getNext();
|
||||
let windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell;
|
||||
for (let win of Services.wm.getXULWindowEnumerator(null)) {
|
||||
let windowDocShell = win.docShell;
|
||||
|
||||
let containedDocShells = windowDocShell.getDocShellEnumerator(
|
||||
Ci.nsIDocShellTreeItem.typeChrome,
|
||||
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
||||
while (containedDocShells.hasMoreElements()) {
|
||||
// Get the corresponding document for this docshell
|
||||
let childDocShell = containedDocShells.getNext();
|
||||
let childDoc = childDocShell.QueryInterface(Ci.nsIDocShell)
|
||||
.contentViewer
|
||||
.DOMDocument;
|
||||
|
||||
if (childDoc.location.href == aLocation) {
|
||||
return childDoc;
|
||||
for (let {domWindow} of containedDocShells) {
|
||||
if (domWindow.location.href == aLocation) {
|
||||
return domWindow.document;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,10 +219,8 @@ add_task(async function checkAllTheProperties() {
|
|||
|
||||
for (let uri of uris) {
|
||||
let bundle = Services.strings.createBundle(uri.spec);
|
||||
let enumerator = bundle.getSimpleEnumeration();
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let entity = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
|
||||
for (let entity of bundle.getSimpleEnumeration()) {
|
||||
testForErrors(uri.spec, entity.key, entity.value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,9 +54,7 @@ function promiseCrashReport(expectedExtra = {}) {
|
|||
}
|
||||
|
||||
info("Iterating crash report extra keys");
|
||||
let enumerator = extra.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let key = enumerator.getNext().QueryInterface(Ci.nsIProperty).name;
|
||||
for (let {name: key} of extra.enumerator) {
|
||||
let value = extra.getPropertyAsAString(key);
|
||||
if (key in expectedExtra) {
|
||||
if (expectedExtra[key] == null) {
|
||||
|
|
|
@ -139,9 +139,7 @@ function loadTab(tab, url) {
|
|||
function ensure_opentabs_match_db() {
|
||||
var tabs = {};
|
||||
|
||||
var winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let browserWin = winEnum.getNext();
|
||||
for (let browserWin of Services.wm.getEnumerator("navigator:browser")) {
|
||||
// skip closed-but-not-destroyed windows
|
||||
if (browserWin.closed)
|
||||
continue;
|
||||
|
|
|
@ -110,9 +110,7 @@ async function assertWebRTCIndicatorStatus(expected) {
|
|||
is(ui.showMicrophoneIndicator, expectAudio, "microphone global indicator as expected");
|
||||
is(ui.showScreenSharingIndicator, expectScreen, "screen global indicator as expected");
|
||||
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let menu = win.document.getElementById("tabSharingMenu");
|
||||
is(!!menu && !menu.hidden, !!expected, "WebRTC menu should be " + expectedState);
|
||||
}
|
||||
|
|
|
@ -790,10 +790,8 @@ function isBidiEnabled() {
|
|||
}
|
||||
|
||||
function openAboutDialog() {
|
||||
var enumerator = Services.wm.getEnumerator("Browser:About");
|
||||
while (enumerator.hasMoreElements()) {
|
||||
for (let win of Services.wm.getEnumerator("Browser:About")) {
|
||||
// Only open one about window (Bug 599573)
|
||||
let win = enumerator.getNext();
|
||||
if (win.closed) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -72,9 +72,7 @@ add_task(async function test_cookie_getCookiesWithOriginAttributes() {
|
|||
|
||||
// Using getCookiesWithOriginAttributes() to get all cookies for a certain
|
||||
// domain by using the originAttributes pattern, and clear all these cookies.
|
||||
let enumerator = Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), TEST_HOST);
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (let cookie of Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), TEST_HOST)) {
|
||||
Services.cookies.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,7 @@ function checkCookies(ignoreContext = null) {
|
|||
function deleteCookies(onlyContext = null) {
|
||||
// Using getCookiesWithOriginAttributes() to get all cookies for a certain
|
||||
// domain by using the originAttributes pattern, and clear all these cookies.
|
||||
let enumerator = Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), TEST_HOST);
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (let cookie of Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), TEST_HOST)) {
|
||||
if (!onlyContext || cookie.originAttributes.userContextId == onlyContext) {
|
||||
Services.cookies.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
|
||||
}
|
||||
|
|
|
@ -142,9 +142,7 @@ var DownloadsCommon = {
|
|||
get strings() {
|
||||
let strings = {};
|
||||
let sb = Services.strings.createBundle(kDownloadsStringBundleUrl);
|
||||
let enumerator = sb.getSimpleEnumeration();
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
|
||||
for (let string of sb.getSimpleEnumeration()) {
|
||||
let stringName = string.key;
|
||||
if (stringName in kDownloadsStringsRequiringFormatting) {
|
||||
strings[stringName] = function() {
|
||||
|
|
|
@ -26,9 +26,7 @@ add_task(async function setup() {
|
|||
|
||||
function retrieve_all_cookies(host) {
|
||||
const values = [];
|
||||
const cookies = Services.cookies.getCookiesFromHost(host, {});
|
||||
while (cookies.hasMoreElements()) {
|
||||
const cookie = cookies.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (let cookie of Services.cookies.getCookiesFromHost(host, {})) {
|
||||
values.push({
|
||||
host: cookie.host,
|
||||
name: cookie.name,
|
||||
|
|
|
@ -44,7 +44,7 @@ const clearCookies = async function(options) {
|
|||
|
||||
if (options.since || options.hostnames) {
|
||||
// Iterate through the cookies and delete any created after our cutoff.
|
||||
for (const cookie of XPCOMUtils.IterSimpleEnumerator(cookieMgr.enumerator, Ci.nsICookie2)) {
|
||||
for (const cookie of cookieMgr.enumerator) {
|
||||
if ((!options.since || cookie.creationTime >= PlacesUtils.toPRTime(options.since)) &&
|
||||
(!options.hostnames || options.hostnames.includes(cookie.host.replace(/^\./, "")))) {
|
||||
// This cookie was created after our cutoff, clear it.
|
||||
|
|
|
@ -13,8 +13,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "pkcs11db",
|
|||
var {DefaultMap} = ExtensionUtils;
|
||||
|
||||
const findModuleByPath = function(path) {
|
||||
let modules = pkcs11db.listModules();
|
||||
for (let module of XPCOMUtils.IterSimpleEnumerator(modules, Ci.nsIPKCS11Module)) {
|
||||
for (let module of pkcs11db.listModules()) {
|
||||
if (module && module.libName === path) {
|
||||
return module;
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ this.pkcs11 = class extends ExtensionAPI {
|
|||
return Promise.reject({message: `The module ${name} is not installed`});
|
||||
}
|
||||
let rv = [];
|
||||
for (let slot of XPCOMUtils.IterSimpleEnumerator(module.listSlots(), Ci.nsIPKCS11Slot)) {
|
||||
for (let slot of module.listSlots()) {
|
||||
let token = slot.getToken();
|
||||
let slotobj = {
|
||||
name: slot.name,
|
||||
|
|
|
@ -50,9 +50,7 @@ XPCOMUtils.defineLazyGetter(this, "tabHidePopup", () => {
|
|||
});
|
||||
|
||||
function showHiddenTabs(id) {
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let win = windowsEnum.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (win.closed || !win.gBrowser) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -508,9 +508,7 @@ function awaitEvent(eventName, id) {
|
|||
}
|
||||
|
||||
function* BrowserWindowIterator() {
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let currentWindow = windowsEnum.getNext();
|
||||
for (let currentWindow of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!currentWindow.closed) {
|
||||
yield currentWindow;
|
||||
}
|
||||
|
|
|
@ -276,9 +276,7 @@ const AutoMigrate = {
|
|||
},
|
||||
|
||||
_removeNotificationBars() {
|
||||
let browserWindows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserWindows.hasMoreElements()) {
|
||||
let win = browserWindows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!win.closed) {
|
||||
for (let browser of win.gBrowser.browsers) {
|
||||
let nb = win.gBrowser.getNotificationBox(browser);
|
||||
|
|
|
@ -37,12 +37,9 @@ FirefoxProfileMigrator.prototype = Object.create(MigratorPrototype);
|
|||
|
||||
FirefoxProfileMigrator.prototype._getAllProfiles = function() {
|
||||
let allProfiles = new Map();
|
||||
let profiles =
|
||||
Cc["@mozilla.org/toolkit/profile-service;1"]
|
||||
.getService(Ci.nsIToolkitProfileService)
|
||||
.profiles;
|
||||
while (profiles.hasMoreElements()) {
|
||||
let profile = profiles.getNext().QueryInterface(Ci.nsIToolkitProfile);
|
||||
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]
|
||||
.getService(Ci.nsIToolkitProfileService);
|
||||
for (let profile of profileService.profiles) {
|
||||
let rootDir = profile.rootDir;
|
||||
|
||||
if (rootDir.exists() && rootDir.isReadable() &&
|
||||
|
|
|
@ -38,10 +38,8 @@ History.prototype = {
|
|||
migrate: function H_migrate(aCallback) {
|
||||
let pageInfos = [];
|
||||
let typedURLs = MSMigrationUtils.getTypedURLs("Software\\Microsoft\\Internet Explorer");
|
||||
let historyEnumerator = Cc["@mozilla.org/profile/migrator/iehistoryenumerator;1"].
|
||||
createInstance(Ci.nsISimpleEnumerator);
|
||||
while (historyEnumerator.hasMoreElements()) {
|
||||
let entry = historyEnumerator.getNext().QueryInterface(Ci.nsIPropertyBag2);
|
||||
for (let entry of Cc["@mozilla.org/profile/migrator/iehistoryenumerator;1"]
|
||||
.createInstance(Ci.nsISimpleEnumerator)) {
|
||||
let url = entry.get("uri").QueryInterface(Ci.nsIURI);
|
||||
// MSIE stores some types of URLs in its history that we don't handle,
|
||||
// like HTMLHelp and others. Since we don't properly map handling for
|
||||
|
@ -115,11 +113,9 @@ IE7FormPasswords.prototype = {
|
|||
},
|
||||
|
||||
async migrate(aCallback) {
|
||||
let historyEnumerator = Cc["@mozilla.org/profile/migrator/iehistoryenumerator;1"].
|
||||
createInstance(Ci.nsISimpleEnumerator);
|
||||
let uris = []; // the uris of the websites that are going to be migrated
|
||||
while (historyEnumerator.hasMoreElements()) {
|
||||
let entry = historyEnumerator.getNext().QueryInterface(Ci.nsIPropertyBag2);
|
||||
for (let entry of Cc["@mozilla.org/profile/migrator/iehistoryenumerator;1"]
|
||||
.createInstance(Ci.nsISimpleEnumerator)) {
|
||||
let uri = entry.get("uri").QueryInterface(Ci.nsIURI);
|
||||
// MSIE stores some types of URLs in its history that we don't handle, like HTMLHelp
|
||||
// and others. Since we are not going to import the logins that are performed in these URLs
|
||||
|
|
|
@ -19,9 +19,7 @@ function readFile(file) {
|
|||
function checkDirectoryContains(dir, files) {
|
||||
print("checking " + dir.path + " - should contain " + Object.keys(files));
|
||||
let seen = new Set();
|
||||
let enumerator = dir.directoryEntries;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
|
||||
for (let file of dir.directoryEntries) {
|
||||
print("found file: " + file.path);
|
||||
Assert.ok(file.leafName in files, file.leafName + " exists, but shouldn't");
|
||||
|
||||
|
|
|
@ -36,9 +36,7 @@ this.ASRouterTriggerListeners = new Map([
|
|||
Services.ww.registerNotification(this);
|
||||
|
||||
// Add listeners to all existing browser windows
|
||||
const winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let win = winEnum.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (win.closed || PrivateBrowsingUtils.isWindowPrivate(win)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -59,9 +57,7 @@ this.ASRouterTriggerListeners = new Map([
|
|||
if (this._initialized) {
|
||||
Services.ww.unregisterNotification(this);
|
||||
|
||||
const winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let win = winEnum.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (win.closed || PrivateBrowsingUtils.isWindowPrivate(win)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -66,9 +66,8 @@ this.Screenshots = {
|
|||
* we are ok to collect screenshots.
|
||||
*/
|
||||
_shouldGetScreenshots() {
|
||||
const windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(windows.getNext())) {
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(win)) {
|
||||
// As soon as we encounter 1 non-private window, screenshots are fair game.
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -642,9 +642,8 @@ BrowserGlue.prototype = {
|
|||
// delays are in seconds
|
||||
const MAX_DELAY = 300;
|
||||
let delay = 3;
|
||||
let browserEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserEnum.hasMoreElements()) {
|
||||
delay += browserEnum.getNext().gBrowser.tabs.length;
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
delay += win.gBrowser.tabs.length;
|
||||
}
|
||||
delay = delay <= MAX_DELAY ? delay : MAX_DELAY;
|
||||
|
||||
|
|
|
@ -47,11 +47,9 @@ add_task(async function cookie_test() {
|
|||
let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty_cookie.html");
|
||||
await BrowserTestUtils.browserLoaded(tab.linkedBrowser, true);
|
||||
|
||||
let iter = Services.cookies.enumerator;
|
||||
let count = 0;
|
||||
while (iter.hasMoreElements()) {
|
||||
for (let cookie of Services.cookies.enumerator) {
|
||||
count++;
|
||||
let cookie = iter.getNext().QueryInterface(Ci.nsICookie2);
|
||||
Assert.equal(cookie.value, "foo", "Cookie value should be foo");
|
||||
Assert.equal(cookie.originAttributes.firstPartyDomain, BASE_DOMAIN, "Cookie's origin attributes should be " + BASE_DOMAIN);
|
||||
}
|
||||
|
|
|
@ -154,9 +154,7 @@ PaymentUIService.prototype = {
|
|||
},
|
||||
|
||||
findDialog(requestId) {
|
||||
let enu = Services.wm.getEnumerator(null);
|
||||
let win;
|
||||
while ((win = enu.getNext())) {
|
||||
for (let win of Services.wm.getEnumerator(null)) {
|
||||
if (win.name == `${this.REQUEST_ID_PREFIX}${requestId}`) {
|
||||
return win;
|
||||
}
|
||||
|
|
|
@ -24,12 +24,7 @@ const {PaymentTestUtils: PTU} = ChromeUtils.import(
|
|||
"resource://testing-common/PaymentTestUtils.jsm", {});
|
||||
|
||||
function getPaymentRequests() {
|
||||
let requestsEnum = paymentSrv.enumerate();
|
||||
let requests = [];
|
||||
while (requestsEnum.hasMoreElements()) {
|
||||
requests.push(requestsEnum.getNext().QueryInterface(Ci.nsIPaymentRequest));
|
||||
}
|
||||
return requests;
|
||||
return Array.from(paymentSrv.enumerate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,14 +30,10 @@ var gAppManagerDialog = {
|
|||
}
|
||||
|
||||
var list = document.getElementById("appList");
|
||||
var apps = this.handlerInfo.possibleApplicationHandlers.enumerate();
|
||||
while (apps.hasMoreElements()) {
|
||||
let app = apps.getNext();
|
||||
for (let app of this.handlerInfo.possibleApplicationHandlers.enumerate()) {
|
||||
if (!gMainPane.isValidHandlerApp(app))
|
||||
continue;
|
||||
|
||||
app.QueryInterface(Ci.nsIHandlerApp);
|
||||
|
||||
// Ensure the XBL binding is created eagerly.
|
||||
// eslint-disable-next-line no-undef
|
||||
list.appendChild(MozXULElement.parseXULToFragment("<richlistitem/>"));
|
||||
|
|
|
@ -1397,10 +1397,7 @@ var gMainPane = {
|
|||
* Load the set of handlers defined by the application datastore.
|
||||
*/
|
||||
_loadApplicationHandlers() {
|
||||
var wrappedHandlerInfos = gHandlerService.enumerate();
|
||||
while (wrappedHandlerInfos.hasMoreElements()) {
|
||||
let wrappedHandlerInfo =
|
||||
wrappedHandlerInfos.getNext().QueryInterface(Ci.nsIHandlerInfo);
|
||||
for (let wrappedHandlerInfo of gHandlerService.enumerate()) {
|
||||
let type = wrappedHandlerInfo.type;
|
||||
|
||||
let handlerInfoWrapper;
|
||||
|
@ -1661,10 +1658,8 @@ var gMainPane = {
|
|||
|
||||
// Create menu items for possible handlers.
|
||||
let preferredApp = handlerInfo.preferredApplicationHandler;
|
||||
let possibleApps = handlerInfo.possibleApplicationHandlers.enumerate();
|
||||
var possibleAppMenuItems = [];
|
||||
while (possibleApps.hasMoreElements()) {
|
||||
let possibleApp = possibleApps.getNext();
|
||||
for (let possibleApp of handlerInfo.possibleApplicationHandlers.enumerate()) {
|
||||
if (!this.isValidHandlerApp(possibleApp))
|
||||
continue;
|
||||
|
||||
|
@ -1692,10 +1687,8 @@ var gMainPane = {
|
|||
let gIOSvc = Cc["@mozilla.org/gio-service;1"].
|
||||
getService(Ci.nsIGIOService);
|
||||
var gioApps = gIOSvc.getAppsForURIScheme(handlerInfo.type);
|
||||
let enumerator = gioApps.enumerate();
|
||||
let possibleHandlers = handlerInfo.possibleApplicationHandlers;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let handler = enumerator.getNext().QueryInterface(Ci.nsIHandlerApp);
|
||||
for (let handler of gioApps.enumerate()) {
|
||||
// OS handler share the same name, it's most likely the same app, skipping...
|
||||
if (handler.name == handlerInfo.defaultDescription) {
|
||||
continue;
|
||||
|
@ -2400,6 +2393,10 @@ function ArrayEnumerator(aItems) {
|
|||
ArrayEnumerator.prototype = {
|
||||
_index: 0,
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this._contents.values();
|
||||
},
|
||||
|
||||
hasMoreElements() {
|
||||
return this._index < this._contents.length;
|
||||
},
|
||||
|
@ -2710,9 +2707,8 @@ class HandlerInfoWrapper {
|
|||
}
|
||||
|
||||
addPossibleApplicationHandler(aNewHandler) {
|
||||
var possibleApps = this.possibleApplicationHandlers.enumerate();
|
||||
while (possibleApps.hasMoreElements()) {
|
||||
if (possibleApps.getNext().equals(aNewHandler))
|
||||
for (let app of this.possibleApplicationHandlers.enumerate()) {
|
||||
if (app.equals(aNewHandler))
|
||||
return;
|
||||
}
|
||||
this.possibleApplicationHandlers.appendElement(aNewHandler);
|
||||
|
|
|
@ -54,15 +54,10 @@ var gLanguagesDialog = {
|
|||
}
|
||||
|
||||
// 1) Read the available languages out of language.properties
|
||||
var strings = bundleAccepted.strings;
|
||||
|
||||
let localeCodes = [];
|
||||
let localeValues = [];
|
||||
while (strings.hasMoreElements()) {
|
||||
var currString = strings.getNext();
|
||||
if (!(currString instanceof Ci.nsIPropertyElement))
|
||||
break;
|
||||
|
||||
for (let currString of bundleAccepted.strings) {
|
||||
var property = currString.key.split("."); // ab[-cd].accept
|
||||
if (property[1] == "accept") {
|
||||
localeCodes.push(property[0]);
|
||||
|
|
|
@ -260,9 +260,7 @@ var gPermissionManager = {
|
|||
|
||||
_loadPermissions() {
|
||||
// load permissions into a table.
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let nextPermission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
for (let nextPermission of Services.perms.enumerator) {
|
||||
this._addPermissionToList(nextPermission);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -192,9 +192,7 @@ var gSitePermissionsManager = {
|
|||
|
||||
_loadPermissions() {
|
||||
// load permissions into a table.
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let nextPermission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
for (let nextPermission of Services.perms.enumerator) {
|
||||
this._addPermissionToList(nextPermission);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -93,10 +93,7 @@ var gTranslationExceptions = {
|
|||
|
||||
// Load site permissions into an array.
|
||||
this._sites = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.type == kPermissionType &&
|
||||
perm.capability == Services.perms.DENY_ACTION) {
|
||||
this._sites.push(perm.principal.origin);
|
||||
|
|
|
@ -176,9 +176,8 @@ var SessionCookiesInternal = {
|
|||
return;
|
||||
}
|
||||
|
||||
let iter = Services.cookies.sessionEnumerator;
|
||||
while (iter.hasMoreElements()) {
|
||||
this._addCookie(iter.getNext());
|
||||
for (let cookie of Services.cookies.sessionEnumerator) {
|
||||
this._addCookie(cookie);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -597,9 +597,7 @@ var SessionStoreInternal = {
|
|||
// in one of the currently open windows that was closed after the
|
||||
// last-closed window.
|
||||
let tabTimestamps = [];
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let window = windowsEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let windowState = this._windows[window.__SSi];
|
||||
if (windowState && windowState._closedTabs[0]) {
|
||||
tabTimestamps.push(windowState._closedTabs[0].closedAt);
|
||||
|
@ -2722,9 +2720,7 @@ var SessionStoreInternal = {
|
|||
}
|
||||
|
||||
// Check for a tab.
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let window = windowsEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let windowState = this._windows[window.__SSi];
|
||||
if (windowState) {
|
||||
for (let j = 0, l = windowState._closedTabs.length; j < l; j++) {
|
||||
|
@ -2785,9 +2781,7 @@ var SessionStoreInternal = {
|
|||
|
||||
// This method deletes all the closedTabs matching userContextId.
|
||||
_forgetTabsWithUserContextId(userContextId) {
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let window = windowsEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let windowState = this._windows[window.__SSi];
|
||||
if (windowState) {
|
||||
// In order to remove the tabs in the correct order, we store the
|
||||
|
@ -2972,9 +2966,7 @@ var SessionStoreInternal = {
|
|||
* Revive all crashed tabs and reset the crashed tabs count to 0.
|
||||
*/
|
||||
reviveAllCrashedTabs() {
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let window = windowsEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
for (let tab of window.gBrowser.tabs) {
|
||||
this.reviveCrashedTab(tab);
|
||||
}
|
||||
|
@ -4329,11 +4321,8 @@ var SessionStoreInternal = {
|
|||
* setBrowserState to treat them as open windows.
|
||||
*/
|
||||
_handleClosedWindows: function ssi_handleClosedWindows() {
|
||||
var windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
|
||||
let promises = [];
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
var window = windowsEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (window.closed) {
|
||||
promises.push(this.onClose(window));
|
||||
}
|
||||
|
|
|
@ -59,9 +59,8 @@ const IS_MAC = navigator.platform.match(/Mac/);
|
|||
*/
|
||||
function getBrowserWindowsCount() {
|
||||
let open = 0;
|
||||
let e = Services.wm.getEnumerator("navigator:browser");
|
||||
while (e.hasMoreElements()) {
|
||||
if (!e.getNext().closed)
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!win.closed)
|
||||
++open;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,8 @@ add_task(async function() {
|
|||
let state = ss.getBrowserState();
|
||||
|
||||
// verify our cookie got set during pageload
|
||||
let enumerator = Services.cookies.enumerator;
|
||||
let cookie;
|
||||
let i = 0;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (var cookie of Services.cookies.enumerator) {
|
||||
i++;
|
||||
}
|
||||
Assert.equal(i, 1, "expected one cookie");
|
||||
|
@ -39,10 +36,7 @@ add_task(async function() {
|
|||
await setBrowserState(state);
|
||||
|
||||
// at this point, the cookie should be restored...
|
||||
enumerator = Services.cookies.enumerator;
|
||||
let cookie2;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
cookie2 = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (var cookie2 of Services.cookies.enumerator) {
|
||||
if (cookie.name == cookie2.name)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,8 @@ function test() {
|
|||
|
||||
function browserWindowsCount(expected) {
|
||||
let count = 0;
|
||||
let e = Services.wm.getEnumerator("navigator:browser");
|
||||
while (e.hasMoreElements()) {
|
||||
if (!e.getNext().closed)
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!win.closed)
|
||||
++count;
|
||||
}
|
||||
is(count, expected,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
function browserWindowsCount(expected) {
|
||||
var count = 0;
|
||||
var e = Services.wm.getEnumerator("navigator:browser");
|
||||
while (e.hasMoreElements()) {
|
||||
if (!e.getNext().closed)
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!win.closed)
|
||||
++count;
|
||||
}
|
||||
is(count, expected,
|
||||
|
|
|
@ -67,10 +67,8 @@ function testBug600545() {
|
|||
function done() {
|
||||
// Enumerate windows and close everything but our primary window. We can't
|
||||
// use waitForFocus() because apparently it's buggy. See bug 599253.
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
let closeWinPromises = [];
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let currentWindow = windowsEnum.getNext();
|
||||
for (let currentWindow of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (currentWindow != window)
|
||||
closeWinPromises.push(BrowserTestUtils.closeWindow(currentWindow));
|
||||
}
|
||||
|
|
|
@ -26,10 +26,8 @@ function runNextTest() {
|
|||
if (tests.length) {
|
||||
// Enumerate windows and close everything but our primary window. We can't
|
||||
// use waitForFocus() because apparently it's buggy. See bug 599253.
|
||||
var windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
let closeWinPromises = [];
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
var currentWindow = windowsEnum.getNext();
|
||||
for (let currentWindow of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (currentWindow != window) {
|
||||
closeWinPromises.push(BrowserTestUtils.closeWindow(currentWindow));
|
||||
}
|
||||
|
|
|
@ -50,10 +50,7 @@ function test() {
|
|||
|
||||
function countTabs() {
|
||||
let needsRestore = 0, isRestoring = 0;
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let window = windowsEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (window.closed)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -136,11 +136,8 @@ add_task(async function run_test() {
|
|||
// Restore window with session cookies that have no originAttributes.
|
||||
await setWindowState(win, SESSION_DATA, true);
|
||||
|
||||
let enumerator = Services.cookies.getCookiesFromHost(TEST_HOST, {});
|
||||
let cookie;
|
||||
let cookieCount = 0;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (var cookie of Services.cookies.getCookiesFromHost(TEST_HOST, {})) {
|
||||
cookieCount++;
|
||||
}
|
||||
|
||||
|
@ -156,10 +153,8 @@ add_task(async function run_test() {
|
|||
// Restore window with session cookies that have originAttributes within.
|
||||
await setWindowState(win, SESSION_DATA_OA, true);
|
||||
|
||||
enumerator = Services.cookies.getCookiesFromHost(TEST_HOST, {});
|
||||
cookieCount = 0;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (cookie of Services.cookies.getCookiesFromHost(TEST_HOST, {})) {
|
||||
cookieCount++;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,9 +318,7 @@ function r() {
|
|||
}
|
||||
|
||||
function* BrowserWindowIterator() {
|
||||
let windowsEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let currentWindow = windowsEnum.getNext();
|
||||
for (let currentWindow of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!currentWindow.closed) {
|
||||
yield currentWindow;
|
||||
}
|
||||
|
|
|
@ -43,10 +43,7 @@ function getLanguageExceptions() {
|
|||
|
||||
function getDomainExceptions() {
|
||||
let results = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.type == "translate" &&
|
||||
perm.capability == Services.perms.DENY_ACTION)
|
||||
results.push(perm.principal);
|
||||
|
|
|
@ -652,9 +652,7 @@ var UITour = {
|
|||
// The browser message manager is disconnected when the <browser> is
|
||||
// destroyed and we want to teardown at that point.
|
||||
case "message-manager-close": {
|
||||
let winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let window = winEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (window.closed)
|
||||
continue;
|
||||
|
||||
|
@ -1683,9 +1681,7 @@ var UITour = {
|
|||
},
|
||||
|
||||
notify(eventName, params) {
|
||||
let winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let window = winEnum.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (window.closed)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -47,24 +47,16 @@ function getDialogDoc() {
|
|||
// through all the open windows and all the <browsers> in each.
|
||||
|
||||
// var enumerator = wm.getEnumerator("navigator:browser");
|
||||
var enumerator = Services.wm.getXULWindowEnumerator(null);
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
var win = enumerator.getNext();
|
||||
var windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell;
|
||||
|
||||
var containedDocShells = windowDocShell.getDocShellEnumerator(
|
||||
Ci.nsIDocShellTreeItem.typeChrome,
|
||||
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
||||
while (containedDocShells.hasMoreElements()) {
|
||||
for (let {docShell} of Services.wm.getEnumerator(null)) {
|
||||
var containedDocShells = docShell.getDocShellEnumerator(
|
||||
docShell.typeChrome,
|
||||
docShell.ENUMERATE_FORWARDS);
|
||||
for (let childDocShell of containedDocShells) {
|
||||
// Get the corresponding document for this docshell
|
||||
var childDocShell = containedDocShells.getNext();
|
||||
// We don't want it if it's not done loading.
|
||||
if (childDocShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE)
|
||||
continue;
|
||||
var childDoc = childDocShell.QueryInterface(Ci.nsIDocShell)
|
||||
.contentViewer
|
||||
.DOMDocument;
|
||||
var childDoc = childDocShell.contentViewer.DOMDocument;
|
||||
|
||||
// ok(true, "Got window: " + childDoc.location.href);
|
||||
if (childDoc.location.href == "chrome://global/content/commonDialog.xul")
|
||||
|
|
|
@ -128,11 +128,8 @@ this.formautofill = class extends ExtensionAPI {
|
|||
|
||||
Services.mm.removeMessageListener("FormAutoComplete:MaybeOpenPopup", onMaybeOpenPopup);
|
||||
|
||||
let enumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let win = enumerator.getNext();
|
||||
let domWindow = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
|
||||
let cachedStyleSheets = CACHED_STYLESHEETS.get(domWindow);
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let cachedStyleSheets = CACHED_STYLESHEETS.get(win);
|
||||
|
||||
if (!cachedStyleSheets) {
|
||||
continue;
|
||||
|
|
|
@ -99,9 +99,7 @@ function getLocalizedStrings(path) {
|
|||
Services.strings.createBundle("chrome://pdf.js/locale/" + path);
|
||||
|
||||
var map = {};
|
||||
var enumerator = stringBundle.getSimpleEnumeration();
|
||||
while (enumerator.hasMoreElements()) {
|
||||
var string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
|
||||
for (let string of stringBundle.getSimpleEnumeration()) {
|
||||
var key = string.key, property = "textContent";
|
||||
var i = key.lastIndexOf(".");
|
||||
if (i >= 0) {
|
||||
|
|
|
@ -538,9 +538,6 @@ function install() {
|
|||
function uninstall() {
|
||||
}
|
||||
|
||||
function* browserWindows() {
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
yield windows.getNext();
|
||||
}
|
||||
function browserWindows() {
|
||||
return Services.wm.getEnumerator("navigator:browser");
|
||||
}
|
||||
|
|
|
@ -530,9 +530,7 @@ var pktUI = (function() {
|
|||
pktUIMessaging.addMessageListener(iframe, _initL10NMessageId, function(panelId, data) {
|
||||
var strings = {};
|
||||
var bundle = Services.strings.createBundle("chrome://pocket/locale/pocket.properties");
|
||||
var e = bundle.getSimpleEnumeration();
|
||||
while (e.hasMoreElements()) {
|
||||
var str = e.getNext().QueryInterface(Ci.nsIPropertyElement);
|
||||
for (let str of bundle.getSimpleEnumeration()) {
|
||||
if (str.key in data) {
|
||||
strings[str.key] = bundle.formatStringFromName(str.key, data[str.key], data[str.key].length);
|
||||
} else {
|
||||
|
@ -568,9 +566,7 @@ var pktUI = (function() {
|
|||
return;
|
||||
}
|
||||
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(win)) {
|
||||
win.openWebLinkIn(url, "tab", {
|
||||
triggeringPrincipal: aTriggeringPrincipal
|
||||
|
|
|
@ -155,10 +155,8 @@ var pktApi = (function() {
|
|||
* The return format: { cookieName:cookieValue, cookieName:cookieValue, ... }
|
||||
*/
|
||||
function getCookiesFromPocket() {
|
||||
var pocketCookies = Services.cookies.getCookiesFromHost(pocketSiteHost, {});
|
||||
var cookies = {};
|
||||
while (pocketCookies.hasMoreElements()) {
|
||||
var cookie = pocketCookies.getNext().QueryInterface(Ci.nsICookie2);
|
||||
for (let cookie of Services.cookies.getCookiesFromHost(pocketSiteHost, {})) {
|
||||
cookies[cookie.name] = cookie.value;
|
||||
}
|
||||
return cookies;
|
||||
|
|
|
@ -95,9 +95,7 @@ function getOpenTabsAndWinsCounts() {
|
|||
let tabCount = 0;
|
||||
let winCount = 0;
|
||||
|
||||
let browserEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserEnum.hasMoreElements()) {
|
||||
let win = browserEnum.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
winCount++;
|
||||
tabCount += win.gBrowser.tabs.length;
|
||||
}
|
||||
|
@ -659,9 +657,8 @@ let BrowserUsageTelemetry = {
|
|||
Services.obs.addObserver(this, TELEMETRY_SUBSESSIONSPLIT_TOPIC, true);
|
||||
|
||||
// Attach the tabopen handlers to the existing Windows.
|
||||
let browserEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserEnum.hasMoreElements()) {
|
||||
this._registerWindow(browserEnum.getNext());
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
this._registerWindow(win);
|
||||
}
|
||||
|
||||
// Get the initial tab and windows max counts.
|
||||
|
|
|
@ -169,19 +169,15 @@ var WindowHelper = {
|
|||
// if we're lucky, this isn't a popup, and we can just return this
|
||||
if (win && !isSuitableBrowserWindow(win)) {
|
||||
win = null;
|
||||
let windowList = Services.wm.getEnumerator("navigator:browser");
|
||||
// this is oldest to newest, so this gets a bit ugly
|
||||
while (windowList.hasMoreElements()) {
|
||||
let nextWin = windowList.getNext();
|
||||
for (let nextWin of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (isSuitableBrowserWindow(nextWin))
|
||||
win = nextWin;
|
||||
}
|
||||
}
|
||||
return win;
|
||||
}
|
||||
let windowList = Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
|
||||
while (windowList.hasMoreElements()) {
|
||||
let win = windowList.getNext();
|
||||
for (let win of Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true)) {
|
||||
if (isSuitableBrowserWindow(win))
|
||||
return win;
|
||||
}
|
||||
|
|
|
@ -458,9 +458,7 @@ var TabCrashHandler = {
|
|||
},
|
||||
|
||||
removeSubmitCheckboxesForSameCrash(childID) {
|
||||
let enumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let window = enumerator.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!window.gMultiProcessBrowser)
|
||||
continue;
|
||||
|
||||
|
@ -1069,9 +1067,7 @@ var PluginCrashReporter = {
|
|||
},
|
||||
|
||||
broadcastState(runID, state) {
|
||||
let enumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let window = enumerator.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let mm = window.messageManager;
|
||||
mm.broadcastAsyncMessage("BrowserPlugins:CrashReportSubmitted",
|
||||
{ runID, state });
|
||||
|
|
|
@ -1200,10 +1200,7 @@ function* allBrowserWindows(browserWindow = null) {
|
|||
yield browserWindow;
|
||||
return;
|
||||
}
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
yield windows.getNext();
|
||||
}
|
||||
yield* Services.wm.getEnumerator("navigator:browser");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -391,9 +391,7 @@ var ProcessHangMonitor = {
|
|||
return;
|
||||
}
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
let win = e.getNext();
|
||||
|
||||
for (let win of e) {
|
||||
this.updateWindow(win);
|
||||
|
||||
// Only listen for these events if there are active hang reports.
|
||||
|
|
|
@ -351,9 +351,7 @@ var Sanitizer = {
|
|||
TelemetryStopwatch.start("FX_SANITIZE_FORMDATA", refObj);
|
||||
try {
|
||||
// Clear undo history of all search bars.
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let currentWindow = windows.getNext();
|
||||
for (let currentWindow of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let currentDocument = currentWindow.document;
|
||||
|
||||
// searchBar.textbox may not exist due to the search bar binding
|
||||
|
@ -466,10 +464,8 @@ var Sanitizer = {
|
|||
let startDate = existingWindow.performance.now();
|
||||
|
||||
// First check if all these windows are OK with being closed:
|
||||
let windowEnumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
let windowList = [];
|
||||
while (windowEnumerator.hasMoreElements()) {
|
||||
let someWin = windowEnumerator.getNext();
|
||||
for (let someWin of Services.wm.getEnumerator("navigator:browser")) {
|
||||
windowList.push(someWin);
|
||||
// If someone says "no" to a beforeunload prompt, we abort here:
|
||||
if (!this._canCloseWindow(someWin)) {
|
||||
|
@ -690,9 +686,7 @@ async function sanitizeOnShutdown(progress) {
|
|||
await sanitizeSessionPrincipals();
|
||||
|
||||
// Let's see if we have to forget some particular site.
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
for (let permission of Services.perms.enumerator) {
|
||||
if (permission.type == "cookie" && permission.capability == Ci.nsICookiePermission.ACCESS_SESSION) {
|
||||
await sanitizeSessionPrincipal(permission.principal);
|
||||
}
|
||||
|
|
|
@ -459,9 +459,7 @@ class WindowWatcher {
|
|||
this._errorCallback = errorCallback;
|
||||
|
||||
// Add loadCallback to existing windows
|
||||
const windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
const win = windows.getNext();
|
||||
for (const win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
try {
|
||||
this._loadCallback(win);
|
||||
} catch (ex) {
|
||||
|
@ -480,9 +478,7 @@ class WindowWatcher {
|
|||
return;
|
||||
}
|
||||
|
||||
const windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
const win = windows.getNext();
|
||||
for (const win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
try {
|
||||
this._unloadCallback(win);
|
||||
} catch (ex) {
|
||||
|
|
|
@ -173,9 +173,7 @@ var SiteDataManager = {
|
|||
},
|
||||
|
||||
_getAllCookies() {
|
||||
let cookiesEnum = Services.cookies.enumerator;
|
||||
while (cookiesEnum.hasMoreElements()) {
|
||||
let cookie = cookiesEnum.getNext().QueryInterface(Ci.nsICookie2);
|
||||
for (let cookie of Services.cookies.enumerator) {
|
||||
let site = this._getOrInsertSite(cookie.rawHost);
|
||||
site.cookies.push(cookie);
|
||||
if (site.lastAccessed < cookie.lastAccessed) {
|
||||
|
|
|
@ -729,9 +729,7 @@ var AeroPeek = {
|
|||
// (rather than this code running on startup because the pref was
|
||||
// already set to true), we must initialize previews for open windows:
|
||||
if (this.initialized) {
|
||||
let browserWindows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserWindows.hasMoreElements()) {
|
||||
let win = browserWindows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!win.closed) {
|
||||
this.onOpenWindow(win);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ function checkEvents(events, expectedEvents) {
|
|||
*/
|
||||
function makeMockPermissionRequest(browser) {
|
||||
let type = {
|
||||
options: [],
|
||||
options: Cc["@mozilla.org/array;1"].createInstance(Ci.nsIArray),
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIContentPermissionType]),
|
||||
};
|
||||
let types = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
||||
|
|
|
@ -1090,9 +1090,7 @@ function updateIndicators(data, target) {
|
|||
indicators.showScreenSharingIndicator = data.showScreenSharingIndicator;
|
||||
}
|
||||
|
||||
let browserWindowEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserWindowEnum.hasMoreElements()) {
|
||||
let chromeWin = browserWindowEnum.getNext();
|
||||
for (let chromeWin of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (webrtcUI.showGlobalIndicator) {
|
||||
showOrCreateMenuForWindow(chromeWin);
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче