From 5630cfb1700aea1b182dae9fc4bd278672837de1 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Wed, 14 Dec 2016 14:20:41 +0100 Subject: [PATCH] Bug 1316984 - Update Puppeteer to use new localization module of Marionette. r=maja_zf MozReview-Commit-ID: 5BZDyWGUz0a --HG-- extra : rebase_source : d3d067dba7f54755df7f797063fbf4fab8ce2b2a --- .../keyboard_shortcuts/test_browser_window.py | 5 +- .../test_about_private_browsing.py | 2 +- .../security/test_dv_certificate.py | 4 +- .../security/test_ev_certificate.py | 4 +- .../security/test_no_certificate.py | 4 +- .../test_safe_browsing_notification.py | 4 +- .../security/test_ssl_disabled_error_page.py | 2 +- .../security/test_ssl_status_after_restart.py | 2 +- .../test_submit_unencrypted_info_warning.py | 2 +- .../firefox-ui/tests/puppeteer/test_l10n.py | 14 +- .../tests/puppeteer/test_page_info_window.py | 3 +- .../firefox/firefox_puppeteer/api/l10n.py | 121 +++++++++++------- .../firefox_puppeteer/ui/browser/tabbar.py | 6 +- .../firefox_puppeteer/ui/browser/toolbars.py | 6 +- .../firefox_puppeteer/ui/browser/window.py | 6 +- .../firefox_puppeteer/ui/pageinfo/window.py | 2 +- .../firefox/firefox_puppeteer/ui/windows.py | 8 +- 17 files changed, 117 insertions(+), 78 deletions(-) diff --git a/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py b/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py index d820972e0949..5b656d0e5fd4 100644 --- a/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py +++ b/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py @@ -16,7 +16,7 @@ class TestBrowserWindowShortcuts(PuppeteerMixin, MarionetteTestCase): # TODO: To be moved to the upcoming add-ons library def opener(tab): - tab.window.send_shortcut(tab.window.get_entity('addons.commandkey'), + tab.window.send_shortcut(tab.window.localize_entity('addons.commandkey'), accel=True, shift=True) self.browser.tabbar.open_tab(opener) @@ -41,7 +41,8 @@ class TestBrowserWindowShortcuts(PuppeteerMixin, MarionetteTestCase): key = 'searchFocusUnix.commandkey' else: key = 'searchFocus.commandkey' - self.browser.send_shortcut(self.browser.get_entity(key), accel=True) + self.browser.send_shortcut(self.browser.localize_entity(key), + accel=True) # TODO: Check that the right input box is focused # Located below searchbar as class="autocomplete-textbox textbox-input" diff --git a/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py b/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py index 55b92f53e225..1babc0b58c41 100644 --- a/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py +++ b/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py @@ -33,7 +33,7 @@ class TestAboutPrivateBrowsing(PuppeteerMixin, MarionetteTestCase): status_node = self.marionette.find_element(By.CSS_SELECTOR, 'p.showNormal') self.assertEqual(status_node.text, - self.browser.get_entity('aboutPrivateBrowsing.notPrivate'), + self.browser.localize_entity('aboutPrivateBrowsing.notPrivate'), 'Status text indicates we are not in private browsing mode') def window_opener(win): diff --git a/testing/firefox-ui/tests/functional/security/test_dv_certificate.py b/testing/firefox-ui/tests/functional/security/test_dv_certificate.py index 541cc7e57266..686a65463ce0 100644 --- a/testing/firefox-ui/tests/functional/security/test_dv_certificate.py +++ b/testing/firefox-ui/tests/functional/security/test_dv_certificate.py @@ -61,7 +61,7 @@ class TestDVCertificate(PuppeteerMixin, MarionetteTestCase): insecure_label = self.identity_popup.view.security.insecure_connection_label self.assertEqual(insecure_label.value_of_css_property('display'), 'none') - verifier_label = self.browser.get_property('identity.identified.verifier') + verifier_label = self.browser.localize_property('identity.identified.verifier') self.assertEqual(self.identity_popup.view.security.verifier.get_attribute('textContent'), verifier_label.replace("%S", cert['issuerOrganization'])) @@ -77,7 +77,7 @@ class TestDVCertificate(PuppeteerMixin, MarionetteTestCase): cert['commonName']) self.assertEqual(deck.security.owner.get_attribute('value'), - page_info_window.get_property('securityNoOwner')) + page_info_window.localize_property('securityNoOwner')) self.assertEqual(deck.security.verifier.get_attribute('value'), cert['issuerOrganization']) diff --git a/testing/firefox-ui/tests/functional/security/test_ev_certificate.py b/testing/firefox-ui/tests/functional/security/test_ev_certificate.py index 7e46b21f9c9c..4602983c684f 100644 --- a/testing/firefox-ui/tests/functional/security/test_ev_certificate.py +++ b/testing/firefox-ui/tests/functional/security/test_ev_certificate.py @@ -79,14 +79,14 @@ class TestEVCertificate(PuppeteerMixin, MarionetteTestCase): # Check the owner location string # More information: # hg.mozilla.org/mozilla-central/file/eab4a81e4457/browser/base/content/browser.js#l7012 - location = self.browser.get_property('identity.identified.state_and_country') + location = self.browser.localize_property('identity.identified.state_and_country') location = location.replace('%S', address['state'], 1).replace('%S', address['country']) location = address['city'] + '\n' + location self.assertEqual(security_view.owner_location.get_attribute('textContent'), location) # Check the verifier - l10n_verifier = self.browser.get_property('identity.identified.verifier') + l10n_verifier = self.browser.localize_property('identity.identified.verifier') l10n_verifier = l10n_verifier.replace('%S', cert['issuerOrganization']) self.assertEqual(security_view.verifier.get_attribute('textContent'), l10n_verifier) diff --git a/testing/firefox-ui/tests/functional/security/test_no_certificate.py b/testing/firefox-ui/tests/functional/security/test_no_certificate.py index 781f17b216e9..e3954d0ba5bc 100644 --- a/testing/firefox-ui/tests/functional/security/test_no_certificate.py +++ b/testing/firefox-ui/tests/functional/security/test_no_certificate.py @@ -74,8 +74,8 @@ class TestNoCertificate(PuppeteerMixin, MarionetteTestCase): # Check the owner label equals localized 'securityNoOwner' self.assertEqual(page_info.deck.security.owner.get_attribute('value'), - page_info.get_property('securityNoOwner')) + page_info.localize_property('securityNoOwner')) # Check the verifier label equals localized 'notset' self.assertEqual(page_info.deck.security.verifier.get_attribute('value'), - page_info.get_property('notset')) + page_info.localize_property('notset')) diff --git a/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py b/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py index 39320bee66a6..2b4858e58760 100644 --- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py +++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py @@ -107,7 +107,7 @@ class TestSafeBrowsingNotificationBar(PuppeteerMixin, MarionetteTestCase): def check_not_badware_button(self, button_property, report_page): with self.marionette.using_context('chrome'): # TODO: update to use safe browsing notification bar class when bug 1139544 lands - label = self.browser.get_property(button_property) + label = self.browser.localize_property(button_property) button = (self.marionette.find_element(By.ID, 'content') .find_element('anon attribute', {'label': label})) @@ -124,7 +124,7 @@ class TestSafeBrowsingNotificationBar(PuppeteerMixin, MarionetteTestCase): def check_get_me_out_of_here_button(self): with self.marionette.using_context('chrome'): # TODO: update to use safe browsing notification bar class when bug 1139544 lands - label = self.browser.get_property('safebrowsing.getMeOutOfHereButton.label') + label = self.browser.localize_property('safebrowsing.getMeOutOfHereButton.label') button = (self.marionette.find_element(By.ID, 'content') .find_element('anon attribute', {'label': label})) button.click() diff --git a/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py b/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py index a2ab81e3342b..80d017f08f67 100644 --- a/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py +++ b/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py @@ -42,7 +42,7 @@ class TestSSLDisabledErrorPage(PuppeteerMixin, MarionetteTestCase): # Verify "Secure Connection Failed" error page title title = self.marionette.find_element(By.CLASS_NAME, 'title-text') - nss_failure2title = self.browser.get_entity('nssFailure2.title') + nss_failure2title = self.browser.localize_entity('nssFailure2.title') self.assertEquals(title.get_property('textContent'), nss_failure2title) # Verify the error message is correct diff --git a/testing/firefox-ui/tests/functional/security/test_ssl_status_after_restart.py b/testing/firefox-ui/tests/functional/security/test_ssl_status_after_restart.py index 33b2e05508ea..8f1cf8d9f1eb 100644 --- a/testing/firefox-ui/tests/functional/security/test_ssl_status_after_restart.py +++ b/testing/firefox-ui/tests/functional/security/test_ssl_status_after_restart.py @@ -112,7 +112,7 @@ class TestSSLStatusAfterRestart(PuppeteerMixin, MarionetteTestCase): if identity != '': owner = cert['organization'] else: - owner = page_info.get_property('securityNoOwner') + owner = page_info.localize_property('securityNoOwner') self.assertEqual(page_info.deck.security.owner.get_attribute('value'), owner, 'Expected owner label found for ' + url) diff --git a/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py b/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py index 64506eed5146..640d00c1c408 100644 --- a/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py +++ b/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py @@ -38,7 +38,7 @@ class TestSubmitUnencryptedInfoWarning(PuppeteerMixin, MarionetteTestCase): button.click() # Get the expected warning text and replace its two instances of "##" with "\n\n". - message = self.browser.get_property('formPostSecureToInsecureWarning.message') + message = self.browser.localize_property('formPostSecureToInsecureWarning.message') message = message.replace('##', '\n\n') # Wait for the warning, verify the expected text matches warning, accept the warning diff --git a/testing/firefox-ui/tests/puppeteer/test_l10n.py b/testing/firefox-ui/tests/puppeteer/test_l10n.py index 73538ac53c57..08f41f9d71a3 100644 --- a/testing/firefox-ui/tests/puppeteer/test_l10n.py +++ b/testing/firefox-ui/tests/puppeteer/test_l10n.py @@ -5,7 +5,7 @@ from firefox_puppeteer import PuppeteerMixin from firefox_puppeteer.api.l10n import L10n from marionette_driver import By -from marionette_driver.errors import MarionetteException +from marionette_driver.errors import NoSuchElementException from marionette_harness import MarionetteTestCase @@ -20,17 +20,18 @@ class TestL10n(PuppeteerMixin, MarionetteTestCase): dtds = ['chrome://global/locale/about.dtd', 'chrome://browser/locale/baseMenuOverlay.dtd'] - value = self.l10n.get_entity(dtds, 'helpSafeMode.label') + value = self.l10n.localize_entity(dtds, 'helpSafeMode.label') elm = self.marionette.find_element(By.ID, 'helpSafeMode') self.assertEqual(value, elm.get_attribute('label')) - self.assertRaises(MarionetteException, self.l10n.get_entity, dtds, 'notExistent') + self.assertRaises(NoSuchElementException, + self.l10n.localize_entity, dtds, 'notExistent') def test_dtd_entity_content(self): dtds = ['chrome://global/locale/about.dtd', 'chrome://global/locale/aboutSupport.dtd'] - value = self.l10n.get_entity(dtds, 'aboutSupport.pageTitle') + value = self.l10n.localize_entity(dtds, 'aboutSupport.pageTitle') self.marionette.set_context(self.marionette.CONTEXT_CONTENT) self.marionette.navigate('about:support') @@ -43,7 +44,8 @@ class TestL10n(PuppeteerMixin, MarionetteTestCase): 'chrome://global/locale/findbar.properties'] # TODO: Find a way to verify the retrieved translated string - value = self.l10n.get_property(properties, 'NotFound') + value = self.l10n.localize_property(properties, 'NotFound') self.assertNotEqual(value, '') - self.assertRaises(MarionetteException, self.l10n.get_property, properties, 'notExistent') + self.assertRaises(NoSuchElementException, + self.l10n.localize_property, properties, 'notExistent') diff --git a/testing/firefox-ui/tests/puppeteer/test_page_info_window.py b/testing/firefox-ui/tests/puppeteer/test_page_info_window.py index 82ca2bd9f322..f73d139d4412 100644 --- a/testing/firefox-ui/tests/puppeteer/test_page_info_window.py +++ b/testing/firefox-ui/tests/puppeteer/test_page_info_window.py @@ -82,7 +82,8 @@ class TestPageInfoWindow(PuppeteerMixin, MarionetteTestCase): def test_close_window(self): """Test various closing strategies.""" def closer(win): - win.send_shortcut(win.get_entity('closeWindow.key'), accel=True) + win.send_shortcut(win.localize_entity('closeWindow.key'), + accel=True) # Close a tab by each trigger method close_strategies = ('menu', diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/l10n.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/l10n.py index dec554354c88..f7f52918c356 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/l10n.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/l10n.py @@ -2,16 +2,44 @@ # 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/. +# ----------------- +# DEPRECATED module +# ----------------- +# Replace its use in tests when Firefox 45 ESR support ends with +# marionette_driver.localization.L10n + import copy -from marionette_driver.errors import MarionetteException +from marionette_driver.errors import ( + NoSuchElementException, + UnknownCommandException, +) +from marionette_driver.localization import L10n as L10nMarionette from firefox_puppeteer.base import BaseLib class L10n(BaseLib): + """An API which allows Marionette to handle localized content. - def get_entity(self, dtd_urls, entity_id): + .. deprecated:: 52.2.0 + Use the localization module from :py:mod:`marionette_driver` instead. + + The `localization`_ of UI elements in Gecko based applications is done via + entities and properties. For static values entities are used, which are located + in .dtd files. Whereby for dynamically updated content the values come from + .property files. Both types of elements can be identifed via a unique id, + and the translated content retrieved. + + .. _localization: https://mzl.la/2eUMjyF + """ + + def __init__(self, marionette): + super(L10n, self).__init__(marionette) + + self._l10nMarionette = L10nMarionette(self.marionette) + + def localize_entity(self, dtd_urls, entity_id): """Returns the localized string for the specified DTD entity id. To find the entity all given DTD files will be searched for the id. @@ -21,39 +49,42 @@ class L10n(BaseLib): :returns: The localized string for the requested entity. - :raises MarionetteException: When entity id is not found in dtd_urls. + :raises NoSuchElementException: When entity id is not found in dtd_urls. """ # Add xhtml11.dtd to prevent missing entity errors with XHTML files - dtds = copy.copy(dtd_urls) - dtds.append("resource:///res/dtd/xhtml11.dtd") + try: + return self._l10nMarionette.localize_entity(dtd_urls, entity_id) + except UnknownCommandException: + dtds = copy.copy(dtd_urls) + dtds.append("resource:///res/dtd/xhtml11.dtd") - dtd_refs = '' - for index, item in enumerate(dtds): - dtd_id = 'dtd_%s' % index - dtd_refs += '%%%s;' % \ - (dtd_id, item, dtd_id) + dtd_refs = '' + for index, item in enumerate(dtds): + dtd_id = 'dtd_%s' % index + dtd_refs += '%%%s;' % \ + (dtd_id, item, dtd_id) - contents = """ - + contents = """ + - &%s;""" % (dtd_refs, entity_id) + &%s;""" % (dtd_refs, entity_id) - with self.marionette.using_context('chrome'): - value = self.marionette.execute_script(""" - var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] - .createInstance(Components.interfaces.nsIDOMParser); - var doc = parser.parseFromString(arguments[0], "text/xml"); - var node = doc.querySelector("elem[id='entity']"); + with self.marionette.using_context('chrome'): + value = self.marionette.execute_script(""" + var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); + var doc = parser.parseFromString(arguments[0], "text/xml"); + var node = doc.querySelector("elem[id='entity']"); - return node ? node.textContent : null; - """, script_args=[contents]) + return node ? node.textContent : null; + """, script_args=[contents]) - if not value: - raise MarionetteException('DTD Entity not found: %s' % entity_id) + if not value: + raise NoSuchElementException('DTD Entity not found: %s' % entity_id) - return value + return value - def get_property(self, property_urls, property_id): + def localize_property(self, property_urls, property_id): """Returns the localized string for the specified property id. To find the property all given property files will be searched for @@ -64,29 +95,31 @@ class L10n(BaseLib): :returns: The localized string for the requested entity. - :raises MarionetteException: When property id is not found in + :raises NoSuchElementException: When property id is not found in property_urls. """ + try: + return self._l10nMarionette.localize_property(property_urls, property_id) + except UnknownCommandException: + with self.marionette.using_context('chrome'): + value = self.marionette.execute_script(""" + let property = null; + let property_id = arguments[1]; - with self.marionette.using_context('chrome'): - value = self.marionette.execute_script(""" - let property = null; - let property_id = arguments[1]; + arguments[0].some(aUrl => { + let bundle = Services.strings.createBundle(aUrl); - arguments[0].some(aUrl => { - let bundle = Services.strings.createBundle(aUrl); + try { + property = bundle.GetStringFromName(property_id); + return true; + } + catch (ex) { } + }); - try { - property = bundle.GetStringFromName(property_id); - return true; - } - catch (ex) { } - }); + return property; + """, script_args=[property_urls, property_id]) - return property; - """, script_args=[property_urls, property_id]) + if not value: + raise NoSuchElementException('Property not found: %s' % property_id) - if not value: - raise MarionetteException('Property not found: %s' % property_id) - - return value + return value diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py index 1c4379a941f9..d59aeb38a354 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py @@ -133,7 +133,8 @@ class TabBar(UIBaseLib): self.window.menubar.select_by_id('file-menu', 'menu_newNavigatorTab') elif trigger == 'shortcut': - self.window.send_shortcut(self.window.get_entity('tabCmd.commandkey'), accel=True) + self.window.send_shortcut(self.window.localize_entity('tabCmd.commandkey'), + accel=True) # elif - need to add other cases else: raise ValueError('Unknown opening method: "%s"' % trigger) @@ -312,7 +313,8 @@ class Tab(UIBaseLib): elif trigger == 'menu': self.window.menubar.select_by_id('file-menu', 'menu_close') elif trigger == 'shortcut': - self.window.send_shortcut(self.window.get_entity('closeCmd.key'), accel=True) + self.window.send_shortcut(self.window.localize_entity('closeCmd.key'), + accel=True) else: raise ValueError('Unknown closing method: "%s"' % trigger) diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py index 83b3f917de1e..dc5c63110f08 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py @@ -149,7 +149,7 @@ class LocationBar(UIBaseLib): if event == 'click': self.urlbar.click() elif event == 'shortcut': - cmd_key = self.window.get_entity('openCmd.commandkey') + cmd_key = self.window.localize_entity('openCmd.commandkey') self.window.send_shortcut(cmd_key, accel=True) else: raise ValueError("An unknown event type was passed: %s" % event) @@ -263,7 +263,7 @@ class LocationBar(UIBaseLib): if trigger == 'button': self.reload_button.click() elif trigger == 'shortcut': - cmd_key = self.window.get_entity('reloadCmd.commandkey') + cmd_key = self.window.localize_entity('reloadCmd.commandkey') self.window.send_shortcut(cmd_key) elif trigger == 'shortcut2': self.window.send_shortcut(keys.Keys.F5) @@ -604,7 +604,7 @@ class IdentityPopupSecurityView(IdentityPopupView): :returns: Reference to the identity-popup more info button. """ - label = self.window.get_entity('identity.moreInfoLinkText2') + label = self.window.localize_entity('identity.moreInfoLinkText2') return self.element.find_element(By.CSS_SELECTOR, u'button[label="{}"]'.format(label)) diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py index 743e0fb6eb73..0aa63b759a14 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py @@ -161,7 +161,7 @@ class BrowserWindow(BaseWindow): elif trigger == 'menu': self.menubar.select_by_id('file-menu', 'menu_closeWindow') elif trigger == 'shortcut': - win.send_shortcut(win.get_entity('closeCmd.key'), + win.send_shortcut(win.localize_entity('closeCmd.key'), accel=True, shift=True) else: raise ValueError('Unknown closing method: "%s"' % trigger) @@ -200,7 +200,7 @@ class BrowserWindow(BaseWindow): self.menubar.select_by_id('file-menu', menu_id) elif trigger == 'shortcut': cmd_key = 'privateBrowsingCmd.commandkey' if is_private else 'newNavigatorCmd.key' - win.send_shortcut(win.get_entity(cmd_key), + win.send_shortcut(win.localize_entity(cmd_key), accel=True, shift=is_private) else: raise ValueError('Unknown opening method: "%s"' % trigger) @@ -245,7 +245,7 @@ class BrowserWindow(BaseWindow): elif trigger == 'shortcut': if win.marionette.session_capabilities['platformName'] == 'windows_nt': raise ValueError('Page info shortcut not available on Windows.') - win.send_shortcut(win.get_entity('pageInfoCmd.commandkey'), + win.send_shortcut(win.localize_entity('pageInfoCmd.commandkey'), accel=True) elif trigger == 'context_menu': # TODO: Add once we can do right clicks diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py index 99856b11211e..070f39f790cb 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py @@ -50,7 +50,7 @@ class PageInfoWindow(BaseWindow): elif trigger == 'menu': self.menubar.select_by_id('file-menu', 'menu_close') elif trigger == 'shortcut': - win.send_shortcut(win.get_entity('closeWindow.key'), + win.send_shortcut(win.localize_entity('closeWindow.key'), accel=True) else: raise ValueError('Unknown closing method: "%s"' % trigger) diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py index 4110d24bb162..42c1dcf35ec7 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py @@ -313,7 +313,7 @@ class BaseWindow(BaseLib): """Sets the focus to the current chrome window.""" return self._windows.focus(self.handle) - def get_entity(self, entity_id): + def localize_entity(self, entity_id): """Returns the localized string for the specified DTD entity id. :param entity_id: The id to retrieve the value from. @@ -322,9 +322,9 @@ class BaseWindow(BaseLib): :raises MarionetteException: When entity id is not found. """ - return self._l10n.get_entity(self.dtds, entity_id) + return self._l10n.localize_entity(self.dtds, entity_id) - def get_property(self, property_id): + def localize_property(self, property_id): """Returns the localized string for the specified property id. :param property_id: The id to retrieve the value from. @@ -333,7 +333,7 @@ class BaseWindow(BaseLib): :raises MarionetteException: When property id is not found. """ - return self._l10n.get_property(self.properties, property_id) + return self._l10n.localize_property(self.properties, property_id) def open_window(self, callback=None, expected_window_class=None, focus=True): """Opens a new top-level chrome window.