diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 366852f66129..ab5596e757fd 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -224,38 +224,54 @@ if (AppConstants.platform != "macosx") { ["gNavigatorBundle", "bundle_browser"] ].forEach(function(elementGlobal) { var [name, id] = elementGlobal; - window.__defineGetter__(name, function() { - var element = document.getElementById(id); - if (!element) - return null; - delete window[name]; - return window[name] = element; - }); - window.__defineSetter__(name, function(val) { - delete window[name]; - return window[name] = val; + Object.defineProperty(window, name, { + configurable: true, + enumerable: true, + get() { + var element = document.getElementById(id); + if (!element) + return null; + delete window[name]; + return window[name] = element; + }, + set(val) { + delete window[name]; + return window[name] = val; + }, }); }); // Smart getter for the findbar. If you don't wish to force the creation of // the findbar, check gFindBarInitialized first. -this.__defineGetter__("gFindBar", function() { - return window.gBrowser.getFindBar(); +Object.defineProperty(this, "gFindBar", { + configurable: true, + enumerable: true, + get() { + return window.gBrowser.getFindBar(); + }, }); -this.__defineGetter__("gFindBarInitialized", function() { - return window.gBrowser.isFindBarInitialized(); +Object.defineProperty(this, "gFindBarInitialized", { + configurable: true, + enumerable: true, + get() { + return window.gBrowser.isFindBarInitialized(); + }, }); -this.__defineGetter__("AddonManager", function() { - let tmp = {}; - Cu.import("resource://gre/modules/AddonManager.jsm", tmp); - return this.AddonManager = tmp.AddonManager; -}); -this.__defineSetter__("AddonManager", function(val) { - delete this.AddonManager; - return this.AddonManager = val; +Object.defineProperty(this, "AddonManager", { + configurable: true, + enumerable: true, + get() { + let tmp = {}; + Cu.import("resource://gre/modules/AddonManager.jsm", tmp); + return this.AddonManager = tmp.AddonManager; + }, + set(val) { + delete this.AddonManager; + return this.AddonManager = val; + }, }); diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index ec4e13d095d2..4e014bb71557 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -18,13 +18,17 @@ XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); -this.__defineGetter__("BROWSER_NEW_TAB_URL", () => { - if (PrivateBrowsingUtils.isWindowPrivate(window) && - !PrivateBrowsingUtils.permanentPrivateBrowsing && - !aboutNewTabService.overridden) { - return "about:privatebrowsing"; - } - return aboutNewTabService.newTabURL; +Object.defineProperty(this, "BROWSER_NEW_TAB_URL", { + configurable: true, + enumerable: true, + get() { + if (PrivateBrowsingUtils.isWindowPrivate(window) && + !PrivateBrowsingUtils.permanentPrivateBrowsing && + !aboutNewTabService.overridden) { + return "about:privatebrowsing"; + } + return aboutNewTabService.newTabURL; + }, }); var TAB_DROP_TYPE = "application/x-moz-tabbrowser-tab"; diff --git a/toolkit/components/viewsource/content/viewSource.js b/toolkit/components/viewsource/content/viewSource.js index 2acfa055fe2a..f7213fce7012 100644 --- a/toolkit/components/viewsource/content/viewSource.js +++ b/toolkit/components/viewsource/content/viewSource.js @@ -27,12 +27,16 @@ XPCOMUtils.defineLazyModuleGetter(this, "Deprecated", ["gViewSourceBundle", "viewSourceBundle"], ["gContextMenu", "viewSourceContextMenu"] ].forEach(function([name, id]) { - window.__defineGetter__(name, function() { - var element = document.getElementById(id); - if (!element) - return null; - delete window[name]; - return window[name] = element; + Object.defineProperty(window, name, { + configurable: true, + enumerable: true, + get() { + var element = document.getElementById(id); + if (!element) + return null; + delete window[name]; + return window[name] = element; + }, }); }); @@ -779,14 +783,18 @@ function getBrowser() { return gBrowser; } -this.__defineGetter__("gPageLoader", function() { - var webnav = viewSourceChrome.webNav; - if (!webnav) - return null; - delete this.gPageLoader; - this.gPageLoader = (webnav instanceof Ci.nsIWebPageDescriptor) ? webnav - : null; - return this.gPageLoader; +Object.defineProperty(this, "gPageLoader", { + configurable: true, + enumerable: true, + get() { + var webnav = viewSourceChrome.webNav; + if (!webnav) + return null; + delete this.gPageLoader; + this.gPageLoader = (webnav instanceof Ci.nsIWebPageDescriptor) ? webnav + : null; + return this.gPageLoader; + }, }); // Strips the |view-source:| for internalSave() @@ -800,11 +808,15 @@ function ViewSourceSavePage() { // Below are old deprecated functions and variables left behind for // compatibility reasons. These will be removed soon via bug 1159293. -this.__defineGetter__("gLastLineFound", function() { - Deprecated.warning("gLastLineFound is deprecated - please use " + - "viewSourceChrome.lastLineFound instead.", - "https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications"); - return viewSourceChrome.lastLineFound; +Object.defineProperty(this, "gLastLineFound", { + configurable: true, + enumerable: true, + get() { + Deprecated.warning("gLastLineFound is deprecated - please use " + + "viewSourceChrome.lastLineFound instead.", + "https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications"); + return viewSourceChrome.lastLineFound; + }, }); function onLoadViewSource() { diff --git a/toolkit/content/globalOverlay.js b/toolkit/content/globalOverlay.js index dc849627947e..ae50c33d8b58 100644 --- a/toolkit/content/globalOverlay.js +++ b/toolkit/content/globalOverlay.js @@ -147,9 +147,13 @@ function setTooltipText(aID, aTooltipText) { element.setAttribute("tooltiptext", aTooltipText); } -this.__defineGetter__("NS_ASSERT", function() { - delete this.NS_ASSERT; - var tmpScope = {}; - Components.utils.import("resource://gre/modules/debug.js", tmpScope); - return this.NS_ASSERT = tmpScope.NS_ASSERT; +Object.defineProperty(this, "NS_ASSERT", { + configurable: true, + enumerable: true, + get() { + delete this.NS_ASSERT; + var tmpScope = {}; + Components.utils.import("resource://gre/modules/debug.js", tmpScope); + return this.NS_ASSERT = tmpScope.NS_ASSERT; + }, }); diff --git a/toolkit/mozapps/downloads/DownloadUtils.jsm b/toolkit/mozapps/downloads/DownloadUtils.jsm index 83e837e353b5..952198e76566 100644 --- a/toolkit/mozapps/downloads/DownloadUtils.jsm +++ b/toolkit/mozapps/downloads/DownloadUtils.jsm @@ -49,9 +49,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", const MS_PER_DAY = 24 * 60 * 60 * 1000; -this.__defineGetter__("gDecimalSymbol", function() { +Object.defineProperty(this, "gDecimalSymbol", { + configurable: true, + enumerable: true, + get() { delete this.gDecimalSymbol; return this.gDecimalSymbol = Number(5.4).toLocaleString().match(/\D/); + }, }); var localeNumberFormatCache = new Map(); @@ -95,11 +99,15 @@ var gStr = { }; // This lazily initializes the string bundle upon first use. -this.__defineGetter__("gBundle", function() { - delete this.gBundle; - return this.gBundle = Cc["@mozilla.org/intl/stringbundle;1"]. - getService(Ci.nsIStringBundleService). - createBundle(kDownloadProperties); +Object.defineProperty(this, "gBundle", { + configurable: true, + enumerable: true, + get() { + delete this.gBundle; + return this.gBundle = Cc["@mozilla.org/intl/stringbundle;1"]. + getService(Ci.nsIStringBundleService). + createBundle(kDownloadProperties); + }, }); // Keep track of at most this many second/lastSec pairs so that multiple calls