diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index 20fa9e042768..2b1cee4029bb 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -2448,6 +2448,9 @@ void DocAccessible::DispatchScrollingEvent(uint32_t aEventType) { nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); + if (!sf) { + return; + } int32_t appUnitsPerDevPixel = mPresShell->GetPresContext()->AppUnitsPerDevPixel(); LayoutDevicePoint scrollPoint = LayoutDevicePoint::FromAppUnits( diff --git a/accessible/jsat/AccessFu.jsm b/accessible/jsat/AccessFu.jsm index 894a919476b1..ab4177fd9dbd 100644 --- a/accessible/jsat/AccessFu.jsm +++ b/accessible/jsat/AccessFu.jsm @@ -67,9 +67,8 @@ var AccessFu = { Services.obs.addObserver(this, "inprocess-browser-shown"); Services.ww.registerNotification(this); - let windows = Services.wm.getEnumerator(null); - while (windows.hasMoreElements()) { - this._attachWindow(windows.getNext()); + for (let win of Services.wm.getEnumerator(null)) { + this._attachWindow(win); } Logger.info("AccessFu:Enabled"); @@ -89,9 +88,8 @@ var AccessFu = { Services.obs.removeObserver(this, "inprocess-browser-shown"); Services.ww.unregisterNotification(this); - let windows = Services.wm.getEnumerator(null); - while (windows.hasMoreElements()) { - this._detachWindow(windows.getNext()); + for (let win of Services.wm.getEnumerator(null)) { + this._detachWindow(win); } delete this._notifyOutputPref; diff --git a/accessible/jsat/Utils.jsm b/accessible/jsat/Utils.jsm index 9d2769d80da3..c6d17095d5f0 100644 --- a/accessible/jsat/Utils.jsm +++ b/accessible/jsat/Utils.jsm @@ -160,13 +160,9 @@ var Utils = { // jshint ignore:line let attributes = {}; if (aAccessible && aAccessible.attributes) { - let attributesEnum = aAccessible.attributes.enumerate(); - // Populate |attributes| object with |aAccessible|'s attribute key-value // pairs. - while (attributesEnum.hasMoreElements()) { - let attribute = attributesEnum.getNext().QueryInterface( - Ci.nsIPropertyElement); + for (let attribute of aAccessible.attributes.enumerate()) { attributes[attribute.key] = attribute.value; } } @@ -757,9 +753,8 @@ PivotContext.prototype = { } }; let getHeaders = function* getHeaders(aHeaderCells) { - let enumerator = aHeaderCells.enumerate(); - while (enumerator.hasMoreElements()) { - yield enumerator.getNext().QueryInterface(Ci.nsIAccessible).name; + for (let {name} of aHeaderCells.enumerate(Ci.nsIAccessible)) { + yield name; } }; diff --git a/accessible/tests/browser/shared-head.js b/accessible/tests/browser/shared-head.js index 55fe7ecd7685..0c73ba455a5c 100644 --- a/accessible/tests/browser/shared-head.js +++ b/accessible/tests/browser/shared-head.js @@ -246,11 +246,8 @@ function addAccessibleTask(doc, task) { } registerCleanupFunction(() => { - let observers = Services.obs.enumerateObservers("accessible-event"); - while (observers.hasMoreElements()) { - Services.obs.removeObserver( - observers.getNext().QueryInterface(Ci.nsIObserver), - "accessible-event"); + for (let observer of Services.obs.enumerateObservers("accessible-event")) { + Services.obs.removeObserver(observer, "accessible-event"); } }); diff --git a/accessible/tests/crashtests/1484778.html b/accessible/tests/crashtests/1484778.html new file mode 100644 index 000000000000..9d3fc33f5985 --- /dev/null +++ b/accessible/tests/crashtests/1484778.html @@ -0,0 +1,26 @@ + + + + diff --git a/accessible/tests/crashtests/crashtests.list b/accessible/tests/crashtests/crashtests.list index f28c3273622e..2210d0945603 100644 --- a/accessible/tests/crashtests/crashtests.list +++ b/accessible/tests/crashtests/crashtests.list @@ -6,6 +6,7 @@ load 893515.html load 1072792.xhtml load 1380199.html load 1402999.html +load 1484778.html # last_test_to_unload_testsuite.xul MUST be the last test in the list because it # is responsible for shutting down accessibility service affecting later tests. diff --git a/accessible/tests/mochitest/attributes.js b/accessible/tests/mochitest/attributes.js index accaf66bec08..711f2623d3ff 100644 --- a/accessible/tests/mochitest/attributes.js +++ b/accessible/tests/mochitest/attributes.js @@ -319,10 +319,7 @@ function testAttrsInternal(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs, function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs, aAbsentAttrs) { // Check if all obtained attributes are expected and have expected value. - var enumerate = aAttrs.enumerate(); - while (enumerate.hasMoreElements()) { - let prop = enumerate.getNext().QueryInterface(nsIPropertyElement); - + for (let prop of aAttrs.enumerate()) { if (!(prop.key in aExpectedAttrs)) { if (!aSkipUnexpectedAttrs) ok(false, "Unexpected attribute '" + prop.key + "' having '" + @@ -355,9 +352,7 @@ function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs, for (var name in aAbsentAttrs) { var wasFound = false; - enumerate = aAttrs.enumerate(); - while (enumerate.hasMoreElements()) { - let prop = enumerate.getNext().QueryInterface(nsIPropertyElement); + for (let prop of aAttrs.enumerate()) { if (prop.key == name) wasFound = true; } diff --git a/accessible/tests/mochitest/relations.js b/accessible/tests/mochitest/relations.js index 767e468f9c42..4c4fc830925d 100644 --- a/accessible/tests/mochitest/relations.js +++ b/accessible/tests/mochitest/relations.js @@ -76,9 +76,7 @@ function testRelation(aIdentifier, aRelType, aRelatedIdentifiers) { // Check if all given related accessibles are targets of obtained relation. for (let idx = 0; idx < targets.length; idx++) { var isFound = false; - let enumerate = actualTargets.enumerate(); - while (enumerate.hasMoreElements()) { - let relatedAcc = enumerate.getNext().QueryInterface(nsIAccessible); + for (let relatedAcc of actualTargets.enumerate(Ci.nsIAccessible)) { if (targets[idx] == relatedAcc) { isFound = true; break; @@ -89,9 +87,7 @@ function testRelation(aIdentifier, aRelType, aRelatedIdentifiers) { } // Check if all obtained targets are given related accessibles. - let enumerate = actualTargets.enumerate(); - while (enumerate.hasMoreElements()) { - let relatedAcc = enumerate.getNext().QueryInterface(nsIAccessible); + for (let relatedAcc of actualTargets.enumerate(Ci.nsIAccessible)) { let idx; for (idx = 0; idx < targets.length && relatedAcc != targets[idx]; idx++); @@ -140,9 +136,7 @@ function testAbsentRelation(aIdentifier, aRelType, aUnrelatedIdentifiers) { // Any found targets that match given accessibles should be called out. for (let idx = 0; idx < targets.length; idx++) { var notFound = true; - var enumerate = actualTargets.enumerate(); - while (enumerate.hasMoreElements()) { - var relatedAcc = enumerate.getNext().QueryInterface(nsIAccessible); + for (let relatedAcc of actualTargets.enumerate(Ci.nsIAccessible)) { if (targets[idx] == relatedAcc) { notFound = false; break; diff --git a/browser/actors/NetErrorChild.jsm b/browser/actors/NetErrorChild.jsm index 2bdc279ddee3..5c3d10ac6306 100644 --- a/browser/actors/NetErrorChild.jsm +++ b/browser/actors/NetErrorChild.jsm @@ -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); } diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index b3457200cdaf..b62f57e3ba75 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -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); } } diff --git a/browser/base/content/test/about/browser_aboutCertError.js b/browser/base/content/test/about/browser_aboutCertError.js index d23a38128200..f8a99e1817a6 100644 --- a/browser/base/content/test/about/browser_aboutCertError.js +++ b/browser/base/content/test/about/browser_aboutCertError.js @@ -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; diff --git a/browser/base/content/test/general/browser_bug484315.js b/browser/base/content/test/general/browser_bug484315.js index 79ab5fdb3148..779741480b62 100644 --- a/browser/base/content/test/general/browser_bug484315.js +++ b/browser/base/content/test/general/browser_bug484315.js @@ -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(); diff --git a/browser/base/content/test/general/browser_save_link_when_window_navigates.js b/browser/base/content/test/general/browser_save_link_when_window_navigates.js index d8010074bd88..3b6c0090fc3e 100644 --- a/browser/base/content/test/general/browser_save_link_when_window_navigates.js +++ b/browser/base/content/test/general/browser_save_link_when_window_navigates.js @@ -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(); diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js index 4ddeb0c49131..36e1ddb2a1a2 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -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; } } } diff --git a/browser/base/content/test/plugins/browser_CTP_crashreporting.js b/browser/base/content/test/plugins/browser_CTP_crashreporting.js index 2772a4eb4662..b8aa1af9a5a2 100644 --- a/browser/base/content/test/plugins/browser_CTP_crashreporting.js +++ b/browser/base/content/test/plugins/browser_CTP_crashreporting.js @@ -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); } diff --git a/browser/base/content/test/siteIdentity/head.js b/browser/base/content/test/siteIdentity/head.js index c3ab3bc092de..0b9c6c945cc7 100644 --- a/browser/base/content/test/siteIdentity/head.js +++ b/browser/base/content/test/siteIdentity/head.js @@ -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; } } } diff --git a/browser/base/content/test/static/browser_misused_characters_in_strings.js b/browser/base/content/test/static/browser_misused_characters_in_strings.js index 50c4e4621370..a9d8043b2493 100644 --- a/browser/base/content/test/static/browser_misused_characters_in_strings.js +++ b/browser/base/content/test/static/browser_misused_characters_in_strings.js @@ -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); } } diff --git a/browser/base/content/test/tabcrashed/head.js b/browser/base/content/test/tabcrashed/head.js index 8a2f25014d68..c14db54dd8fb 100644 --- a/browser/base/content/test/tabcrashed/head.js +++ b/browser/base/content/test/tabcrashed/head.js @@ -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) { diff --git a/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js b/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js index 737060851c6d..985fb33cd358 100644 --- a/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js +++ b/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js @@ -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; diff --git a/browser/base/content/test/webrtc/head.js b/browser/base/content/test/webrtc/head.js index 7fb6790b3e7c..0bd80238e491 100644 --- a/browser/base/content/test/webrtc/head.js +++ b/browser/base/content/test/webrtc/head.js @@ -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); } diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index 97eea3cda9c9..6320128e3087 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -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; } diff --git a/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js b/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js index 4baa015263bf..ef773ac02fcb 100644 --- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js +++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js @@ -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); } diff --git a/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js b/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js index 1e9bcbbebc3c..485d2da726dc 100644 --- a/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js +++ b/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js @@ -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); } diff --git a/browser/components/customizableui/PanelMultiView.jsm b/browser/components/customizableui/PanelMultiView.jsm index a242de3b6138..6b2d195abe6e 100644 --- a/browser/components/customizableui/PanelMultiView.jsm +++ b/browser/components/customizableui/PanelMultiView.jsm @@ -516,6 +516,15 @@ var PanelMultiView = class extends AssociatedToNode { try { canCancel = false; this._panel.openPopup(...args); + + // On Windows, if another popup is hiding while we call openPopup, the + // call won't fail but the popup won't open. In this case, we have to + // dispatch an artificial "popuphidden" event to reset our state. + if (this._panel.state == "closed" && this.openViews.length) { + this.dispatchCustomEvent("popuphidden"); + return false; + } + return true; } catch (ex) { this.dispatchCustomEvent("popuphidden"); @@ -1056,8 +1065,10 @@ var PanelMultiView = class extends AssociatedToNode { } handleEvent(aEvent) { - if (aEvent.type.startsWith("popup") && aEvent.target != this._panel) { - // Shouldn't act on e.g. context menus being shown from within the panel. + // Only process actual popup events from the panel or events we generate + // ourselves, but not from menus being shown from within the panel. + if (aEvent.type.startsWith("popup") && aEvent.target != this._panel && + aEvent.target != this.node) { return; } switch (aEvent.type) { diff --git a/browser/components/customizableui/test/browser.ini b/browser/components/customizableui/test/browser.ini index 0947cf716551..3ce405ba5820 100644 --- a/browser/components/customizableui/test/browser.ini +++ b/browser/components/customizableui/test/browser.ini @@ -144,6 +144,7 @@ skip-if = os == "mac" [browser_1096763_seen_widgets_post_reset.js] [browser_1161838_inserted_new_default_buttons.js] skip-if = verify +[browser_1484275_PanelMultiView_toggle_with_other_popup.js] [browser_allow_dragging_removable_false.js] [browser_bootstrapped_custom_toolbar.js] [browser_currentset_post_reset.js] diff --git a/browser/components/customizableui/test/browser_1484275_PanelMultiView_toggle_with_other_popup.js b/browser/components/customizableui/test/browser_1484275_PanelMultiView_toggle_with_other_popup.js new file mode 100644 index 000000000000..d3e0e1f49124 --- /dev/null +++ b/browser/components/customizableui/test/browser_1484275_PanelMultiView_toggle_with_other_popup.js @@ -0,0 +1,87 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const TEST_URL = "data:text/html,"; + +// This code can be consolidated in the EventUtils module (bug 1126772). +const isWindows = AppConstants.platform == "win"; +const isMac = AppConstants.platform == "macosx"; +const mouseDown = isWindows ? 2 : isMac ? 1 : 4; // eslint-disable-line no-nested-ternary +const mouseUp = isWindows ? 4 : isMac ? 2 : 7; // eslint-disable-line no-nested-ternary +const utils = window.windowUtils; +const scale = utils.screenPixelsPerCSSPixel; +function synthesizeNativeMouseClick(aElement) { + let rect = aElement.getBoundingClientRect(); + let win = aElement.ownerGlobal; + let x = win.mozInnerScreenX + (rect.left + rect.right) / 2; + let y = win.mozInnerScreenY + (rect.top + rect.bottom) / 2; + + // Wait for the mouseup event to occur before continuing. + return new Promise((resolve, reject) => { + function eventOccurred(e) { + aElement.removeEventListener("mouseup", eventOccurred, true); + resolve(); + } + + aElement.addEventListener("mouseup", eventOccurred, true); + + utils.sendNativeMouseEvent(x * scale, y * scale, mouseDown, 0, null); + utils.sendNativeMouseEvent(x * scale, y * scale, mouseUp, 0, null); + }); +} + +/** + * Test steps that may lead to the panel being stuck on Windows (bug 1484275). + */ +add_task(async function test_PanelMultiView_toggle_with_other_popup() { + // For proper cleanup, create a bookmark that we will remove later. + let bookmark = await PlacesUtils.bookmarks.insert({ + parentGuid: PlacesUtils.bookmarks.unfiledGuid, + url: TEST_URL, + }); + registerCleanupFunction(() => PlacesUtils.bookmarks.remove(bookmark)); + + await BrowserTestUtils.withNewTab({ + gBrowser, + url: TEST_URL, + }, async function(browser) { + // 1. Open the main menu. + await gCUITestUtils.openMainMenu(); + + // 2. Open another popup not managed by PanelMultiView. + let bookmarkPanel = document.getElementById("editBookmarkPanel"); + let shown = BrowserTestUtils.waitForEvent(bookmarkPanel, "popupshown"); + let hidden = BrowserTestUtils.waitForEvent(bookmarkPanel, "popuphidden"); + EventUtils.synthesizeKey("D", { accelKey: true }); + await shown; + + // 3. Click the button to which the main menu is anchored. We need a native + // mouse event to simulate the exact platform behavior with popups. + let clickFn = () => synthesizeNativeMouseClick( + document.getElementById("PanelUI-button")); + + if (AppConstants.platform == "win") { + // On Windows, the operation will close both popups. + await gCUITestUtils.hidePanelMultiView(PanelUI.panel, clickFn); + await new Promise(resolve => executeSoon(resolve)); + + // 4. Test that the popup can be opened again after it's been closed. + await gCUITestUtils.openMainMenu(); + Assert.equal(PanelUI.panel.state, "open"); + } else { + // On other platforms, the operation will close both popups and reopen the + // main menu immediately, so we wait for the reopen to occur. + shown = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown"); + clickFn(); + await shown; + } + + await gCUITestUtils.hideMainMenu(); + + // Make sure the events for the bookmarks panel have also been processed + // before closing the tab and removing the bookmark. + await hidden; + }); +}); diff --git a/browser/components/customizableui/test/browser_PanelMultiView.js b/browser/components/customizableui/test/browser_PanelMultiView.js index f8cb0d2276ec..54fe4c691f19 100644 --- a/browser/components/customizableui/test/browser_PanelMultiView.js +++ b/browser/components/customizableui/test/browser_PanelMultiView.js @@ -406,6 +406,7 @@ add_task(async function test_cancel_mainview_event_sequence() { Assert.deepEqual(recordArray, [ "panelview-0: ViewShowing", "panelview-0: ViewHiding", + "panelmultiview-0: PanelMultiViewHidden", "panelmultiview-0: popuphidden", ]); }); @@ -475,8 +476,9 @@ add_task(async function test_close_while_showing_mainview_event_sequence() { Assert.deepEqual(recordArray, [ "panelview-0: ViewShowing", - "panelview-0: ViewShowing > panelmultiview-0: popuphidden", "panelview-0: ViewShowing > panelview-0: ViewHiding", + "panelview-0: ViewShowing > panelmultiview-0: PanelMultiViewHidden", + "panelview-0: ViewShowing > panelmultiview-0: popuphidden", ]); }); diff --git a/browser/components/dirprovider/DirectoryProvider.cpp b/browser/components/dirprovider/DirectoryProvider.cpp index e711ccbcc019..4dde0ef92ee1 100644 --- a/browser/components/dirprovider/DirectoryProvider.cpp +++ b/browser/components/dirprovider/DirectoryProvider.cpp @@ -140,14 +140,12 @@ DirectoryProvider::GetFiles(const char *aKey, nsISimpleEnumerator* *aResult) nsCOMArray distroFiles; AppendDistroSearchDirs(dirSvc, distroFiles); - return NS_NewArrayEnumerator(aResult, distroFiles); + return NS_NewArrayEnumerator(aResult, distroFiles, NS_GET_IID(nsIFile)); } return NS_ERROR_FAILURE; } -NS_IMPL_ISUPPORTS(DirectoryProvider::AppendingEnumerator, nsISimpleEnumerator) - NS_IMETHODIMP DirectoryProvider::AppendingEnumerator::HasMoreElements(bool *aResult) { diff --git a/browser/components/dirprovider/DirectoryProvider.h b/browser/components/dirprovider/DirectoryProvider.h index 43fa85ab9387..138546ecee7d 100644 --- a/browser/components/dirprovider/DirectoryProvider.h +++ b/browser/components/dirprovider/DirectoryProvider.h @@ -7,8 +7,8 @@ #include "nsIDirectoryService.h" #include "nsComponentManagerUtils.h" -#include "nsISimpleEnumerator.h" #include "nsIFile.h" +#include "nsSimpleEnumerator.h" #include "mozilla/Attributes.h" #define NS_BROWSERDIRECTORYPROVIDER_CONTRACTID \ @@ -27,17 +27,16 @@ public: private: ~DirectoryProvider() {} - class AppendingEnumerator final : public nsISimpleEnumerator + class AppendingEnumerator final : public nsSimpleEnumerator { public: - NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR AppendingEnumerator(nsISimpleEnumerator* aBase, char const *const *aAppendList); private: - ~AppendingEnumerator() {} + ~AppendingEnumerator() override = default; nsCOMPtr mBase; char const *const *const mAppendList; diff --git a/browser/components/downloads/DownloadsCommon.jsm b/browser/components/downloads/DownloadsCommon.jsm index 3c60e0e4e072..d4401cb516bb 100644 --- a/browser/components/downloads/DownloadsCommon.jsm +++ b/browser/components/downloads/DownloadsCommon.jsm @@ -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() { diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js index 01fc3971fe6e..9877abf36ce5 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js @@ -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, diff --git a/browser/components/extensions/parent/ext-browsingData.js b/browser/components/extensions/parent/ext-browsingData.js index ad1ec81fa8e0..8b6f811d2b11 100644 --- a/browser/components/extensions/parent/ext-browsingData.js +++ b/browser/components/extensions/parent/ext-browsingData.js @@ -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. diff --git a/browser/components/extensions/parent/ext-pkcs11.js b/browser/components/extensions/parent/ext-pkcs11.js index 827acf3b9d4a..a40acc718263 100644 --- a/browser/components/extensions/parent/ext-pkcs11.js +++ b/browser/components/extensions/parent/ext-pkcs11.js @@ -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, diff --git a/browser/components/extensions/parent/ext-tabs.js b/browser/components/extensions/parent/ext-tabs.js index 7d7d605e6db1..b8176e6ecf03 100644 --- a/browser/components/extensions/parent/ext-tabs.js +++ b/browser/components/extensions/parent/ext-tabs.js @@ -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; } diff --git a/browser/components/extensions/test/browser/browser-common.ini b/browser/components/extensions/test/browser/browser-common.ini index 450ff262d5fb..b7f18fceeaf8 100644 --- a/browser/components/extensions/test/browser/browser-common.ini +++ b/browser/components/extensions/test/browser/browser-common.ini @@ -28,6 +28,8 @@ support-files = file_inspectedwindow_reload_target.sjs file_indexedDB.html file_serviceWorker.html + install_other-1.0-fx.xpi + install_theme-1.0-fx.xpi webNav_createdTarget.html webNav_createdTargetSource.html webNav_createdTargetSource_subframe.html @@ -105,6 +107,7 @@ skip-if = (verify && (os == 'linux' || os == 'mac')) [browser_ext_incognito_views.js] [browser_ext_incognito_popup.js] [browser_ext_lastError.js] +[browser_ext_management.js] [browser_ext_menus.js] [browser_ext_menus_accesskey.js] [browser_ext_menus_activeTab.js] diff --git a/browser/components/extensions/test/browser/browser_ext_management.js b/browser/components/extensions/test/browser/browser_ext_management.js new file mode 100644 index 000000000000..5252f7a4a028 --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_management.js @@ -0,0 +1,80 @@ +"use strict"; + +const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/"; + +function waitForTransition(element, propertyName) { + return BrowserTestUtils.waitForEvent(element, "transitionend", false, event => { + return event.target == element && event.propertyName == propertyName; + }); +} + +add_task(async function test_management_install() { + await SpecialPowers.pushPrefEnv({set: [ + ["xpinstall.signatures.required", false], + ]}); + + registerCleanupFunction(async () => { + await SpecialPowers.popPrefEnv(); + }); + + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + browser_action: { + "browser_style": false, + }, + permissions: ["management"], + }, + background() { + let addons; + browser.test.onMessage.addListener((msg, init) => { + addons = init; + browser.test.sendMessage("ready"); + }); + browser.browserAction.onClicked.addListener(async () => { + try { + let {url, hash} = addons.shift(); + browser.test.log(`Installing XPI from ${url} with hash ${hash || "missing"}`); + let {id} = await browser.management.install({url, hash}); + let {type} = await browser.management.get(id); + browser.test.sendMessage("installed", {id, type}); + } catch (e) { + browser.test.log(`management.install() throws ${e}`); + browser.test.sendMessage("failed", e.message); + } + }); + }, + }); + + let addons = [{ + url: BASE + "install_theme-1.0-fx.xpi", + hash: "sha256:aa232d8391d82a9c1014364efbe1657ff6d8dfc88b3c71e99881b1f3843fdad3", + }, { + url: BASE + "install_other-1.0-fx.xpi", + }]; + + await extension.startup(); + extension.sendMessage("addons", addons); + await extension.awaitMessage("ready"); + + // Test installing a static WE theme. + let transitionDone = waitForTransition(document.documentElement, "background-color"); + clickBrowserAction(extension); + + let {id, type} = await extension.awaitMessage("installed"); + is(id, "tiger@persona.beard", "Static web extension theme installed"); + is(type, "theme", "Extension type is correct"); + + await transitionDone; + let style = window.getComputedStyle(document.documentElement); + is(style.backgroundColor, "rgb(255, 165, 0)", "Background is the new black"); + + let addon = await AddonManager.getAddonByID("tiger@persona.beard"); + await addon.uninstall(); + + // Test installing a standard WE. + clickBrowserAction(extension); + let error = await extension.awaitMessage("failed"); + is(error, "Incompatible addon", "Standard web extension rejected"); + + await extension.unload(); +}); diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index f0204f810b36..854d56e8d885 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -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; } diff --git a/browser/components/extensions/test/browser/install_other-1.0-fx.xpi b/browser/components/extensions/test/browser/install_other-1.0-fx.xpi new file mode 100644 index 000000000000..66be85efd590 Binary files /dev/null and b/browser/components/extensions/test/browser/install_other-1.0-fx.xpi differ diff --git a/browser/components/extensions/test/browser/install_theme-1.0-fx.xpi b/browser/components/extensions/test/browser/install_theme-1.0-fx.xpi new file mode 100644 index 000000000000..0ef2b3d67222 Binary files /dev/null and b/browser/components/extensions/test/browser/install_theme-1.0-fx.xpi differ diff --git a/browser/components/migration/AutoMigrate.jsm b/browser/components/migration/AutoMigrate.jsm index a54d0df1fc6f..d8c141facbbe 100644 --- a/browser/components/migration/AutoMigrate.jsm +++ b/browser/components/migration/AutoMigrate.jsm @@ -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); diff --git a/browser/components/migration/FirefoxProfileMigrator.js b/browser/components/migration/FirefoxProfileMigrator.js index 38fef70aa804..a7151f6fabb2 100644 --- a/browser/components/migration/FirefoxProfileMigrator.js +++ b/browser/components/migration/FirefoxProfileMigrator.js @@ -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() && diff --git a/browser/components/migration/IEProfileMigrator.js b/browser/components/migration/IEProfileMigrator.js index ff258d4e1983..2a22ffc0b939 100644 --- a/browser/components/migration/IEProfileMigrator.js +++ b/browser/components/migration/IEProfileMigrator.js @@ -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 diff --git a/browser/components/migration/nsIEHistoryEnumerator.cpp b/browser/components/migration/nsIEHistoryEnumerator.cpp index 116e9a860860..ba1fe4c5d204 100644 --- a/browser/components/migration/nsIEHistoryEnumerator.cpp +++ b/browser/components/migration/nsIEHistoryEnumerator.cpp @@ -19,8 +19,6 @@ //////////////////////////////////////////////////////////////////////////////// //// nsIEHistoryEnumerator -NS_IMPL_ISUPPORTS(nsIEHistoryEnumerator, nsISimpleEnumerator) - nsIEHistoryEnumerator::nsIEHistoryEnumerator() { ::CoInitialize(nullptr); diff --git a/browser/components/migration/nsIEHistoryEnumerator.h b/browser/components/migration/nsIEHistoryEnumerator.h index 1572a8dd5b8d..2e28c816d978 100644 --- a/browser/components/migration/nsIEHistoryEnumerator.h +++ b/browser/components/migration/nsIEHistoryEnumerator.h @@ -9,19 +9,23 @@ #include "mozilla/Attributes.h" #include "nsCOMPtr.h" -#include "nsISimpleEnumerator.h" #include "nsIWritablePropertyBag2.h" +#include "nsSimpleEnumerator.h" -class nsIEHistoryEnumerator final : public nsISimpleEnumerator +class nsIEHistoryEnumerator final : public nsSimpleEnumerator { public: - NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR nsIEHistoryEnumerator(); + const nsID& DefaultInterface() override + { + return NS_GET_IID(nsIWritablePropertyBag2); + } + private: - ~nsIEHistoryEnumerator(); + ~nsIEHistoryEnumerator() override; /** * Initializes the history reader, if needed. diff --git a/browser/components/migration/tests/unit/test_fx_telemetry.js b/browser/components/migration/tests/unit/test_fx_telemetry.js index 556a8b33ba61..43d1c96e50f4 100644 --- a/browser/components/migration/tests/unit/test_fx_telemetry.js +++ b/browser/components/migration/tests/unit/test_fx_telemetry.js @@ -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"); diff --git a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm index 7241ec87e93b..0d99f9113960 100644 --- a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm +++ b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm @@ -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; } diff --git a/browser/components/newtab/lib/Screenshots.jsm b/browser/components/newtab/lib/Screenshots.jsm index 541eb3c8bbc2..58a1fac2f154 100644 --- a/browser/components/newtab/lib/Screenshots.jsm +++ b/browser/components/newtab/lib/Screenshots.jsm @@ -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; } diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index 96692f6b9221..1f2234879bd4 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -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; diff --git a/browser/components/originattributes/test/browser/browser_firstPartyIsolation.js b/browser/components/originattributes/test/browser/browser_firstPartyIsolation.js index 06bc21255a94..da45c95ce3e5 100644 --- a/browser/components/originattributes/test/browser/browser_firstPartyIsolation.js +++ b/browser/components/originattributes/test/browser/browser_firstPartyIsolation.js @@ -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); } diff --git a/browser/components/payments/paymentUIService.js b/browser/components/payments/paymentUIService.js index 56e8e0a7f13a..d6d2649aafb7 100644 --- a/browser/components/payments/paymentUIService.js +++ b/browser/components/payments/paymentUIService.js @@ -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; } diff --git a/browser/components/payments/test/browser/head.js b/browser/components/payments/test/browser/head.js index 3f67d2f95f95..257074e46364 100644 --- a/browser/components/payments/test/browser/head.js +++ b/browser/components/payments/test/browser/head.js @@ -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()); } /** diff --git a/browser/components/preferences/applicationManager.js b/browser/components/preferences/applicationManager.js index ea1419907b1b..f52caef40041 100644 --- a/browser/components/preferences/applicationManager.js +++ b/browser/components/preferences/applicationManager.js @@ -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("")); diff --git a/browser/components/preferences/in-content/main.js b/browser/components/preferences/in-content/main.js index 3c455a991e36..d42faac78350 100644 --- a/browser/components/preferences/in-content/main.js +++ b/browser/components/preferences/in-content/main.js @@ -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); diff --git a/browser/components/preferences/languages.js b/browser/components/preferences/languages.js index 2062630d3e57..08594fbd5008 100644 --- a/browser/components/preferences/languages.js +++ b/browser/components/preferences/languages.js @@ -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]); diff --git a/browser/components/preferences/permissions.js b/browser/components/preferences/permissions.js index 46ecfb52db59..27e231c0f9c6 100644 --- a/browser/components/preferences/permissions.js +++ b/browser/components/preferences/permissions.js @@ -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); } }, diff --git a/browser/components/preferences/sitePermissions.js b/browser/components/preferences/sitePermissions.js index fcf2e09cbc20..5a470bc60b99 100644 --- a/browser/components/preferences/sitePermissions.js +++ b/browser/components/preferences/sitePermissions.js @@ -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); } }, diff --git a/browser/components/preferences/translation.js b/browser/components/preferences/translation.js index 9080802bc5d1..a0fc3efb6696 100644 --- a/browser/components/preferences/translation.js +++ b/browser/components/preferences/translation.js @@ -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); diff --git a/browser/components/sessionstore/SessionCookies.jsm b/browser/components/sessionstore/SessionCookies.jsm index bf944d7b51e7..2e26b2767d5f 100644 --- a/browser/components/sessionstore/SessionCookies.jsm +++ b/browser/components/sessionstore/SessionCookies.jsm @@ -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); } } }; diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 3c707f8601f3..ec6f26ba6aad 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -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)); } diff --git a/browser/components/sessionstore/test/browser_354894_perwindowpb.js b/browser/components/sessionstore/test/browser_354894_perwindowpb.js index 6f7b483bceb1..b9641be1fc67 100644 --- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js +++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js @@ -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; } diff --git a/browser/components/sessionstore/test/browser_423132.js b/browser/components/sessionstore/test/browser_423132.js index e44eea1df73e..1ca79a931f7d 100644 --- a/browser/components/sessionstore/test/browser_423132.js +++ b/browser/components/sessionstore/test/browser_423132.js @@ -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; } diff --git a/browser/components/sessionstore/test/browser_526613.js b/browser/components/sessionstore/test/browser_526613.js index dbf6a37dd8e1..85a7af51865f 100644 --- a/browser/components/sessionstore/test/browser_526613.js +++ b/browser/components/sessionstore/test/browser_526613.js @@ -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, diff --git a/browser/components/sessionstore/test/browser_528776.js b/browser/components/sessionstore/test/browser_528776.js index d2b69ec63760..72586be64e69 100644 --- a/browser/components/sessionstore/test/browser_528776.js +++ b/browser/components/sessionstore/test/browser_528776.js @@ -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, diff --git a/browser/components/sessionstore/test/browser_600545.js b/browser/components/sessionstore/test/browser_600545.js index ceceef9b0b01..b53c5b520bd9 100644 --- a/browser/components/sessionstore/test/browser_600545.js +++ b/browser/components/sessionstore/test/browser_600545.js @@ -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)); } diff --git a/browser/components/sessionstore/test/browser_618151.js b/browser/components/sessionstore/test/browser_618151.js index 85e49c3aa255..a8f89fc50913 100644 --- a/browser/components/sessionstore/test/browser_618151.js +++ b/browser/components/sessionstore/test/browser_618151.js @@ -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)); } diff --git a/browser/components/sessionstore/test/browser_636279.js b/browser/components/sessionstore/test/browser_636279.js index 5102bd9459cc..0890cd73800c 100644 --- a/browser/components/sessionstore/test/browser_636279.js +++ b/browser/components/sessionstore/test/browser_636279.js @@ -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; diff --git a/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js b/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js index de21a947b353..6d916eb23587 100644 --- a/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js +++ b/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js @@ -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++; } diff --git a/browser/components/sessionstore/test/head.js b/browser/components/sessionstore/test/head.js index 51a12b8791e3..5790c1d5254a 100644 --- a/browser/components/sessionstore/test/head.js +++ b/browser/components/sessionstore/test/head.js @@ -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; } diff --git a/browser/components/translation/test/browser_translation_exceptions.js b/browser/components/translation/test/browser_translation_exceptions.js index fb3d7795ec7e..07fdeb6155a1 100644 --- a/browser/components/translation/test/browser_translation_exceptions.js +++ b/browser/components/translation/test/browser_translation_exceptions.js @@ -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); diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index 8008a3158e8c..b3f3cd36eff9 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -652,9 +652,7 @@ var UITour = { // The browser message manager is disconnected when the 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; diff --git a/browser/components/uitour/test/browser_UITour_modalDialog.js b/browser/components/uitour/test/browser_UITour_modalDialog.js index ab826e4109fc..42d87b1ff294 100644 --- a/browser/components/uitour/test/browser_UITour_modalDialog.js +++ b/browser/components/uitour/test/browser_UITour_modalDialog.js @@ -47,24 +47,16 @@ function getDialogDoc() { // through all the open windows and all the 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") diff --git a/browser/extensions/formautofill/api.js b/browser/extensions/formautofill/api.js index 2dfbd54063f8..85ad442f064a 100644 --- a/browser/extensions/formautofill/api.js +++ b/browser/extensions/formautofill/api.js @@ -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; diff --git a/browser/extensions/formautofill/test/unit/head.js b/browser/extensions/formautofill/test/unit/head.js index f0d4c7fd5af1..cad8bbbafe23 100644 --- a/browser/extensions/formautofill/test/unit/head.js +++ b/browser/extensions/formautofill/test/unit/head.js @@ -36,6 +36,7 @@ Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", const EXTENSION_ID = "formautofill@mozilla.org"; AddonTestUtils.init(this); +AddonTestUtils.overrideCertDB(); async function loadExtension() { AddonTestUtils.createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); diff --git a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm index 7e50b5b7aac4..386df8a9ec4b 100644 --- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -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) { diff --git a/browser/extensions/pocket/bootstrap.js b/browser/extensions/pocket/bootstrap.js index c88b403a592a..46cdd5c87fec 100644 --- a/browser/extensions/pocket/bootstrap.js +++ b/browser/extensions/pocket/bootstrap.js @@ -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"); } diff --git a/browser/extensions/pocket/content/main.js b/browser/extensions/pocket/content/main.js index 71adcd23426c..040c823066e7 100644 --- a/browser/extensions/pocket/content/main.js +++ b/browser/extensions/pocket/content/main.js @@ -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 diff --git a/browser/extensions/pocket/content/pktApi.jsm b/browser/extensions/pocket/content/pktApi.jsm index 25bae563a29b..fee16b0e1994 100644 --- a/browser/extensions/pocket/content/pktApi.jsm +++ b/browser/extensions/pocket/content/pktApi.jsm @@ -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; diff --git a/browser/modules/BrowserUsageTelemetry.jsm b/browser/modules/BrowserUsageTelemetry.jsm index c5c832b8629c..bb8eafd837b6 100644 --- a/browser/modules/BrowserUsageTelemetry.jsm +++ b/browser/modules/BrowserUsageTelemetry.jsm @@ -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. diff --git a/browser/modules/BrowserWindowTracker.jsm b/browser/modules/BrowserWindowTracker.jsm index a4dccb7dc793..a010a439984c 100644 --- a/browser/modules/BrowserWindowTracker.jsm +++ b/browser/modules/BrowserWindowTracker.jsm @@ -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; } diff --git a/browser/modules/ContentCrashHandlers.jsm b/browser/modules/ContentCrashHandlers.jsm index f3fadc46b10b..c33b5f804b89 100644 --- a/browser/modules/ContentCrashHandlers.jsm +++ b/browser/modules/ContentCrashHandlers.jsm @@ -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 }); diff --git a/browser/modules/PageActions.jsm b/browser/modules/PageActions.jsm index f09f4f962bfd..2a3d33448035 100644 --- a/browser/modules/PageActions.jsm +++ b/browser/modules/PageActions.jsm @@ -1204,10 +1204,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"); } /** diff --git a/browser/modules/ProcessHangMonitor.jsm b/browser/modules/ProcessHangMonitor.jsm index e6f6d1a3a7b7..12599f95fc75 100644 --- a/browser/modules/ProcessHangMonitor.jsm +++ b/browser/modules/ProcessHangMonitor.jsm @@ -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. diff --git a/browser/modules/Sanitizer.jsm b/browser/modules/Sanitizer.jsm index 534b8b4c2428..a4fed5f65014 100644 --- a/browser/modules/Sanitizer.jsm +++ b/browser/modules/Sanitizer.jsm @@ -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); } diff --git a/browser/modules/SavantShieldStudy.jsm b/browser/modules/SavantShieldStudy.jsm index 6d2d20f2d797..9a29dae41a7c 100644 --- a/browser/modules/SavantShieldStudy.jsm +++ b/browser/modules/SavantShieldStudy.jsm @@ -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) { diff --git a/browser/modules/SiteDataManager.jsm b/browser/modules/SiteDataManager.jsm index 9e08e00c38c5..91f88aaadf3c 100644 --- a/browser/modules/SiteDataManager.jsm +++ b/browser/modules/SiteDataManager.jsm @@ -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) { diff --git a/browser/modules/WindowsPreviewPerTab.jsm b/browser/modules/WindowsPreviewPerTab.jsm index ad029caee749..fccf1ce14e17 100644 --- a/browser/modules/WindowsPreviewPerTab.jsm +++ b/browser/modules/WindowsPreviewPerTab.jsm @@ -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); } diff --git a/browser/modules/test/browser/head.js b/browser/modules/test/browser/head.js index 26ff653c26d1..cd3732bc01bf 100644 --- a/browser/modules/test/browser/head.js +++ b/browser/modules/test/browser/head.js @@ -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); diff --git a/browser/modules/webrtcUI.jsm b/browser/modules/webrtcUI.jsm index a479beaf3731..2959ffdd1b23 100644 --- a/browser/modules/webrtcUI.jsm +++ b/browser/modules/webrtcUI.jsm @@ -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 { diff --git a/build/autoconf/frameptr.m4 b/build/autoconf/frameptr.m4 index e7e50330eea5..4efe32c3be18 100644 --- a/build/autoconf/frameptr.m4 +++ b/build/autoconf/frameptr.m4 @@ -30,13 +30,15 @@ AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [ fi # If we are debugging, profiling, using sanitizers, or on win32 we want a - # frame pointer. + # frame pointer. It is not required to enable frame pointers on AArch64 + # Windows, but we enable it for compatibility with ETW. if test -z "$MOZ_OPTIMIZE" -o \ -n "$MOZ_PROFILING" -o \ -n "$MOZ_DEBUG" -o \ -n "$MOZ_MSAN" -o \ -n "$MOZ_ASAN" -o \ - "$OS_ARCH:$CPU_ARCH" = "WINNT:x86"; then + "$OS_ARCH:$CPU_ARCH" = "WINNT:x86" -o \ + "$OS_ARCH:$CPU_ARCH" = "WINNT:aarch64"; then MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR" else MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR" diff --git a/build/build-clang/clang-7-pre-linux64.json b/build/build-clang/clang-7-pre-linux64.json index 75032df694d3..a201218b4056 100644 --- a/build/build-clang/clang-7-pre-linux64.json +++ b/build/build-clang/clang-7-pre-linux64.json @@ -1,15 +1,15 @@ { - "llvm_revision": "338869", + "llvm_revision": "340494", "stages": "3", "build_libcxx": true, "build_type": "Release", "assertions": false, - "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_700/rc1", - "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_700/rc1", - "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_700/rc1", - "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_700/rc1", - "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_700/rc1", - "libcxxabi_repo": "https://llvm.org/svn/llvm-project/libcxxabi/tags/RELEASE_700/rc1", + "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_700/rc2", + "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_700/rc2", + "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_700/rc2", + "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_700/rc2", + "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_700/rc2", + "libcxxabi_repo": "https://llvm.org/svn/llvm-project/libcxxabi/tags/RELEASE_700/rc2", "python_path": "/usr/bin/python2.7", "gcc_dir": "/builds/worker/workspace/build/src/gcc", "cc": "/builds/worker/workspace/build/src/gcc/bin/gcc", @@ -17,7 +17,6 @@ "as": "/builds/worker/workspace/build/src/gcc/bin/gcc", "patches": [ "find_symbolizer_linux.patch", - "rename_gcov_flush.patch", - "r339636.patch" + "rename_gcov_flush.patch" ] } diff --git a/build/build-clang/clang-7-pre-mingw.json b/build/build-clang/clang-7-pre-mingw.json index ce89196543f2..3132dbcc0170 100644 --- a/build/build-clang/clang-7-pre-mingw.json +++ b/build/build-clang/clang-7-pre-mingw.json @@ -1,21 +1,18 @@ { - "llvm_revision": "338869", + "llvm_revision": "340494", "stages": "3", "build_libcxx": true, "build_type": "Release", "assertions": false, - "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_700/rc1", - "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_700/rc1", - "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_700/rc1", - "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_700/rc1", - "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_700/rc1", - "libcxxabi_repo": "https://llvm.org/svn/llvm-project/libcxxabi/tags/RELEASE_700/rc1", + "llvm_repo": "https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_700/rc2", + "clang_repo": "https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_700/rc2", + "lld_repo": "https://llvm.org/svn/llvm-project/lld/tags/RELEASE_700/rc2", + "compiler_repo": "https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_700/rc2", + "libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_700/rc2", + "libcxxabi_repo": "https://llvm.org/svn/llvm-project/libcxxabi/tags/RELEASE_700/rc2", "python_path": "/usr/bin/python2.7", "gcc_dir": "/builds/worker/workspace/build/src/gcc", "cc": "/builds/worker/workspace/build/src/gcc/bin/gcc", "cxx": "/builds/worker/workspace/build/src/gcc/bin/g++", - "as": "/builds/worker/workspace/build/src/gcc/bin/gcc", - "patches": [ - "r339636.patch" - ] + "as": "/builds/worker/workspace/build/src/gcc/bin/gcc" } diff --git a/build/unix/mozconfig.lto b/build/unix/mozconfig.lto index d825ac6158a7..c62104f8c857 100644 --- a/build/unix/mozconfig.lto +++ b/build/unix/mozconfig.lto @@ -17,5 +17,8 @@ if [ -e "$topsrcdir/gcc/bin/ld" ]; then fi ac_add_options --enable-lto +# Until it's either made the default or we figure a way to remove the +# copy locations that LTO induces in non-PIE executables. +ac_add_options --enable-pie . "$topsrcdir/build/unix/mozconfig.stdcxx" diff --git a/devtools/client/debugger/new/src/actions/expressions.js b/devtools/client/debugger/new/src/actions/expressions.js index 2ccb0317ee39..52ca43c3648f 100644 --- a/devtools/client/debugger/new/src/actions/expressions.js +++ b/devtools/client/debugger/new/src/actions/expressions.js @@ -217,9 +217,15 @@ function getMappedExpression(expression) { sourceMaps }) { const mappings = (0, _selectors.getSelectedScopeMappings)(getState()); - const bindings = (0, _selectors.getSelectedFrameBindings)(getState()); + const bindings = (0, _selectors.getSelectedFrameBindings)(getState()); // We bail early if we do not need to map the expression. This is important + // because mapping an expression can be slow if the parser worker is + // busy doing other work. + // + // 1. there are no mappings - we do not need to map original expressions + // 2. does not contain `await` - we do not need to map top level awaits + // 3. does not contain `=` - we do not need to map assignments - if (!mappings && !bindings && !expression.includes("await")) { + if (!mappings && !expression.match(/(await|=)/)) { return expression; } diff --git a/devtools/client/debugger/new/src/reducers/pause.js b/devtools/client/debugger/new/src/reducers/pause.js index 47d7dffe7f03..516529751cf7 100644 --- a/devtools/client/debugger/new/src/reducers/pause.js +++ b/devtools/client/debugger/new/src/reducers/pause.js @@ -410,12 +410,20 @@ function getFrameScope(state, sourceId, frameId) { } function getSelectedScope(state) { - const sourceRecord = (0, _sources.getSelectedSource)(state); + const source = (0, _sources.getSelectedSource)(state); const frameId = getSelectedFrameId(state); - const { - scope - } = getFrameScope(state, sourceRecord && sourceRecord.id, frameId) || {}; - return scope || null; + + if (!source) { + return null; + } + + const frameScope = getFrameScope(state, source.id, frameId); + + if (!frameScope) { + return null; + } + + return frameScope.scope || null; } function getSelectedScopeMappings(state) { diff --git a/devtools/client/debugger/new/test/mochitest/browser_dbg-preview-source-maps.js b/devtools/client/debugger/new/test/mochitest/browser_dbg-preview-source-maps.js index b6b37c1331fc..277ac7757802 100644 --- a/devtools/client/debugger/new/test/mochitest/browser_dbg-preview-source-maps.js +++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-preview-source-maps.js @@ -49,7 +49,7 @@ add_task(async function() { info(`Test previewing in the original location`); await assertPreviews(dbg, [ - { line: 2, column: 10, result: 4, expression: "x;" } + { line: 2, column: 10, result: 4, expression: "x" } ]); info(`Test previewing in the generated location`); diff --git a/devtools/client/framework/devtools-browser.js b/devtools/client/framework/devtools-browser.js index e3e0a995d563..54a1377f84fa 100644 --- a/devtools/client/framework/devtools-browser.js +++ b/devtools/client/framework/devtools-browser.js @@ -743,9 +743,7 @@ Services.obs.addObserver(gDevToolsBrowser, "devtools:loader:destroy"); // Fake end of browser window load event for all already opened windows // that is already fully loaded. -const enumerator = Services.wm.getEnumerator(gDevTools.chromeWindowType); -while (enumerator.hasMoreElements()) { - const win = enumerator.getNext(); +for (const win of Services.wm.getEnumerator(gDevTools.chromeWindowType)) { if (win.gBrowserInit && win.gBrowserInit.delayedStartupFinished) { gDevToolsBrowser._registerBrowserWindow(win); } diff --git a/devtools/client/framework/test/browser_toolbox_dynamic_registration.js b/devtools/client/framework/test/browser_toolbox_dynamic_registration.js index 8be72b6a5afa..c605a63ce5e7 100644 --- a/devtools/client/framework/test/browser_toolbox_dynamic_registration.js +++ b/devtools/client/framework/test/browser_toolbox_dynamic_registration.js @@ -50,12 +50,7 @@ function toolRegistered(toolId) { } function getAllBrowserWindows() { - const wins = []; - const enumerator = Services.wm.getEnumerator("navigator:browser"); - while (enumerator.hasMoreElements()) { - wins.push(enumerator.getNext()); - } - return wins; + return Array.from(Services.wm.getEnumerator("navigator:browser")); } function testUnregister() { diff --git a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js index dd2d360f4c2c..451b3232e04a 100644 --- a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js +++ b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js @@ -97,12 +97,7 @@ function testToolRegistered() { } function getAllBrowserWindows() { - const wins = []; - const enumerator = Services.wm.getEnumerator("navigator:browser"); - while (enumerator.hasMoreElements()) { - wins.push(enumerator.getNext()); - } - return wins; + return Array.from(Services.wm.getEnumerator("navigator:browser")); } function testUnregister() { diff --git a/devtools/client/scratchpad/scratchpad-manager.jsm b/devtools/client/scratchpad/scratchpad-manager.jsm index 8507e9d2429b..d926537ee60d 100644 --- a/devtools/client/scratchpad/scratchpad-manager.jsm +++ b/devtools/client/scratchpad/scratchpad-manager.jsm @@ -87,9 +87,7 @@ this.ScratchpadManager = { // such objects are not primitive-values-only anymore so they // can leak. - const enumerator = Services.wm.getEnumerator("devtools:scratchpad"); - while (enumerator.hasMoreElements()) { - const win = enumerator.getNext(); + for (const win of Services.wm.getEnumerator("devtools:scratchpad")) { if (!win.closed && win.Scratchpad.initialized) { this._scratchpads.push(clone(win.Scratchpad.getState())); } diff --git a/devtools/client/shared/view-source.js b/devtools/client/shared/view-source.js index 98d6545ac29d..450e985f9fc7 100644 --- a/devtools/client/shared/view-source.js +++ b/devtools/client/shared/view-source.js @@ -132,11 +132,7 @@ exports.viewSourceInDebugger = async function(toolbox, sourceURL, sourceLine, */ exports.viewSourceInScratchpad = async function(sourceURL, sourceLine) { // Check for matching top level scratchpad window. - const wins = Services.wm.getEnumerator("devtools:scratchpad"); - - while (wins.hasMoreElements()) { - const win = wins.getNext(); - + for (const win of Services.wm.getEnumerator("devtools:scratchpad")) { if (!win.closed && win.Scratchpad.uniqueName === sourceURL) { win.focus(); win.Scratchpad.editor.setCursor({ line: sourceLine, ch: 0 }); diff --git a/devtools/server/actors/accessibility.js b/devtools/server/actors/accessibility.js index 47115b0e3bad..58e04f8a70a5 100644 --- a/devtools/server/actors/accessibility.js +++ b/devtools/server/actors/accessibility.js @@ -25,7 +25,6 @@ const PREF_ACCESSIBILITY_FORCE_DISABLED = "accessibility.force_disabled"; const nsIAccessibleEvent = Ci.nsIAccessibleEvent; const nsIAccessibleStateChangeEvent = Ci.nsIAccessibleStateChangeEvent; -const nsIPropertyElement = Ci.nsIPropertyElement; const nsIAccessibleRole = Ci.nsIAccessibleRole; const { @@ -322,10 +321,7 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, { } const attributes = {}; - const attrsEnum = this.rawAccessible.attributes.enumerate(); - while (attrsEnum.hasMoreElements()) { - const { key, value } = attrsEnum.getNext().QueryInterface( - nsIPropertyElement); + for (const { key, value } of this.rawAccessible.attributes.enumerate()) { attributes[key] = value; } diff --git a/devtools/server/actors/inspector/walker.js b/devtools/server/actors/inspector/walker.js index 129626a8fa77..35729a832693 100644 --- a/devtools/server/actors/inspector/walker.js +++ b/devtools/server/actors/inspector/walker.js @@ -186,9 +186,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { * enumerator of nsIEventListenerChange */ _onEventListenerChange: function(changesEnum) { - const changes = changesEnum.enumerate(); - while (changes.hasMoreElements()) { - const current = changes.getNext().QueryInterface(Ci.nsIEventListenerChange); + for (const current of changesEnum.enumerate(Ci.nsIEventListenerChange)) { const target = current.target; if (this._refMap.has(target)) { diff --git a/devtools/server/actors/replay/graphics.js b/devtools/server/actors/replay/graphics.js index 06045f3f5d50..d546746a288f 100644 --- a/devtools/server/actors/replay/graphics.js +++ b/devtools/server/actors/replay/graphics.js @@ -51,9 +51,7 @@ function updateWindow(window, buffer, width, height) { function Update(buffer, width, height) { try { // Paint to all windows we can find. Hopefully there is only one. - const windowEnumerator = Services.ww.getWindowEnumerator(); - while (windowEnumerator.hasMoreElements()) { - const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow); + for (const window of Services.ww.getWindowEnumerator()) { updateWindow(window, buffer, width, height); } } catch (e) { diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js index e9bae7708e58..30be3ef38257 100644 --- a/devtools/server/actors/storage.js +++ b/devtools/server/actors/storage.js @@ -810,16 +810,8 @@ var cookieHelpers = { host = trimHttpHttpsPort(host); - const cookies = Services.cookies.getCookiesFromHost(host, originAttributes); - const store = []; - - while (cookies.hasMoreElements()) { - const cookie = cookies.getNext().QueryInterface(Ci.nsICookie2); - - store.push(cookie); - } - - return store; + return Array.from( + Services.cookies.getCookiesFromHost(host, originAttributes)); }, /** @@ -854,11 +846,9 @@ var cookieHelpers = { const origPath = field === "path" ? oldValue : data.items.path; let cookie = null; - const enumerator = - Services.cookies.getCookiesFromHost(origHost, data.originAttributes || {}); - - while (enumerator.hasMoreElements()) { - const nsiCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + const cookies = Services.cookies.getCookiesFromHost(origHost, + data.originAttributes || {}); + for (const nsiCookie of cookies) { if (nsiCookie.name === origName && nsiCookie.host === origHost && nsiCookie.path === origPath) { @@ -956,11 +946,9 @@ var cookieHelpers = { return cookieHost == host; } - const enumerator = - Services.cookies.getCookiesFromHost(host, opts.originAttributes || {}); - - while (enumerator.hasMoreElements()) { - const cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + const cookies = Services.cookies.getCookiesFromHost(host, + opts.originAttributes || {}); + for (const cookie of cookies) { if (hostMatches(cookie.host, host) && (!opts.name || cookie.name === opts.name) && (!opts.domain || cookie.host === opts.domain) && diff --git a/devtools/server/actors/targets/addon.js b/devtools/server/actors/targets/addon.js index 5d2db5b06237..bbbd48282929 100644 --- a/devtools/server/actors/targets/addon.js +++ b/devtools/server/actors/targets/addon.js @@ -185,20 +185,14 @@ AddonTargetActor.prototype = { }, preNest: function() { - const e = Services.wm.getEnumerator(null); - while (e.hasMoreElements()) { - const win = e.getNext(); - const windowUtils = win.windowUtils; + for (const {windowUtils} of Services.wm.getEnumerator(null)) { windowUtils.suppressEventHandling(true); windowUtils.suspendTimeouts(); } }, postNest: function() { - const e = Services.wm.getEnumerator(null); - while (e.hasMoreElements()) { - const win = e.getNext(); - const windowUtils = win.windowUtils; + for (const {windowUtils} of Services.wm.getEnumerator(null)) { windowUtils.resumeTimeouts(); windowUtils.suppressEventHandling(false); } diff --git a/devtools/server/actors/targets/browsing-context.js b/devtools/server/actors/targets/browsing-context.js index 930166586dc6..211a9454be0a 100644 --- a/devtools/server/actors/targets/browsing-context.js +++ b/devtools/server/actors/targets/browsing-context.js @@ -77,9 +77,7 @@ function getChildDocShells(parentDocShell) { ); const docShells = []; - while (docShellsEnum.hasMoreElements()) { - const docShell = docShellsEnum.getNext(); - docShell.QueryInterface(Ci.nsIDocShell); + for (const docShell of docShellsEnum) { docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebProgress); docShells.push(docShell); diff --git a/devtools/server/actors/targets/content-process.js b/devtools/server/actors/targets/content-process.js index 92366fcb40f5..f1c786de434b 100644 --- a/devtools/server/actors/targets/content-process.js +++ b/devtools/server/actors/targets/content-process.js @@ -38,14 +38,8 @@ function ContentProcessTargetActor(connection) { const sandboxPrototype = { get tabs() { - const tabs = []; - const windowEnumerator = Services.ww.getWindowEnumerator(); - while (windowEnumerator.hasMoreElements()) { - const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow); - const tabChildGlobal = window.docShell.messageManager; - tabs.push(tabChildGlobal); - } - return tabs; + return Array.from(Services.ww.getWindowEnumerator(), + win => win.docShell.messageManager); }, }; diff --git a/devtools/server/actors/targets/parent-process.js b/devtools/server/actors/targets/parent-process.js index 6770e1f86c25..925418e3b0b5 100644 --- a/devtools/server/actors/targets/parent-process.js +++ b/devtools/server/actors/targets/parent-process.js @@ -93,10 +93,7 @@ Object.defineProperty(parentProcessTargetPrototype, "docShells", { get: function() { // Iterate over all top-level windows and all their docshells. let docShells = []; - const e = Services.ww.getWindowEnumerator(); - while (e.hasMoreElements()) { - const window = e.getNext(); - const docShell = window.docShell; + for (const {docShell} of Services.ww.getWindowEnumerator()) { docShells = docShells.concat(getChildDocShells(docShell)); } @@ -131,10 +128,7 @@ parentProcessTargetPrototype._attach = function() { Services.obs.addObserver(this, "chrome-webnavigation-destroy"); // Iterate over all top-level windows. - const e = Services.ww.getWindowEnumerator(); - while (e.hasMoreElements()) { - const window = e.getNext(); - const docShell = window.docShell; + for (const {docShell} of Services.ww.getWindowEnumerator()) { if (docShell == this.docShell) { continue; } @@ -152,10 +146,7 @@ parentProcessTargetPrototype._detach = function() { Services.obs.removeObserver(this, "chrome-webnavigation-destroy"); // Iterate over all top-level windows. - const e = Services.ww.getWindowEnumerator(); - while (e.hasMoreElements()) { - const window = e.getNext(); - const docShell = window.docShell; + for (const {docShell} of Services.ww.getWindowEnumerator()) { if (docShell == this.docShell) { continue; } @@ -173,10 +164,7 @@ parentProcessTargetPrototype._detach = function() { */ parentProcessTargetPrototype.preNest = function() { // Disable events in all open windows. - const e = Services.wm.getEnumerator(null); - while (e.hasMoreElements()) { - const win = e.getNext(); - const windowUtils = win.windowUtils; + for (const {windowUtils} of Services.wm.getEnumerator(null)) { windowUtils.suppressEventHandling(true); windowUtils.suspendTimeouts(); } @@ -187,10 +175,7 @@ parentProcessTargetPrototype.preNest = function() { */ parentProcessTargetPrototype.postNest = function(nestData) { // Enable events in all open windows. - const e = Services.wm.getEnumerator(null); - while (e.hasMoreElements()) { - const win = e.getNext(); - const windowUtils = win.windowUtils; + for (const {windowUtils} of Services.wm.getEnumerator(null)) { windowUtils.resumeTimeouts(); windowUtils.suppressEventHandling(false); } diff --git a/devtools/server/actors/targets/webextension.js b/devtools/server/actors/targets/webextension.js index 3fe9a0e6438e..d6abce8bdbbc 100644 --- a/devtools/server/actors/targets/webextension.js +++ b/devtools/server/actors/targets/webextension.js @@ -188,10 +188,7 @@ webExtensionTargetPrototype._destroyFallbackWindow = function() { // windowless browser when running in non-oop mode, and the background page // is set later using _onNewExtensionWindow. webExtensionTargetPrototype._searchForExtensionWindow = function() { - const e = Services.ww.getWindowEnumerator(null); - while (e.hasMoreElements()) { - const window = e.getNext(); - + for (const window of Services.ww.getWindowEnumerator(null)) { if (window.document.nodePrincipal.addonId == this.id) { return window; } diff --git a/devtools/server/actors/webbrowser.js b/devtools/server/actors/webbrowser.js index fb302022b553..ba8beb1b9c92 100644 --- a/devtools/server/actors/webbrowser.js +++ b/devtools/server/actors/webbrowser.js @@ -24,20 +24,6 @@ loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.j * Browser-specific actors. */ -/** - * Yield all windows of type |windowType|, from the oldest window to the - * youngest, using nsIWindowMediator::getEnumerator. We're usually - * interested in "navigator:browser" windows. - */ -function* allAppShellDOMWindows(windowType) { - const e = Services.wm.getEnumerator(windowType); - while (e.hasMoreElements()) { - yield e.getNext(); - } -} - -exports.allAppShellDOMWindows = allAppShellDOMWindows; - /** * Retrieve the window type of the top-level window |window|. */ @@ -50,7 +36,7 @@ function appShellDOMWindowType(window) { * Send Debugger:Shutdown events to all "navigator:browser" windows. */ function sendShutdownEvent() { - for (const win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) { + for (const win of Services.wm.getEnumerator(DebuggerServer.chromeWindowType)) { const evt = win.document.createEvent("Event"); evt.initEvent("Debugger:Shutdown", true, false); win.document.documentElement.dispatchEvent(evt); @@ -228,7 +214,7 @@ BrowserTabList.prototype._getSelectedBrowser = function(window) { */ BrowserTabList.prototype._getBrowsers = function* () { // Iterate over all navigator:browser XUL windows. - for (const win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) { + for (const win of Services.wm.getEnumerator(DebuggerServer.chromeWindowType)) { // For each tab in this XUL window, ensure that we have an actor for // it, reusing existing actors where possible. for (const browser of this._getChildren(win)) { @@ -488,7 +474,7 @@ BrowserTabList.prototype._listenForEventsIf = function(shouldListen, guard, eventNames) { if (!shouldListen !== !this[guard]) { const op = shouldListen ? "addEventListener" : "removeEventListener"; - for (const win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) { + for (const win of Services.wm.getEnumerator(DebuggerServer.chromeWindowType)) { for (const name of eventNames) { win[op](name, this, false); } @@ -512,7 +498,7 @@ BrowserTabList.prototype._listenForMessagesIf = function(shouldListen, guard, messageNames) { if (!shouldListen !== !this[guard]) { const op = shouldListen ? "addMessageListener" : "removeMessageListener"; - for (const win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) { + for (const win of Services.wm.getEnumerator(DebuggerServer.chromeWindowType)) { for (const name of messageNames) { win.messageManager[op](name, this); } diff --git a/devtools/server/actors/worker/worker-list.js b/devtools/server/actors/worker/worker-list.js index 1b8f4e216d43..5f6038ce1159 100644 --- a/devtools/server/actors/worker/worker-list.js +++ b/devtools/server/actors/worker/worker-list.js @@ -53,9 +53,7 @@ WorkerTargetActorList.prototype = { getList() { // Create a set of debuggers. const dbgs = new Set(); - const e = wdm.getWorkerDebuggerEnumerator(); - while (e.hasMoreElements()) { - const dbg = e.getNext().QueryInterface(Ci.nsIWorkerDebugger); + for (const dbg of wdm.getWorkerDebuggerEnumerator()) { if (matchWorkerDebugger(dbg, this._options)) { dbgs.add(dbg); } diff --git a/devtools/server/performance/timeline.js b/devtools/server/performance/timeline.js index 537a50d1a827..1e0ec86fe166 100644 --- a/devtools/server/performance/timeline.js +++ b/devtools/server/performance/timeline.js @@ -75,7 +75,6 @@ Timeline.prototype = { */ get docShells() { let originalDocShell; - const docShells = []; if (this.targetActor.isRootActor) { originalDocShell = this.targetActor.docShell; @@ -84,7 +83,7 @@ Timeline.prototype = { } if (!originalDocShell) { - return docShells; + return []; } const docShellsEnum = originalDocShell.getDocShellEnumerator( @@ -92,12 +91,7 @@ Timeline.prototype = { Ci.nsIDocShell.ENUMERATE_FORWARDS ); - while (docShellsEnum.hasMoreElements()) { - const docShell = docShellsEnum.getNext(); - docShells.push(docShell.QueryInterface(Ci.nsIDocShell)); - } - - return docShells; + return Array.from(docShellsEnum); }, /** diff --git a/devtools/shared/system.js b/devtools/shared/system.js index d67aeee06781..b44565216581 100644 --- a/devtools/shared/system.js +++ b/devtools/shared/system.js @@ -175,9 +175,7 @@ function getProfileLocation() { const profd = Services.dirsvc.get("ProfD", Ci.nsIFile); const profservice = Cc["@mozilla.org/toolkit/profile-service;1"] .getService(Ci.nsIToolkitProfileService); - const profiles = profservice.profiles; - while (profiles.hasMoreElements()) { - const profile = profiles.getNext().QueryInterface(Ci.nsIToolkitProfile); + for (const profile of profservice.profiles) { if (profile.rootDir.path == profd.path) { return profile.name; } diff --git a/devtools/startup/devtools-startup.js b/devtools/startup/devtools-startup.js index 1fddcbadcd34..0e24e8e8f25d 100644 --- a/devtools/startup/devtools-startup.js +++ b/devtools/startup/devtools-startup.js @@ -500,9 +500,7 @@ DevToolsStartup.prototype = { * item. */ onEnabledPrefChanged() { - const enumerator = Services.wm.getEnumerator("navigator:browser"); - while (enumerator.hasMoreElements()) { - const window = enumerator.getNext(); + for (const window of Services.wm.getEnumerator("navigator:browser")) { if (window.gBrowserInit && window.gBrowserInit.delayedStartupFinished) { this.updateDevToolsMenuItems(window); } diff --git a/docshell/base/nsDocShellEnumerator.cpp b/docshell/base/nsDocShellEnumerator.cpp index 1f870cd01feb..5d68907f9b64 100644 --- a/docshell/base/nsDocShellEnumerator.cpp +++ b/docshell/base/nsDocShellEnumerator.cpp @@ -21,8 +21,6 @@ nsDocShellEnumerator::~nsDocShellEnumerator() { } -NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator) - NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports** aResult) { diff --git a/docshell/base/nsDocShellEnumerator.h b/docshell/base/nsDocShellEnumerator.h index c7e3dc215231..94f5db6aa05b 100644 --- a/docshell/base/nsDocShellEnumerator.h +++ b/docshell/base/nsDocShellEnumerator.h @@ -7,7 +7,7 @@ #ifndef nsDocShellEnumerator_h___ #define nsDocShellEnumerator_h___ -#include "nsISimpleEnumerator.h" +#include "nsSimpleEnumerator.h" #include "nsTArray.h" #include "nsIWeakReferenceUtils.h" @@ -29,7 +29,7 @@ class nsIDocShellTreeItem; "@mozilla.org/docshell/enumerator-backwards;1" */ -class nsDocShellEnumerator : public nsISimpleEnumerator +class nsDocShellEnumerator : public nsSimpleEnumerator { protected: enum @@ -43,12 +43,11 @@ protected: public: explicit nsDocShellEnumerator(int32_t aEnumerationDirection); - // nsISupports - NS_DECL_ISUPPORTS - // nsISimpleEnumerator NS_DECL_NSISIMPLEENUMERATOR + const nsID& DefaultInterface() override { return NS_GET_IID(nsIDocShell); } + public: nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem); nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem); diff --git a/docshell/shistory/nsSHistory.h b/docshell/shistory/nsSHistory.h index 52d8bc3e84f2..4c054cdb445f 100644 --- a/docshell/shistory/nsSHistory.h +++ b/docshell/shistory/nsSHistory.h @@ -11,9 +11,9 @@ #include "nsExpirationTracker.h" #include "nsISHistory.h" #include "nsISHistoryInternal.h" -#include "nsISimpleEnumerator.h" #include "nsIWebNavigation.h" #include "nsSHEntryShared.h" +#include "nsSimpleEnumerator.h" #include "nsTObserverArray.h" #include "nsWeakReference.h" diff --git a/docshell/test/browser/file_bug1328501_framescript.js b/docshell/test/browser/file_bug1328501_framescript.js index 1107f5ad4092..bf76711e2100 100644 --- a/docshell/test/browser/file_bug1328501_framescript.js +++ b/docshell/test/browser/file_bug1328501_framescript.js @@ -31,10 +31,5 @@ function getChildDocShells() { Ci.nsIDocShell.ENUMERATE_FORWARDS ); - let docShells = []; - while (docShellsEnum.hasMoreElements()) { - let ds = docShellsEnum.getNext(); - docShells.push(ds); - } - return docShells; + return Array.from(docShellsEnum); } diff --git a/docshell/test/navigation/NavigationUtils.js b/docshell/test/navigation/NavigationUtils.js index 4822ff0e6ade..219c5cbabf39 100644 --- a/docshell/test/navigation/NavigationUtils.js +++ b/docshell/test/navigation/NavigationUtils.js @@ -102,12 +102,10 @@ function xpcEnumerateContentWindows(callback) { var Ci = SpecialPowers.Ci; var ww = SpecialPowers.Cc["@mozilla.org/embedcomp/window-watcher;1"] .getService(Ci.nsIWindowWatcher); - var enumerator = ww.getWindowEnumerator(); var contentWindows = []; - while (enumerator.hasMoreElements()) { - var win = enumerator.getNext(); + for (let win of ww.getWindowEnumerator()) { if (win.isChromeWindow) { var docshellTreeNode = win.docShell; var childCount = docshellTreeNode.childCount; diff --git a/dom/base/ContentFrameMessageManager.h b/dom/base/ContentFrameMessageManager.h index 7c6f4bad8314..b4660b15a9fd 100644 --- a/dom/base/ContentFrameMessageManager.h +++ b/dom/base/ContentFrameMessageManager.h @@ -16,6 +16,10 @@ namespace mozilla { namespace dom { +#define NS_CONTENTFRAMEMESSAGEMANAGER_IID \ +{ 0x97e192a6, 0xab7a, 0x4c8f, \ + { 0xb7, 0xdd, 0xf7, 0xec, 0x36, 0x38, 0x71, 0xb5 } } + /** * Base class for implementing the WebIDL ContentFrameMessageManager class. */ @@ -26,6 +30,8 @@ public: using DOMEventTargetHelper::AddRef; using DOMEventTargetHelper::Release; + NS_DECLARE_STATIC_IID_ACCESSOR(NS_CONTENTFRAMEMESSAGEMANAGER_IID) + virtual already_AddRefed GetContent(ErrorResult& aError) = 0; virtual already_AddRefed GetDocShell(ErrorResult& aError) = 0; virtual already_AddRefed GetTabEventTarget() = 0; @@ -50,6 +56,8 @@ protected: {} }; +NS_DEFINE_STATIC_IID_ACCESSOR(ContentFrameMessageManager, NS_CONTENTFRAMEMESSAGEMANAGER_IID) + } // namespace dom } // namespace mozilla diff --git a/dom/base/InProcessTabChildMessageManager.cpp b/dom/base/InProcessTabChildMessageManager.cpp index 0d2ab0be19d3..50dc6a79e45d 100644 --- a/dom/base/InProcessTabChildMessageManager.cpp +++ b/dom/base/InProcessTabChildMessageManager.cpp @@ -147,6 +147,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InProcessTabChildMessageManager) NS_INTERFACE_MAP_ENTRY(nsIMessageSender) NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager) + NS_INTERFACE_MAP_ENTRY(ContentFrameMessageManager) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index f5423ab28dd4..3863bcc22f6f 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -2938,7 +2938,13 @@ NS_IMETHODIMP nsJSArgArray::IndexOf(uint32_t startIndex, nsISupports *element, u return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsJSArgArray::Enumerate(nsISimpleEnumerator **_retval) +NS_IMETHODIMP nsJSArgArray::ScriptedEnumerate(nsIJSIID* aElemIID, uint8_t aArgc, + nsISimpleEnumerator** aResult) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsJSArgArray::EnumerateImpl(const nsID& aEntryIID, nsISimpleEnumerator **_retval) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/dom/browser-element/mochitest/browserElement_ExecuteScript.js b/dom/browser-element/mochitest/browserElement_ExecuteScript.js index b6b0b842bcc9..334a4f8791cd 100644 --- a/dom/browser-element/mochitest/browserElement_ExecuteScript.js +++ b/dom/browser-element/mochitest/browserElement_ExecuteScript.js @@ -91,7 +91,7 @@ function runTest() { ok(c(rv, 'YQ=='), `scriptId: ${scriptId++}`); return iframe.executeScript('window.wrappedJSObject.btoa("a")', {url}) }, bail).then(bail, (error) => { - is(error.message, 'TypeError: window.wrappedJSObject is undefined', `scriptId: ${scriptId++}`); + is(error.message, `TypeError: window.wrappedJSObject is undefined, can't access property "btoa" of it`, `scriptId: ${scriptId++}`); return iframe.executeScript('42', {}) }).then(bail, error => { is(error.name, 'InvalidAccessError', `scriptId: ${scriptId++}`); diff --git a/dom/chrome-webidl/IteratorResult.webidl b/dom/chrome-webidl/IteratorResult.webidl new file mode 100644 index 000000000000..1fdd26810e07 --- /dev/null +++ b/dom/chrome-webidl/IteratorResult.webidl @@ -0,0 +1,14 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +/** + * A dictionary which represents the result of a call to a next() method on a + * JS iterator object. + */ +dictionary IteratorResult { + required boolean done; + any value; +}; diff --git a/dom/chrome-webidl/WebExtensionContentScript.webidl b/dom/chrome-webidl/WebExtensionContentScript.webidl index 6b5d36b3c4ea..488bd82b104d 100644 --- a/dom/chrome-webidl/WebExtensionContentScript.webidl +++ b/dom/chrome-webidl/WebExtensionContentScript.webidl @@ -6,6 +6,9 @@ interface LoadInfo; interface URI; interface WindowProxy; +typedef (MatchPatternSet or sequence) MatchPatternSetOrStringSequence; +typedef (MatchGlob or DOMString) MatchGlobOrString; + [Constructor(MozDocumentMatcherInit options), ChromeOnly, Exposed=System] interface MozDocumentMatcher { /** @@ -94,13 +97,13 @@ dictionary MozDocumentMatcherInit { unsigned long long? frameID = null; - required MatchPatternSet matches; + required MatchPatternSetOrStringSequence matches; - MatchPatternSet? excludeMatches = null; + MatchPatternSetOrStringSequence? excludeMatches = null; - sequence? includeGlobs = null; + sequence? includeGlobs = null; - sequence? excludeGlobs = null; + sequence? excludeGlobs = null; boolean hasActiveTabPermission = false; }; diff --git a/dom/chrome-webidl/WebExtensionPolicy.webidl b/dom/chrome-webidl/WebExtensionPolicy.webidl index b65757c34620..6fc51046eb82 100644 --- a/dom/chrome-webidl/WebExtensionPolicy.webidl +++ b/dom/chrome-webidl/WebExtensionPolicy.webidl @@ -134,6 +134,12 @@ interface WebExtensionPolicy { [Throws] void unregisterContentScript(WebExtensionContentScript script); + /** + * Injects the extension's content script into all existing matching windows. + */ + [Throws] + void injectContentScripts(); + /** * Returns the list of currently active extension policies. */ @@ -176,11 +182,11 @@ dictionary WebExtensionInit { required WebExtensionLocalizeCallback localizeCallback; - required MatchPatternSet allowedOrigins; + required MatchPatternSetOrStringSequence allowedOrigins; sequence permissions = []; - sequence webAccessibleResources = []; + sequence webAccessibleResources = []; sequence contentScripts = []; diff --git a/dom/chrome-webidl/moz.build b/dom/chrome-webidl/moz.build index d7b6b43274b9..071cbb8b88f8 100644 --- a/dom/chrome-webidl/moz.build +++ b/dom/chrome-webidl/moz.build @@ -34,6 +34,7 @@ WEBIDL_FILES = [ 'DominatorTree.webidl', 'HeapSnapshot.webidl', 'InspectorUtils.webidl', + 'IteratorResult.webidl', 'MatchGlob.webidl', 'MatchPattern.webidl', 'MessageManager.webidl', diff --git a/dom/commandhandler/nsCommandGroup.cpp b/dom/commandhandler/nsCommandGroup.cpp index 5175ef0a3ea9..a81e11daec33 100644 --- a/dom/commandhandler/nsCommandGroup.cpp +++ b/dom/commandhandler/nsCommandGroup.cpp @@ -7,7 +7,7 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsTArray.h" -#include "nsISimpleEnumerator.h" +#include "nsSimpleEnumerator.h" #include "nsXPCOM.h" #include "nsSupportsPrimitives.h" #include "nsIComponentManager.h" @@ -15,17 +15,21 @@ #include "nsIControllerCommand.h" #include "nsCRT.h" -class nsGroupsEnumerator : public nsISimpleEnumerator +class nsGroupsEnumerator : public nsSimpleEnumerator { public: explicit nsGroupsEnumerator( nsControllerCommandGroup::GroupsHashtable& aInHashTable); - NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR + const nsID& DefaultInterface() override + { + return NS_GET_IID(nsISupportsCString); + } + protected: - virtual ~nsGroupsEnumerator(); + ~nsGroupsEnumerator() override; nsresult Initialize(); @@ -36,9 +40,6 @@ protected: bool mInitted; }; -/* Implementation file */ -NS_IMPL_ISUPPORTS(nsGroupsEnumerator, nsISimpleEnumerator) - nsGroupsEnumerator::nsGroupsEnumerator( nsControllerCommandGroup::GroupsHashtable& aInHashTable) : mHashTable(aInHashTable) @@ -125,16 +126,20 @@ nsGroupsEnumerator::Initialize() return NS_OK; } -class nsNamedGroupEnumerator : public nsISimpleEnumerator +class nsNamedGroupEnumerator : public nsSimpleEnumerator { public: explicit nsNamedGroupEnumerator(nsTArray* aInArray); - NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR + const nsID& DefaultInterface() override + { + return NS_GET_IID(nsISupportsCString); + } + protected: - virtual ~nsNamedGroupEnumerator(); + ~nsNamedGroupEnumerator() override; nsTArray* mGroupArray; int32_t mIndex; @@ -150,8 +155,6 @@ nsNamedGroupEnumerator::~nsNamedGroupEnumerator() { } -NS_IMPL_ISUPPORTS(nsNamedGroupEnumerator, nsISimpleEnumerator) - NS_IMETHODIMP nsNamedGroupEnumerator::HasMoreElements(bool* aResult) { diff --git a/dom/html/test/file_cookiemanager.js b/dom/html/test/file_cookiemanager.js index 281d2a8dc5dc..c8f9cfd0f249 100644 --- a/dom/html/test/file_cookiemanager.js +++ b/dom/html/test/file_cookiemanager.js @@ -3,9 +3,7 @@ addMessageListener("getCookieFromManager", ({ host, path }) => { .getService(Ci.nsICookieManager); let values = []; path = path.substring(0, path.lastIndexOf("/") + 1); - let e = cm.enumerator; - while (e.hasMoreElements()) { - let cookie = e.getNext().QueryInterface(Ci.nsICookie); + for (let cookie of cm.enumerator) { if (!cookie) { break; } diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 22038a36b20f..58ce9c672263 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -17124,7 +17124,7 @@ FileManager::InitDirectory(nsIFile* aDirectory, return NS_ERROR_FAILURE; } - nsCOMPtr entries; + nsCOMPtr entries; rv = journalDirectory->GetDirectoryEntries(getter_AddRefs(entries)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 511ebf884c21..ea3998f9f22f 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -90,6 +90,7 @@ #include "nsISimpleEnumerator.h" #include "nsIStringBundle.h" #include "nsIWorkerDebuggerManager.h" +#include "nsGeolocation.h" #if !defined(XP_WIN) #include "mozilla/Omnijar.h" @@ -2626,8 +2627,8 @@ ContentChild::RecvUpdateSharedData(const FileDescriptor& aMapFile, mozilla::ipc::IPCResult ContentChild::RecvGeolocationUpdate(nsIDOMGeoPosition* aPosition) { - nsCOMPtr gs = - do_GetService("@mozilla.org/geolocation/service;1"); + RefPtr gs = + nsGeolocationService::GetGeolocationService(); if (!gs) { return IPC_OK(); } @@ -2638,8 +2639,8 @@ ContentChild::RecvGeolocationUpdate(nsIDOMGeoPosition* aPosition) mozilla::ipc::IPCResult ContentChild::RecvGeolocationError(const uint16_t& errorCode) { - nsCOMPtr gs = - do_GetService("@mozilla.org/geolocation/service;1"); + RefPtr gs = + nsGeolocationService::GetGeolocationService(); if (!gs) { return IPC_OK(); } diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index f138e7f72d83..0f07c36d5582 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -3563,6 +3563,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildMessageManager) NS_INTERFACE_MAP_ENTRY(nsIMessageSender) + NS_INTERFACE_MAP_ENTRY(ContentFrameMessageManager) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) diff --git a/dom/media/gmp/GMPUtils.h b/dom/media/gmp/GMPUtils.h index 628b68561797..c6f9d18a6053 100644 --- a/dom/media/gmp/GMPUtils.h +++ b/dom/media/gmp/GMPUtils.h @@ -18,7 +18,7 @@ #define CHROMIUM_CDM_API "chromium-cdm9-host4" class nsIFile; -class nsISimpleEnumerator; +class nsIDirectoryEnumerator; namespace mozilla { @@ -62,7 +62,7 @@ public: private: Mode mMode; - nsCOMPtr mIter; + nsCOMPtr mIter; }; class GMPInfoFileParser { diff --git a/dom/payments/PaymentRequestService.cpp b/dom/payments/PaymentRequestService.cpp index ee37fc8aaf33..a54b82f3989f 100644 --- a/dom/payments/PaymentRequestService.cpp +++ b/dom/payments/PaymentRequestService.cpp @@ -8,6 +8,7 @@ #include "PaymentRequestData.h" #include "PaymentRequestService.h" #include "BasicCardPayment.h" +#include "nsSimpleEnumerator.h" namespace mozilla { namespace dom { @@ -16,22 +17,25 @@ StaticRefPtr gPaymentService; namespace { -class PaymentRequestEnumerator final : public nsISimpleEnumerator +class PaymentRequestEnumerator final : public nsSimpleEnumerator { public: - NS_DECL_ISUPPORTS NS_DECL_NSISIMPLEENUMERATOR PaymentRequestEnumerator() : mIndex(0) {} + + const nsID& DefaultInterface() override + { + return NS_GET_IID(nsIPaymentRequest); + } + private: - ~PaymentRequestEnumerator() = default; + ~PaymentRequestEnumerator() override = default; uint32_t mIndex; }; -NS_IMPL_ISUPPORTS(PaymentRequestEnumerator, nsISimpleEnumerator) - NS_IMETHODIMP PaymentRequestEnumerator::HasMoreElements(bool* aReturn) { diff --git a/dom/payments/test/CleanupChromeScript.js b/dom/payments/test/CleanupChromeScript.js index 301c2f105d0f..44fa195518ba 100644 --- a/dom/payments/test/CleanupChromeScript.js +++ b/dom/payments/test/CleanupChromeScript.js @@ -28,20 +28,16 @@ var setPaymentNums = 0; addMessageListener("payment-num-set", function() { setPaymentNums = 0; - const paymentEnum = paymentSrv.enumerate(); - while (paymentEnum.hasMoreElements()) { + for (let payment of paymentSrv.enumerate()) { setPaymentNums = setPaymentNums + 1; - paymentEnum.getNext(); } sendAsyncMessage("payment-num-set-complete"); }); addMessageListener("payment-num-check", function(expectedNumPayments) { - const paymentEnum = paymentSrv.enumerate(); let numPayments = 0; - while (paymentEnum.hasMoreElements()) { + for (let payment of paymentSrv.enumerate()) { numPayments = numPayments + 1; - paymentEnum.getNext(); } if (numPayments !== expectedNumPayments + setPaymentNums) { emitTestFail("Expected '" + expectedNumPayments + diff --git a/dom/payments/test/ConstructorChromeScript.js b/dom/payments/test/ConstructorChromeScript.js index bb1990425b62..9ce4448db547 100644 --- a/dom/payments/test/ConstructorChromeScript.js +++ b/dom/payments/test/ConstructorChromeScript.js @@ -353,8 +353,7 @@ function checkSimplestRequestHandler() { if (!paymentEnum.hasMoreElements()) { emitTestFail("PaymentRequestService should have at least one payment request."); } - while (paymentEnum.hasMoreElements()) { - let payRequest = paymentEnum.getNext().QueryInterface(Ci.nsIPaymentRequest); + for (let payRequest of paymentEnum) { if (!payRequest) { emitTestFail("Fail to get existing payment request."); break; @@ -370,8 +369,7 @@ function checkComplexRequestHandler() { if (!paymentEnum.hasMoreElements()) { emitTestFail("PaymentRequestService should have at least one payment request."); } - while (paymentEnum.hasMoreElements()) { - let payRequest = paymentEnum.getNext().QueryInterface(Ci.nsIPaymentRequest); + for (let payRequest of paymentEnum) { if (!payRequest) { emitTestFail("Fail to get existing payment request."); break; @@ -387,8 +385,7 @@ function checkNonBasicCardRequestHandler() { if (!paymentEnum.hasMoreElements()) { emitTestFail("PaymentRequestService should have at least one payment request."); } - while (paymentEnum.hasMoreElements()) { - let payRequest = paymentEnum.getNext().QueryInterface(Ci.nsIPaymentRequest); + for (let payRequest of paymentEnum) { if (!payRequest) { emitTestFail("Fail to get existing payment request."); break; @@ -404,8 +401,7 @@ function checkMultipleRequestsHandler () { if (!paymentEnum.hasMoreElements()) { emitTestFail("PaymentRequestService should have at least one payment request."); } - while (paymentEnum.hasMoreElements()) { - let payRequest = paymentEnum.getNext().QueryInterface(Ci.nsIPaymentRequest); + for (let payRequest of paymentEnum) { if (!payRequest) { emitTestFail("Fail to get existing payment request."); break; @@ -425,8 +421,7 @@ function checkCrossOriginTopLevelPrincipalHandler() { if (!paymentEnum.hasMoreElements()) { emitTestFail("PaymentRequestService should have at least one payment request."); } - while (paymentEnum.hasMoreElements()) { - let payRequest = paymentEnum.getNext().QueryInterface(Ci.nsIPaymentRequest); + for (let payRequest of paymentEnum) { if (!payRequest) { emitTestFail("Fail to get existing payment request."); break; diff --git a/dom/payments/test/CurrencyAmountValidationChromeScript.js b/dom/payments/test/CurrencyAmountValidationChromeScript.js index 3a24c813c4bb..3ff74c3a77de 100644 --- a/dom/payments/test/CurrencyAmountValidationChromeScript.js +++ b/dom/payments/test/CurrencyAmountValidationChromeScript.js @@ -36,10 +36,7 @@ function checkLowerCaseCurrency() { "PaymentRequestService should have at least one payment request."; sendAsyncMessage("test-fail", msg); } - while (paymentEnum.hasMoreElements()) { - const payRequest = paymentEnum - .getNext() - .QueryInterface(Ci.nsIPaymentRequest); + for (let payRequest of paymentEnum) { if (!payRequest) { sendAsyncMessage("test-fail", "Fail to get existing payment request."); break; diff --git a/dom/payments/test/browser_payment_in_different_tabs.js b/dom/payments/test/browser_payment_in_different_tabs.js index 515fc328c77d..5cc68b65a486 100644 --- a/dom/payments/test/browser_payment_in_different_tabs.js +++ b/dom/payments/test/browser_payment_in_different_tabs.js @@ -17,15 +17,13 @@ add_task(async () => { const paymentSrv = Cc[ "@mozilla.org/dom/payments/payment-request-service;1" ].getService(Ci.nsIPaymentRequestService); - ok(paymentSrv, "Fail to get PaymentRequestService."); const paymentEnum = paymentSrv.enumerate(); ok( paymentEnum.hasMoreElements(), "PaymentRequestService should have at least one payment request." ); const payments = new Set(); - while (paymentEnum.hasMoreElements()) { - const payment = paymentEnum.getNext().QueryInterface(Ci.nsIPaymentRequest); + for (let payment of paymentEnum) { ok(payment, "Fail to get existing payment request."); checkSimplePayment(payment); payments.add(payment); diff --git a/dom/plugins/base/nsPluginDirServiceProvider.cpp b/dom/plugins/base/nsPluginDirServiceProvider.cpp index abd76237c68a..15372a2ad807 100644 --- a/dom/plugins/base/nsPluginDirServiceProvider.cpp +++ b/dom/plugins/base/nsPluginDirServiceProvider.cpp @@ -62,7 +62,7 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, dirs); GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, dirs); - return NS_NewArrayEnumerator(aEnumerator, dirs); + return NS_NewArrayEnumerator(aEnumerator, dirs, NS_GET_IID(nsIFile)); } nsresult diff --git a/dom/plugins/test/unit/head_plugins.js b/dom/plugins/test/unit/head_plugins.js index 8acaa902b247..c545cd532be7 100644 --- a/dom/plugins/test/unit/head_plugins.js +++ b/dom/plugins/test/unit/head_plugins.js @@ -16,9 +16,7 @@ function allow_all_plugins() { // Finds the test plugin library function get_test_plugin(secondplugin=false) { - var pluginEnum = gDirSvc.get("APluginsDL", Ci.nsISimpleEnumerator); - while (pluginEnum.hasMoreElements()) { - let dir = pluginEnum.getNext().QueryInterface(Ci.nsIFile); + for (let dir of gDirSvc.get("APluginsDL", Ci.nsISimpleEnumerator)) { let name = get_platform_specific_plugin_name(secondplugin); let plugin = dir.clone(); plugin.append(name); @@ -100,9 +98,7 @@ function get_platform_specific_plugin_suffix() { function get_test_plugin_no_symlink() { let dirSvc = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIProperties); - let pluginEnum = dirSvc.get("APluginsDL", Ci.nsISimpleEnumerator); - while (pluginEnum.hasMoreElements()) { - let dir = pluginEnum.getNext().QueryInterface(Ci.nsIFile); + for (let dir of dirSvc.get("APluginsDL", Ci.nsISimpleEnumerator)) { let plugin = dir.clone(); plugin.append(get_platform_specific_plugin_name()); if (plugin.exists()) { diff --git a/dom/promise/Promise-inl.h b/dom/promise/Promise-inl.h new file mode 100644 index 000000000000..b96f2efcb543 --- /dev/null +++ b/dom/promise/Promise-inl.h @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_Promise_inl_h +#define mozilla_dom_Promise_inl_h + +#include "mozilla/TupleCycleCollection.h" +#include "mozilla/TypeTraits.h" +#include "mozilla/ResultExtensions.h" +#include "mozilla/dom/PromiseNativeHandler.h" + +namespace mozilla { +namespace dom { + +class PromiseNativeThenHandlerBase : public PromiseNativeHandler +{ + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS(PromiseNativeThenHandlerBase) + + PromiseNativeThenHandlerBase(Promise& aPromise) + : mPromise(&aPromise) + {} + + void + ResolvedCallback(JSContext* aCx, JS::Handle aValue) override; + + void + RejectedCallback(JSContext* aCx, JS::Handle aValue) override; + +protected: + virtual ~PromiseNativeThenHandlerBase() = default; + + virtual already_AddRefed + CallResolveCallback(JSContext* aCx, JS::Handle aValue) = 0; + + virtual void Traverse(nsCycleCollectionTraversalCallback&) = 0; + virtual void Unlink() = 0; + + RefPtr mPromise; +}; + +namespace { + +template ::Type>::value, + bool = (IsConvertible::value || + IsConvertible::value)> +struct StorageTypeHelper +{ + using Type = T; +}; + +template +struct StorageTypeHelper +{ + using Type = nsCOMPtr; +}; + +template +struct StorageTypeHelper, true, true> +{ + using Type = nsCOMPtr; +}; + +template +struct StorageTypeHelper +{ + using Type = RefPtr; +}; + +template