зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1484496: Part 5b - Convert toolkit/ nsISimpleEnumerator users to use JS iteration. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D3730 --HG-- extra : rebase_source : 935f166ec2c6581ba6f3fffe912404e81c8dc3d6 extra : histedit_source : ba701801de5205dcce6cfdccabe7b26aa7c7859c
This commit is contained in:
Родитель
80327d3561
Коммит
6adf9223ce
|
@ -75,9 +75,7 @@ function performanceCountersEnabled() {
|
|||
let tabFinder = {
|
||||
update() {
|
||||
this._map = new Map();
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let tabbrowser = win.gBrowser;
|
||||
for (let browser of tabbrowser.browsers) {
|
||||
let id = browser.outerWindowID; // May be `null` if the browser isn't loaded yet
|
||||
|
|
|
@ -200,9 +200,7 @@ function moveWindowToReplace(aReplacedAlert) {
|
|||
|
||||
// Move windows that come after the replaced alert if the height is different.
|
||||
if (heightDelta != 0) {
|
||||
let windows = Services.wm.getEnumerator("alert:alert");
|
||||
while (windows.hasMoreElements()) {
|
||||
let alertWindow = windows.getNext();
|
||||
for (let alertWindow of Services.wm.getEnumerator("alert:alert")) {
|
||||
// boolean to determine if the alert window is after the replaced alert.
|
||||
let alertIsAfter = gOrigin & NS_ALERT_TOP ?
|
||||
alertWindow.screenY > aReplacedAlert.screenY :
|
||||
|
@ -230,9 +228,7 @@ function moveWindowToEnd() {
|
|||
screen.availTop + screen.availHeight - window.outerHeight;
|
||||
|
||||
// Position the window at the end of all alerts.
|
||||
let windows = Services.wm.getEnumerator("alert:alert");
|
||||
while (windows.hasMoreElements()) {
|
||||
let alertWindow = windows.getNext();
|
||||
for (let alertWindow of Services.wm.getEnumerator("alert:alert")) {
|
||||
if (alertWindow != window) {
|
||||
if (gOrigin & NS_ALERT_TOP) {
|
||||
y = Math.max(y, alertWindow.screenY + alertWindow.outerHeight - WINDOW_SHADOW_SPREAD);
|
||||
|
@ -253,9 +249,7 @@ function onAlertBeforeUnload() {
|
|||
if (!gIsReplaced) {
|
||||
// Move other alert windows to fill the gap left by closing alert.
|
||||
let heightDelta = window.outerHeight + WINDOW_MARGIN - WINDOW_SHADOW_SPREAD;
|
||||
let windows = Services.wm.getEnumerator("alert:alert");
|
||||
while (windows.hasMoreElements()) {
|
||||
let alertWindow = windows.getNext();
|
||||
for (let alertWindow of Services.wm.getEnumerator("alert:alert")) {
|
||||
if (alertWindow != window) {
|
||||
if (gOrigin & NS_ALERT_TOP) {
|
||||
if (alertWindow.screenY > window.screenY) {
|
||||
|
|
|
@ -23,9 +23,7 @@ var PropertyBagConverter = {
|
|||
throw new TypeError("Not a property bag");
|
||||
}
|
||||
let result = {};
|
||||
let enumerator = bag.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let {name, value: property} = enumerator.getNext().QueryInterface(Ci.nsIProperty);
|
||||
for (let {name, value: property} of bag.enumerator) {
|
||||
let value = this.toValue(property);
|
||||
result[name] = value;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ const CookieCleaner = {
|
|||
|
||||
return new Promise((aResolve, aReject) => {
|
||||
let count = 0;
|
||||
while (aEnumerator.hasMoreElements()) {
|
||||
let cookie = aEnumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
for (let cookie of aEnumerator) {
|
||||
if (aCb(cookie)) {
|
||||
Services.cookies.remove(cookie.host, cookie.name, cookie.path,
|
||||
false, cookie.originAttributes);
|
||||
|
@ -514,9 +513,7 @@ const AuthCacheCleaner = {
|
|||
const PermissionsCleaner = {
|
||||
deleteByHost(aHost, aOriginAttributes) {
|
||||
return new Promise(aResolve => {
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
try {
|
||||
if (eTLDService.hasRootDomain(perm.principal.URI.host, aHost)) {
|
||||
Services.perms.removePermission(perm);
|
||||
|
@ -590,10 +587,8 @@ const SecuritySettingsCleaner = {
|
|||
Ci.nsISiteSecurityService.HEADER_HPKP]) {
|
||||
// Also remove HSTS/HPKP/OMS information for subdomains by enumerating
|
||||
// the information in the site security service.
|
||||
let enumerator = sss.enumerate(type);
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let entry = enumerator.getNext();
|
||||
let hostname = entry.QueryInterface(Ci.nsISiteSecurityState).hostname;
|
||||
for (let entry of sss.enumerate(type)) {
|
||||
let hostname = entry.hostname;
|
||||
if (eTLDService.hasRootDomain(hostname, aHost)) {
|
||||
// This uri is used as a key to remove the state.
|
||||
let uri = Services.io.newURI("https://" + hostname);
|
||||
|
|
|
@ -473,10 +473,7 @@ _ContextualIdentityService.prototype = {
|
|||
},
|
||||
|
||||
_forEachContainerTab(callback, userContextId = 0) {
|
||||
let windowList = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowList.hasMoreElements()) {
|
||||
let win = windowList.getNext();
|
||||
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (win.closed || !win.gBrowser) {
|
||||
continue;
|
||||
}
|
||||
|
@ -530,10 +527,7 @@ _ContextualIdentityService.prototype = {
|
|||
// Collect the userContextIds currently used by any stored cookie.
|
||||
let cookiesUserContextIds = new Set();
|
||||
|
||||
const enumerator = Services.cookies.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
const cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
|
||||
for (let cookie of Services.cookies.enumerator) {
|
||||
// Skip any userContextIds that should not be cleared.
|
||||
if (cookie.originAttributes.userContextId >= minUserContextId &&
|
||||
!keepDataContextIds.includes(cookie.originAttributes.userContextId)) {
|
||||
|
|
|
@ -35,9 +35,7 @@ function createCookie(userContextId) {
|
|||
|
||||
function hasCookie(userContextId) {
|
||||
let found = false;
|
||||
let enumerator = Services.cookies.getCookiesFromHost(BASE_URL, {userContextId});
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
for (let cookie of Services.cookies.getCookiesFromHost(BASE_URL, {userContextId})) {
|
||||
if (cookie.originAttributes.userContextId == userContextId) {
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
@ -63,9 +63,7 @@ var DownloadUIHelper = {
|
|||
XPCOMUtils.defineLazyGetter(DownloadUIHelper, "strings", function() {
|
||||
let strings = {};
|
||||
let sb = Services.strings.createBundle(kStringBundleUrl);
|
||||
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 kStringsRequiringFormatting) {
|
||||
strings[stringName] = function() {
|
||||
|
|
|
@ -962,7 +962,7 @@ var ExtensionContent = {
|
|||
let enum_ = docShell.getDocShellEnumerator(docShell.typeContent,
|
||||
docShell.ENUMERATE_FORWARDS);
|
||||
|
||||
for (let docShell of XPCOMUtils.IterSimpleEnumerator(enum_, Ci.nsIDocShell)) {
|
||||
for (let docShell of enum_) {
|
||||
try {
|
||||
yield docShell.domWindow;
|
||||
} catch (e) {
|
||||
|
|
|
@ -278,7 +278,7 @@ const query = function* (detailsIn, props, context) {
|
|||
return true;
|
||||
}
|
||||
|
||||
for (const cookie of XPCOMUtils.IterSimpleEnumerator(enumerator, Ci.nsICookie2)) {
|
||||
for (const cookie of enumerator) {
|
||||
if (matches(cookie)) {
|
||||
yield {cookie, isPrivate, storeId};
|
||||
}
|
||||
|
|
|
@ -1354,10 +1354,7 @@ class WindowTrackerBase extends EventEmitter {
|
|||
// fires for browser windows when they're in that in-between state, and just
|
||||
// before we register our own "domwindowcreated" listener.
|
||||
|
||||
let e = Services.wm.getEnumerator("");
|
||||
while (e.hasMoreElements()) {
|
||||
let window = e.getNext();
|
||||
|
||||
for (let window of Services.wm.getEnumerator("")) {
|
||||
let ok = includeIncomplete;
|
||||
if (window.document.readyState === "complete") {
|
||||
ok = this.isBrowserWindow(window);
|
||||
|
|
|
@ -22,9 +22,7 @@ if (AppConstants.MOZ_BUILD_APP === "mobile/android") {
|
|||
}
|
||||
|
||||
function* iterBrowserWindows() {
|
||||
let enm = Services.wm.getEnumerator("navigator:browser");
|
||||
while (enm.hasMoreElements()) {
|
||||
let win = enm.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (!win.closed && getBrowserApp(win)) {
|
||||
yield win;
|
||||
}
|
||||
|
|
|
@ -139,9 +139,8 @@ async function testCookies(options) {
|
|||
|
||||
function getCookies(host) {
|
||||
let cookies = [];
|
||||
let enum_ = cookieSvc.getCookiesFromHost(host, {});
|
||||
while (enum_.hasMoreElements()) {
|
||||
cookies.push(enum_.getNext().QueryInterface(Ci.nsICookie2));
|
||||
for (let cookie of cookieSvc.getCookiesFromHost(host, {})) {
|
||||
cookies.push(cookie);
|
||||
}
|
||||
return cookies.sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
|
|
@ -153,14 +153,10 @@ add_task(async function test_localStorage_on_session_lifetimePolicy() {
|
|||
domStorageStoredValue,
|
||||
} = await ContentTask.spawn(addonBrowser, {uuid, isRemoteBrowser}, (params) => {
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
|
||||
let windowEnumerator = Services.ww.getWindowEnumerator();
|
||||
|
||||
let bgPageWindow;
|
||||
|
||||
// Search the background page window in the process where the extension is running.
|
||||
while (windowEnumerator.hasMoreElements()) {
|
||||
let win = windowEnumerator.getNext();
|
||||
|
||||
for (let win of Services.ww.getWindowEnumerator()) {
|
||||
// When running in remote-webextension mode the window enumerator
|
||||
// will only include top level windows related to the extension process
|
||||
// (the background page and the "about:blank" related to the addonBrowser
|
||||
|
|
|
@ -12,9 +12,7 @@ server.registerPathHandler("/return_headers.sjs", (request, response) => {
|
|||
response.setHeader("Content-Type", "text/plain", false);
|
||||
|
||||
let headers = {};
|
||||
// Why on earth is this a nsISimpleEnumerator...
|
||||
for (let {data: header} of XPCOMUtils.IterSimpleEnumerator(request.headers,
|
||||
Ci.nsISupportsString)) {
|
||||
for (let {data: header} of request.headers) {
|
||||
headers[header.toLowerCase()] = request.getHeader(header);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ server.registerPathHandler("/return_headers.sjs", (request, response) => {
|
|||
response.setHeader("Content-Type", "text/plain", false);
|
||||
|
||||
let headers = {};
|
||||
// Why on earth is this a nsISimpleEnumerator...
|
||||
for (let {data: header} of XPCOMUtils.IterSimpleEnumerator(request.headers,
|
||||
Ci.nsISupportsString)) {
|
||||
for (let {data: header} of request.headers) {
|
||||
headers[header.toLowerCase()] = request.getHeader(header);
|
||||
}
|
||||
|
||||
|
@ -184,7 +182,6 @@ add_task(async function test_set_responseHeaders() {
|
|||
let headerPromise = new Promise(resolve => { resolveHeaderPromise = resolve; });
|
||||
{
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
let ssm = Services.scriptSecurityManager;
|
||||
|
||||
|
|
|
@ -68,9 +68,7 @@ class ShieldFrameChild extends ActorChild {
|
|||
break;
|
||||
case "GetRemoteValue:ShieldTranslations":
|
||||
const strings = {};
|
||||
const e = gStringBundle.getSimpleEnumeration();
|
||||
while (e.hasMoreElements()) {
|
||||
var str = e.getNext().QueryInterface(Ci.nsIPropertyElement);
|
||||
for (let str of gStringBundle.getSimpleEnumeration()) {
|
||||
strings[str.key] = str.value;
|
||||
}
|
||||
const brandName = gBrandBundle.GetStringFromName("brandShortName");
|
||||
|
|
|
@ -30,9 +30,7 @@ let anyWindowsWithInjectedCss = false;
|
|||
// Add cleanup handler for CSS injected into windows by Heartbeat
|
||||
CleanupManager.addCleanupHandler(() => {
|
||||
if (anyWindowsWithInjectedCss) {
|
||||
const windowEnumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windowEnumerator.hasMoreElements()) {
|
||||
const window = windowEnumerator.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
if (windowsWithInjectedCss.has(window)) {
|
||||
const utils = window.windowUtils;
|
||||
utils.removeSheet(HEARTBEAT_CSS_URI, window.AGENT_SHEET);
|
||||
|
|
|
@ -61,10 +61,8 @@ nsDefaultCLH.prototype = {
|
|||
false))) {
|
||||
out = "print-xpcom-dirlist(\"" + printDirList + "\"): ";
|
||||
try {
|
||||
var list = getDirectoryService().get(printDirList,
|
||||
nsISimpleEnumerator);
|
||||
while (list.hasMoreElements())
|
||||
out += list.getNext().QueryInterface(nsIFile).path + ";";
|
||||
for (let file of getDirectoryService().get(printDirList, nsISimpleEnumerator))
|
||||
out += file.path + ";";
|
||||
} catch (e) {
|
||||
out += "<Not Provided>";
|
||||
}
|
||||
|
|
|
@ -336,9 +336,7 @@ var LoginHelper = {
|
|||
}
|
||||
}
|
||||
|
||||
let propEnum = aNewLoginData.enumerator;
|
||||
while (propEnum.hasMoreElements()) {
|
||||
let prop = propEnum.getNext().QueryInterface(Ci.nsIProperty);
|
||||
for (let prop of aNewLoginData.enumerator) {
|
||||
switch (prop.name) {
|
||||
// nsILoginInfo
|
||||
case "hostname":
|
||||
|
|
|
@ -402,10 +402,7 @@ LoginManager.prototype = {
|
|||
log.debug("Getting a list of all disabled origins");
|
||||
|
||||
let disabledHosts = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext();
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.type == PERMISSION_SAVE_LOGINS && perm.capability == Services.perms.DENY_ACTION) {
|
||||
disabledHosts.push(perm.principal.URI.displayPrePath);
|
||||
}
|
||||
|
|
|
@ -1435,9 +1435,7 @@ LoginManagerPrompter.prototype = {
|
|||
return { win: chromeWin, browser };
|
||||
}
|
||||
|
||||
let windows = Services.wm.getEnumerator(null);
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
for (let win of Services.wm.getEnumerator(null)) {
|
||||
let tabbrowser = win.gBrowser || win.getBrowser();
|
||||
let browser = tabbrowser.getBrowserForContentWindow(aWindow);
|
||||
if (browser) {
|
||||
|
|
|
@ -260,9 +260,7 @@ this.LoginManagerStorage_json.prototype = {
|
|||
let realMatchData = {};
|
||||
let options = {};
|
||||
// Convert nsIPropertyBag to normal JS object
|
||||
let propEnum = matchData.enumerator;
|
||||
while (propEnum.hasMoreElements()) {
|
||||
let prop = propEnum.getNext().QueryInterface(Ci.nsIProperty);
|
||||
for (let prop of matchData.enumerator) {
|
||||
switch (prop.name) {
|
||||
// Some property names aren't field names but are special options to affect the search.
|
||||
case "schemeUpgrades": {
|
||||
|
|
|
@ -402,9 +402,7 @@ LoginManagerStorage_mozStorage.prototype = {
|
|||
let realMatchData = {};
|
||||
let options = {};
|
||||
// Convert nsIPropertyBag to normal JS object
|
||||
let propEnum = matchData.enumerator;
|
||||
while (propEnum.hasMoreElements()) {
|
||||
let prop = propEnum.getNext().QueryInterface(Ci.nsIProperty);
|
||||
for (let prop of matchData.enumerator) {
|
||||
switch (prop.name) {
|
||||
// Some property names aren't field names but are special options to affect the search.
|
||||
case "schemeUpgrades": {
|
||||
|
|
|
@ -8,24 +8,15 @@ function getSelectDialogDoc() {
|
|||
// Trudge through all the open windows, until we find the one
|
||||
// that has selectDialog.xul loaded.
|
||||
// var enumerator = Services.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()) {
|
||||
// Get the corresponding document for this docshell
|
||||
var childDocShell = containedDocShells.getNext();
|
||||
for (let {docShell} of Services.wm.getEnumerator(null)) {
|
||||
var containedDocShells = docShell.getDocShellEnumerator(
|
||||
docShell.typeChrome,
|
||||
docShell.ENUMERATE_FORWARDS);
|
||||
for (let childDocShell of containedDocShells) {
|
||||
// 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;
|
||||
|
||||
if (childDoc.location.href == "chrome://global/content/selectDialog.xul")
|
||||
return childDoc;
|
||||
|
|
|
@ -49,24 +49,15 @@ function getDialogDoc() {
|
|||
// Find the <browser> which contains notifyWindow, by looking
|
||||
// through all the open windows and all the <browsers> in each.
|
||||
// var enumerator = SpecialPowers.Services.wm.getEnumerator("navigator:browser");
|
||||
var enumerator = SpecialPowers.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()) {
|
||||
// Get the corresponding document for this docshell
|
||||
var childDocShell = containedDocShells.getNext();
|
||||
for (let {docShell} of SpecialPowers.Services.wm.getXULWindowEnumerator(null)) {
|
||||
var containedDocShells = docShell.getDocShellEnumerator(
|
||||
docShell.typeChrome,
|
||||
docShell.ENUMERATE_FORWARDS);
|
||||
for (let childDocShell of containedDocShells) {
|
||||
// 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")
|
||||
|
|
|
@ -68,10 +68,7 @@ function checkStorageData(storage, ref_disabledHosts, ref_logins)
|
|||
|
||||
function getAllDisabledHostsFromPermissionManager() {
|
||||
let disabledHosts = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext();
|
||||
for (let perm of Services.perms.enumerator) {
|
||||
if (perm.type == PERMISSION_SAVE_LOGINS && perm.capability == Services.perms.DENY_ACTION) {
|
||||
disabledHosts.push(perm.principal.URI.prePath);
|
||||
}
|
||||
|
|
|
@ -808,17 +808,15 @@ function ProcessSnapshot({xpcom, probes}) {
|
|||
this.componentsData = [];
|
||||
|
||||
let subgroups = new Map();
|
||||
let enumeration = xpcom.getComponentsData().enumerate();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
let xpcom = enumeration.getNext().QueryInterface(Ci.nsIPerformanceStats);
|
||||
let stat = (new PerformanceDataLeaf({xpcom, probes}));
|
||||
for (let data of xpcom.getComponentsData().enumerate(Ci.nsIPerformanceStats)) {
|
||||
let stat = (new PerformanceDataLeaf({xpcom: data, probes}));
|
||||
|
||||
if (!xpcom.parentId) {
|
||||
if (!data.parentId) {
|
||||
this.componentsData.push(stat);
|
||||
} else {
|
||||
let siblings = subgroups.get(xpcom.parentId);
|
||||
let siblings = subgroups.get(data.parentId);
|
||||
if (!siblings) {
|
||||
subgroups.set(xpcom.parentId, (siblings = []));
|
||||
subgroups.set(data.parentId, (siblings = []));
|
||||
}
|
||||
siblings.push(stat);
|
||||
}
|
||||
|
|
|
@ -245,9 +245,7 @@ add_task(async function test() {
|
|||
// Attach titles to components.
|
||||
let titles = [];
|
||||
let map = new Map();
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let window = windows.getNext();
|
||||
for (let window of Services.wm.getEnumerator("navigator:browser")) {
|
||||
let tabbrowser = window.gBrowser;
|
||||
for (let browser of tabbrowser.browsers) {
|
||||
let id = browser.outerWindowID; // May be `null` if the browser isn't loaded yet
|
||||
|
|
|
@ -12,9 +12,7 @@ function commonDialogOnLoad() {
|
|||
.QueryInterface(Ci.nsIWritablePropertyBag);
|
||||
// Convert to a JS object
|
||||
args = {};
|
||||
let propEnum = propBag.enumerator;
|
||||
while (propEnum.hasMoreElements()) {
|
||||
let prop = propEnum.getNext().QueryInterface(Ci.nsIProperty);
|
||||
for (let prop of propBag.enumerator) {
|
||||
args[prop.name] = prop.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,24 +200,16 @@ function getDialogDoc() {
|
|||
// Trudge through all the open windows, until we find the one
|
||||
// that has either commonDialog.xul or selectDialog.xul loaded.
|
||||
// var enumerator = Services.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;
|
||||
|
||||
if (childDoc.location.href != "chrome://global/content/commonDialog.xul" &&
|
||||
childDoc.location.href != "chrome://global/content/selectDialog.xul")
|
||||
|
|
|
@ -2807,11 +2807,10 @@ SearchService.prototype = {
|
|||
} catch (e) {
|
||||
// NS_APP_DISTRIBUTION_SEARCH_DIR_LIST is defined by each app
|
||||
// so this throws during unit tests (but not xpcshell tests).
|
||||
locations = {hasMoreElements: () => false};
|
||||
locations = [];
|
||||
|
||||
}
|
||||
while (locations.hasMoreElements()) {
|
||||
let dir = locations.getNext().QueryInterface(Ci.nsIFile);
|
||||
for (let dir of locations) {
|
||||
if (dir.directoryEntries.nextFile)
|
||||
distDirs.push(dir);
|
||||
}
|
||||
|
@ -2873,10 +2872,9 @@ SearchService.prototype = {
|
|||
} catch (e) {
|
||||
// NS_APP_DISTRIBUTION_SEARCH_DIR_LIST is defined by each app
|
||||
// so this throws during unit tests (but not xpcshell tests).
|
||||
locations = {hasMoreElements: () => false};
|
||||
locations = [];
|
||||
}
|
||||
while (locations.hasMoreElements()) {
|
||||
let dir = locations.getNext().QueryInterface(Ci.nsIFile);
|
||||
for (let dir of locations) {
|
||||
let iterator = new OS.File.DirectoryIterator(dir.path,
|
||||
{ winPattern: "*.xml" });
|
||||
try {
|
||||
|
|
|
@ -62,10 +62,7 @@ SecurityReporter.prototype = {
|
|||
let asciiCertChain = [];
|
||||
|
||||
if (transportSecurityInfo.failedCertChain) {
|
||||
let certs = transportSecurityInfo.failedCertChain.getEnumerator();
|
||||
while (certs.hasMoreElements()) {
|
||||
let cert = certs.getNext();
|
||||
cert.QueryInterface(Ci.nsIX509Cert);
|
||||
for (let cert of transportSecurityInfo.failedCertChain.getEnumerator()) {
|
||||
asciiCertChain.push(btoa(getDERString(cert)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1400,9 +1400,7 @@ var Impl = {
|
|||
getOpenTabsCount: function getOpenTabsCount() {
|
||||
let tabCount = 0;
|
||||
|
||||
let browserEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (browserEnum.hasMoreElements()) {
|
||||
let win = browserEnum.getNext();
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
tabCount += win.gBrowser.tabs.length;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,9 +153,7 @@ TimerManager.prototype = {
|
|||
|
||||
var catMan = Cc["@mozilla.org/categorymanager;1"].
|
||||
getService(Ci.nsICategoryManager);
|
||||
var entries = catMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;
|
||||
for (let {data: entry} of catMan.enumerateCategory(CATEGORY_UPDATE_TIMER)) {
|
||||
let value = catMan.getCategoryEntry(CATEGORY_UPDATE_TIMER, entry);
|
||||
let [cid, method, timerID, prefInterval, defaultInterval, maxInterval] = value.split(",");
|
||||
|
||||
|
|
|
@ -332,9 +332,7 @@ function run_test() {
|
|||
gPref.setBoolPref(PREF_APP_UPDATE_LOG_ALL, true);
|
||||
|
||||
// Remove existing update timers to prevent them from being notified
|
||||
let entries = gCatMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;
|
||||
for (let {data: entry} of gCatMan.enumerateCategory(CATEGORY_UPDATE_TIMER)) {
|
||||
gCatMan.deleteCategoryEntry(CATEGORY_UPDATE_TIMER, entry, false);
|
||||
}
|
||||
|
||||
|
@ -474,13 +472,11 @@ function check_test0thru7() {
|
|||
gCatMan.deleteCategoryEntry(CATEGORY_UPDATE_TIMER, TESTS[1].desc, true);
|
||||
gCatMan.deleteCategoryEntry(CATEGORY_UPDATE_TIMER, TESTS[2].desc, true);
|
||||
gCatMan.deleteCategoryEntry(CATEGORY_UPDATE_TIMER, TESTS[3].desc, true);
|
||||
let entries = gCatMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;
|
||||
for (let {data: entry} of gCatMan.enumerateCategory(CATEGORY_UPDATE_TIMER)) {
|
||||
gCatMan.deleteCategoryEntry(CATEGORY_UPDATE_TIMER, entry, false);
|
||||
}
|
||||
|
||||
entries = gCatMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
|
||||
let entries = gCatMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
|
||||
Assert.ok(!entries.hasMoreElements(),
|
||||
"no " + CATEGORY_UPDATE_TIMER + " categories should still be " +
|
||||
"registered");
|
||||
|
|
|
@ -29,9 +29,7 @@ function findCurrentProfile() {
|
|||
} catch (e) {}
|
||||
|
||||
if (cpd) {
|
||||
let itr = ProfileService.profiles;
|
||||
while (itr.hasMoreElements()) {
|
||||
let profile = itr.getNext().QueryInterface(Ci.nsIToolkitProfile);
|
||||
for (let profile of ProfileService.profiles) {
|
||||
if (profile.rootDir.path == cpd.path) {
|
||||
return profile;
|
||||
}
|
||||
|
@ -60,9 +58,7 @@ function refreshUI() {
|
|||
|
||||
let currentProfile = findCurrentProfile();
|
||||
|
||||
let iter = ProfileService.profiles;
|
||||
while (iter.hasMoreElements()) {
|
||||
let profile = iter.getNext().QueryInterface(Ci.nsIToolkitProfile);
|
||||
for (let profile of ProfileService.profiles) {
|
||||
let isCurrentProfile = profile == currentProfile;
|
||||
let isInUse = isCurrentProfile;
|
||||
if (!isInUse) {
|
||||
|
@ -290,9 +286,7 @@ function removeProfile(profile) {
|
|||
} catch (e) {}
|
||||
|
||||
if (isSelected || isDefault) {
|
||||
let itr = ProfileService.profiles;
|
||||
while (itr.hasMoreElements()) {
|
||||
let p = itr.getNext().QueryInterface(Ci.nsIToolkitProfile);
|
||||
for (let p of ProfileService.profiles) {
|
||||
if (profile == p) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,7 @@ function closeWindow(aClose, aPromptFunction) {
|
|||
// Closing the last window doesn't quit the application on OS X.
|
||||
if (AppConstants.platform != "macosx") {
|
||||
var windowCount = 0;
|
||||
var e = Services.wm.getEnumerator(null);
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
var w = e.getNext();
|
||||
for (let w of Services.wm.getEnumerator(null)) {
|
||||
if (w.closed) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function macWindowMenuDidShow() {
|
||||
let windows = Services.wm.getEnumerator("");
|
||||
let frag = document.createDocumentFragment();
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext();
|
||||
for (let win of Services.wm.getEnumerator("")) {
|
||||
if (win.document.documentElement.getAttribute("inwindowmenu") == "false") {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ var EXPORTED_SYMBOLS = ["CertUtils"];
|
|||
const Ce = Components.Exception;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
|
||||
/**
|
||||
* Reads a set of expected certificate attributes from preferences. The returned
|
||||
|
@ -153,10 +152,8 @@ function checkCert(aChannel, aAllowNonBuiltInCerts, aCerts) {
|
|||
return;
|
||||
}
|
||||
|
||||
let certEnumerator = sslStatus.succeededCertChain.getEnumerator();
|
||||
let issuerCert = null;
|
||||
for (issuerCert of XPCOMUtils.IterSimpleEnumerator(certEnumerator,
|
||||
Ci.nsIX509Cert));
|
||||
for (issuerCert of sslStatus.succeededCertChain.getEnumerator());
|
||||
|
||||
const certNotBuiltInErr = "Certificate issuer is not built-in.";
|
||||
if (!issuerCert) {
|
||||
|
|
|
@ -32,9 +32,7 @@ var ResetProfile = {
|
|||
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"].
|
||||
getService(Ci.nsIToolkitProfileService);
|
||||
let currentProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
let profileEnumerator = profileService.profiles;
|
||||
while (profileEnumerator.hasMoreElements()) {
|
||||
let profile = profileEnumerator.getNext().QueryInterface(Ci.nsIToolkitProfile);
|
||||
for (let profile of profileService.profiles) {
|
||||
if (profile.rootDir && profile.rootDir.equals(currentProfileDir)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -186,12 +186,10 @@ var dataProviders = {
|
|||
|
||||
data.numTotalWindows = 0;
|
||||
data.numRemoteWindows = 0;
|
||||
let winEnumer = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnumer.hasMoreElements()) {
|
||||
for (let {docShell} of Services.wm.getEnumerator("navigator:browser")) {
|
||||
data.numTotalWindows++;
|
||||
let remote = winEnumer.getNext().docShell.
|
||||
QueryInterface(Ci.nsILoadContext).
|
||||
useRemoteTabs;
|
||||
let remote = docShell.QueryInterface(Ci.nsILoadContext)
|
||||
.useRemoteTabs;
|
||||
if (remote) {
|
||||
data.numRemoteWindows++;
|
||||
}
|
||||
|
@ -357,9 +355,8 @@ var dataProviders = {
|
|||
|
||||
data.numTotalWindows = 0;
|
||||
data.numAcceleratedWindows = 0;
|
||||
let winEnumer = Services.ww.getWindowEnumerator();
|
||||
while (winEnumer.hasMoreElements()) {
|
||||
let winUtils = winEnumer.getNext().windowUtils;
|
||||
for (let win of Services.ww.getWindowEnumerator()) {
|
||||
let winUtils = win.windowUtils;
|
||||
try {
|
||||
// NOTE: windowless browser's windows should not be reported in the graphics troubleshoot report
|
||||
if (winUtils.layerManagerType == "None" || !winUtils.layerManagerRemote) {
|
||||
|
|
|
@ -183,7 +183,7 @@ const SecurityInfo = {
|
|||
|
||||
getCertificateChain(certChain, options = {}) {
|
||||
let certificates = [];
|
||||
for (let cert of XPCOMUtils.IterSimpleEnumerator(certChain.getEnumerator(), Ci.nsIX509Cert)) {
|
||||
for (let cert of certChain.getEnumerator()) {
|
||||
certificates.push(this.parseCertificateInfo(cert, options));
|
||||
}
|
||||
return certificates;
|
||||
|
|
|
@ -24,14 +24,11 @@ const EXPORTED_SYMBOLS = ["WebNavigationFrames"];
|
|||
* A generator function which iterates over a docShell tree, given a root docShell.
|
||||
*
|
||||
* @param {nsIDocShell} docShell - the root docShell object
|
||||
* @returns {Iterator<nsIDocShell>}
|
||||
*/
|
||||
function* iterateDocShellTree(docShell) {
|
||||
let docShellsEnum = docShell.getDocShellEnumerator(
|
||||
function iterateDocShellTree(docShell) {
|
||||
return docShell.getDocShellEnumerator(
|
||||
docShell.typeContent, docShell.ENUMERATE_FORWARDS);
|
||||
|
||||
while (docShellsEnum.hasMoreElements()) {
|
||||
yield docShellsEnum.getNext().QueryInterface(Ci.nsIDocShell);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -217,9 +217,7 @@ nsUnknownContentTypeDialog.prototype = {
|
|||
// because the original one is definitely gone (and nsIFilePicker doesn't like
|
||||
// a null parent):
|
||||
gDownloadLastDir = this._mDownloadDir;
|
||||
let windowsEnum = Services.wm.getEnumerator("");
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let someWin = windowsEnum.getNext();
|
||||
for (let someWin of Services.wm.getEnumerator("")) {
|
||||
// We need to make sure we don't end up with this dialog, because otherwise
|
||||
// that's going to go away when the user clicks "Save", and that breaks the
|
||||
// windows file picker that's supposed to show up if we let the user choose
|
||||
|
|
|
@ -785,9 +785,7 @@ var AddonManagerInternal = {
|
|||
// Load any providers registered in the category manager
|
||||
let catman = Cc["@mozilla.org/categorymanager;1"].
|
||||
getService(Ci.nsICategoryManager);
|
||||
let entries = catman.enumerateCategory(CATEGORY_PROVIDER_MODULE);
|
||||
while (entries.hasMoreElements()) {
|
||||
let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;
|
||||
for (let {data: entry} of catman.enumerateCategory(CATEGORY_PROVIDER_MODULE)) {
|
||||
let url = catman.getCategoryEntry(CATEGORY_PROVIDER_MODULE, entry);
|
||||
|
||||
try {
|
||||
|
|
|
@ -1242,9 +1242,7 @@ var gViewController = {
|
|||
return;
|
||||
|
||||
let browser = getBrowserElement();
|
||||
let files = fp.files;
|
||||
while (files.hasMoreElements()) {
|
||||
let file = files.getNext();
|
||||
for (let file of fp.files) {
|
||||
let install = await AddonManager.getInstallForFile(file);
|
||||
AddonManager.installAddonFromAOM(browser, document.documentURIObject, install);
|
||||
}
|
||||
|
|
|
@ -95,10 +95,8 @@ function promiseFocus(window) {
|
|||
|
||||
// Helper to register test failures and close windows if any are left open
|
||||
function checkOpenWindows(aWindowID) {
|
||||
let windows = Services.wm.getEnumerator(aWindowID);
|
||||
let found = false;
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
|
||||
for (let win of Services.wm.getEnumerator(aWindowID)) {
|
||||
if (!win.closed) {
|
||||
found = true;
|
||||
win.close();
|
||||
|
|
|
@ -37,9 +37,7 @@ async function run_test() {
|
|||
|
||||
// Finds the test plugin library
|
||||
function get_test_plugin() {
|
||||
var pluginEnum = Services.dirsvc.get("APluginsDL", Ci.nsISimpleEnumerator);
|
||||
while (pluginEnum.hasMoreElements()) {
|
||||
let dir = pluginEnum.getNext().QueryInterface(Ci.nsIFile);
|
||||
for (let dir of Services.dirsvc.get("APluginsDL", Ci.nsISimpleEnumerator)) {
|
||||
let plugin = dir.clone();
|
||||
// OSX plugin
|
||||
plugin.append("npswftest.plugin");
|
||||
|
|
|
@ -154,9 +154,7 @@ var dialog = {
|
|||
let gIOSvc = Cc["@mozilla.org/gio-service;1"]
|
||||
.getService(Ci.nsIGIOService);
|
||||
var gioApps = gIOSvc.getAppsForURIScheme(this._URI.scheme);
|
||||
let enumerator = gioApps.enumerate();
|
||||
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 == this._handlerInfo.defaultDescription) {
|
||||
continue;
|
||||
|
|
|
@ -156,9 +156,7 @@ function checkProfileName(profileNameToCheck) {
|
|||
}
|
||||
|
||||
function profileExists(aName) {
|
||||
var profiles = gProfileService.profiles;
|
||||
while (profiles.hasMoreElements()) {
|
||||
var profile = profiles.getNext().QueryInterface(I.nsIToolkitProfile);
|
||||
for (let profile of gProfileService.profiles) {
|
||||
if (profile.name.toLowerCase() == aName.toLowerCase())
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,7 @@ function startup() {
|
|||
|
||||
var profilesElement = document.getElementById("profiles");
|
||||
|
||||
var profileList = gProfileService.profiles;
|
||||
while (profileList.hasMoreElements()) {
|
||||
var profile = profileList.getNext().QueryInterface(I.nsIToolkitProfile);
|
||||
|
||||
for (let profile of gProfileService.profiles.entries(I.nsIToolkitProfile)) {
|
||||
var listitem = profilesElement.appendItem(profile.name, "");
|
||||
|
||||
var tooltiptext =
|
||||
|
|
Загрузка…
Ссылка в новой задаче