From 9f2a58c64c1c773a0989b685b0e509e493bcc769 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Fri, 2 Feb 2018 16:15:53 -0800 Subject: [PATCH] Bug 1435437 - Expose gNavigatorBundle as a plain JS object with a stringbundle-like API;r=Gijs This will allow us to not rely on an actual while still avoiding a mass rewrite of code that accesses gNavigatorBundle with the more awkward API exposed by gBrowserBundle. MozReview-Commit-ID: 2B4smbo1xZP --HG-- extra : rebase_source : 0f2eef9178cb61802f158efe88b82a723f5e082e --- browser/base/content/browser.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index faa2591778a4..aa7d71dc2412 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -143,6 +143,18 @@ if (AppConstants.MOZ_CRASHREPORTER) { XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() { return Services.strings.createBundle("chrome://browser/locale/browser.properties"); }); +XPCOMUtils.defineLazyGetter(this, "gNavigatorBundle", function() { + // This is a stringbundle-like interface to gBrowserBundle, formerly a getter for + // the "bundle_browser" element. + return { + getString(key) { + return gBrowserBundle.GetStringFromName(key); + }, + getFormattedString(key, array) { + return gBrowserBundle.formatStringFromName(key, array, array.length); + } + }; +}); XPCOMUtils.defineLazyGetter(this, "gTabBrowserBundle", function() { return Services.strings.createBundle("chrome://browser/locale/tabbrowser.properties"); }); @@ -224,12 +236,11 @@ if (AppConstants.platform != "macosx") { var gEditUIVisible = true; } -/* globals gBrowser, gNavToolbox, gURLBar:true, gNavigatorBundle*/ +/* globals gBrowser, gNavToolbox, gURLBar:true */ [ ["gBrowser", "content"], ["gNavToolbox", "navigator-toolbox"], ["gURLBar", "urlbar"], - ["gNavigatorBundle", "bundle_browser"] ].forEach(function(elementGlobal) { var [name, id] = elementGlobal; Object.defineProperty(window, name, {