Bug 1355382 - Use ChromeRegistry in Marionette Puppet when LocaleService is not available. r=whimboo
MozReview-Commit-ID: Hh7mvyWVKzu
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/appinfo.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/appinfo.py
@@ -25,19 +25,29 @@ class AppInfo(BaseLib):
else:
raise AttributeError('{} has no attribute {}'.format(self.__class__.__name__,
attr))
@property
def locale(self):
with self.marionette.using_context('chrome'):
return self.marionette.execute_script("""
- return Components.classes["@mozilla.org/intl/localeservice;1"]
- .getService(Components.interfaces.mozILocaleService)
- .getAppLocaleAsLangTag();
+ // LocaleService has been added in 55, use ChromeRegistry for
+ // earlier releases.
+ // The ChromeRegistry path can be removed when 52esr is not longer
+ // supported.
+ try {
+ return Components.classes["@mozilla.org/intl/localeservice;1"]
+ .getService(Components.interfaces.mozILocaleService)
+ .getAppLocaleAsLangTag();
+ } catch (e) {
+ return Components.classes["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Components.interfaces.nsIXULChromeRegistry)
+ .getSelectedLocale("global");
+ }
""")
@property
def user_agent(self):
with self.marionette.using_context('chrome'):
return self.marionette.execute_script("""
return Components.classes["@mozilla.org/network/protocol;1?name=http"]
.getService(Components.interfaces.nsIHttpProtocolHandler)