author | Omkar Konaraddi <okonaraddi@mozilla.com> |
Fri, 12 Jul 2019 22:43:06 +0000 | |
changeset 543186 | 284d6fb99eb35d77efaf35ddf0eec696d619aaba |
parent 543185 | 9b64d5b7a63c9ea623e8dbd00bf5ad1e9d012a34 |
child 543187 | a4317ff40faee52fc7278424dedb313e0e741695 |
push id | 11848 |
push user | ffxbld-merge |
push date | Mon, 26 Aug 2019 19:26:25 +0000 |
treeherder | mozilla-beta@9b31bfdfac10 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | adw |
bugs | 1526818 |
milestone | 70.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm +++ b/browser/components/urlbar/UrlbarProviderUnifiedComplete.jsm @@ -31,22 +31,16 @@ XPCOMUtils.defineLazyServiceGetter( "@mozilla.org/autocomplete/search;1?name=unifiedcomplete", "nsIAutoCompleteSearch" ); XPCOMUtils.defineLazyGetter(this, "logger", () => Log.repository.getLogger("Urlbar.Provider.UnifiedComplete") ); -XPCOMUtils.defineLazyGetter(this, "bundle", () => - Services.strings.createBundle( - "chrome://global/locale/autocomplete.properties" - ) -); - // See UnifiedComplete. const TITLE_TAGS_SEPARATOR = " \u2013 "; /** * Class used to create the provider. */ class ProviderUnifiedComplete extends UrlbarProvider { constructor() { @@ -294,23 +288,26 @@ function makeUrlbarResult(tokens, info) if (!title) { // If the url doesn't have an host (e.g. javascript urls), comment // will be empty, and we can't build the usual title. Thus use the url. title = Services.textToSubURI.unEscapeURIForUI( "UTF-8", action.params.url ); } else if (tokens && tokens.length > 1) { - title = bundle.formatStringFromName("bookmarkKeywordSearch", [ - info.comment, - tokens - .slice(1) - .map(t => t.value) - .join(" "), - ]); + title = UrlbarUtils.strings.formatStringFromName( + "bookmarkKeywordSearch", + [ + info.comment, + tokens + .slice(1) + .map(t => t.value) + .join(" "), + ] + ); } return new UrlbarResult( UrlbarUtils.RESULT_TYPE.KEYWORD, UrlbarUtils.RESULT_SOURCE.BOOKMARKS, ...UrlbarResult.payloadAndSimpleHighlights(tokens, { title: [title, UrlbarUtils.HIGHLIGHT.TYPED], url: [action.params.url, UrlbarUtils.HIGHLIGHT.TYPED], keyword: [info.firstToken.value, UrlbarUtils.HIGHLIGHT.TYPED],
--- a/browser/components/urlbar/UrlbarUtils.jsm +++ b/browser/components/urlbar/UrlbarUtils.jsm @@ -427,16 +427,22 @@ var UrlbarUtils = { }); }, }; XPCOMUtils.defineLazyGetter(UrlbarUtils.ICON, "DEFAULT", () => { return PlacesUtils.favicons.defaultFavicon.spec; }); +XPCOMUtils.defineLazyGetter(UrlbarUtils, "strings", () => { + return Services.strings.createBundle( + "chrome://global/locale/autocomplete.properties" + ); +}); + /** * UrlbarQueryContext defines a user's autocomplete input from within the urlbar. * It supplements it with details of how the search results should be obtained * and what they consist of. */ class UrlbarQueryContext { /** * Constructs the UrlbarQueryContext instance.
--- a/browser/components/urlbar/UrlbarView.jsm +++ b/browser/components/urlbar/UrlbarView.jsm @@ -5,29 +5,22 @@ "use strict"; var EXPORTED_SYMBOLS = ["UrlbarView"]; const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); XPCOMUtils.defineLazyModuleGetters(this, { - Services: "resource://gre/modules/Services.jsm", UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm", UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm", UrlbarUtils: "resource:///modules/UrlbarUtils.jsm", AppConstants: "resource://gre/modules/AppConstants.jsm", }); -XPCOMUtils.defineLazyGetter(this, "bundle", function() { - return Services.strings.createBundle( - "chrome://global/locale/autocomplete.properties" - ); -}); - /** * Receives and displays address bar autocomplete results. */ class UrlbarView { /** * @param {UrlbarInput} input * The UrlbarInput instance belonging to this UrlbarView instance. */ @@ -626,25 +619,25 @@ class UrlbarView { ); } let action = ""; let isVisitAction = false; let setURL = false; switch (result.type) { case UrlbarUtils.RESULT_TYPE.TAB_SWITCH: - action = bundle.GetStringFromName("switchToTab2"); + action = UrlbarUtils.strings.GetStringFromName("switchToTab2"); setURL = true; break; case UrlbarUtils.RESULT_TYPE.REMOTE_TAB: action = result.payload.device; setURL = true; break; case UrlbarUtils.RESULT_TYPE.SEARCH: - action = bundle.formatStringFromName("searchWithEngine", [ + action = UrlbarUtils.strings.formatStringFromName("searchWithEngine", [ result.payload.engine, ]); break; case UrlbarUtils.RESULT_TYPE.KEYWORD: isVisitAction = result.payload.input.trim() == result.payload.keyword; break; case UrlbarUtils.RESULT_TYPE.OMNIBOX: action = result.payload.content; @@ -670,17 +663,17 @@ class UrlbarView { url.textContent = ""; url._tooltip = ""; } if (url.hasAttribute("overflow")) { url.setAttribute("title", url._tooltip); } if (isVisitAction) { - action = bundle.GetStringFromName("visit"); + action = UrlbarUtils.strings.GetStringFromName("visit"); title.setAttribute("isurl", "true"); } else { title.removeAttribute("isurl"); } item._elements.get("action").textContent = action; item._elements.get("titleSeparator").hidden = !action && !setURL; } @@ -850,19 +843,20 @@ class UrlbarView { } result.payload.engine = engine.name; } else if (result.payload.originalEngine) { result.payload.engine = result.payload.originalEngine; delete result.payload.originalEngine; } let item = this._rows.children[i]; let action = item.querySelector(".urlbarView-action"); - action.textContent = bundle.formatStringFromName("searchWithEngine", [ - (engine && engine.name) || result.payload.engine, - ]); + action.textContent = UrlbarUtils.strings.formatStringFromName( + "searchWithEngine", + [(engine && engine.name) || result.payload.engine] + ); // If we just changed the engine from the original engine and it had an // icon, then make sure the result now uses the new engine's icon or // failing that the default icon. If we changed it back to the original // engine, go back to the original or default icon. let favicon = item.querySelector(".urlbarView-favicon"); if (engine && result.payload.icon) { favicon.src = (engine.iconURI && engine.iconURI.spec) ||
--- a/browser/components/urlbar/tests/browser/browser_keyword.js +++ b/browser/components/urlbar/tests/browser/browser_keyword.js @@ -82,19 +82,17 @@ add_task(async function test_display_key ); Assert.equal( result.displayed.title, "example.com", "Node should contain the name of the bookmark" ); Assert.equal( result.displayed.action, - Services.strings - .createBundle("chrome://global/locale/autocomplete.properties") - .GetStringFromName("visit"), + UrlbarUtils.strings.GetStringFromName("visit"), "Should have visit indicated" ); }); add_task(async function test_keyword_using_get() { let tab = await BrowserTestUtils.openNewForegroundTab( gBrowser, "about:mozilla"
--- a/browser/components/urlbar/tests/browser/browser_search_favicon.js +++ b/browser/components/urlbar/tests/browser/browser_search_favicon.js @@ -46,19 +46,18 @@ add_task(async function() { // The first autocomplete result has the action searchengine, while // the second result is the "search favicon" element. await promiseAutocompleteResultPopup("foo"); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 1); Assert.equal(result.type, UrlbarUtils.RESULT_TYPE.SEARCH); Assert.equal(result.displayed.title, "foobar"); - let bundle = Services.strings.createBundle( - "chrome://global/locale/autocomplete.properties" - ); Assert.equal( result.displayed.action, - bundle.formatStringFromName("searchWithEngine", ["SearchEngine"]), + UrlbarUtils.strings.formatStringFromName("searchWithEngine", [ + "SearchEngine", + ]), "Should have the correct action text" ); gBrowser.removeCurrentTab(); });
--- a/browser/components/urlbar/tests/browser/browser_urlbarDecode.js +++ b/browser/components/urlbar/tests/browser/browser_urlbarDecode.js @@ -126,14 +126,12 @@ async function checkInput(inputStr) { Assert.equal( result.displayed.title, inputStr.replace("\\", "/"), "Should be displaying the correct text" ); Assert.equal( result.displayed.action, - Services.strings - .createBundle("chrome://global/locale/autocomplete.properties") - .GetStringFromName("visit"), + UrlbarUtils.strings.GetStringFromName("visit"), "Should be displaying the correct action text" ); }