--- a/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py
+++ b/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py
@@ -11,17 +11,17 @@ class TestBrowserWindowShortcuts(Puppete
def test_addons_manager(self):
# If an about:xyz page is visible, no new tab will be opened
with self.marionette.using_context('content'):
self.marionette.navigate('about:')
# 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)
# TODO: Marionette currently fails to detect the correct tab
# with self.marionette.using_content('content'):
# self.wait_for_condition(lambda mn: mn.get_url() == "about:addons")
# TODO: remove extra switch once it is done automatically
@@ -36,17 +36,18 @@ class TestBrowserWindowShortcuts(Puppete
# This doesn't test anything if we're already at input.
self.assertNotEqual(current_name, "input")
# TODO: To be moved to the upcoming search library
if self.puppeteer.platform == 'linux':
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"
# Anon locator has not been released yet (bug 1080764)
def has_input_selected(mn):
selection_name = mn.execute_script("""
return window.document.activeElement.localName;
""")
--- 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
@@ -28,17 +28,17 @@ class TestAboutPrivateBrowsing(Puppeteer
def testCheckAboutPrivateBrowsing(self):
self.assertFalse(self.browser.is_private)
with self.marionette.using_context('content'):
self.marionette.navigate('about:privatebrowsing')
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):
with win.marionette.using_context('content'):
button = self.marionette.find_element(By.ID, 'startPrivateBrowsing')
button.click()
pb_window = self.browser.open_window(callback=window_opener,
--- a/testing/firefox-ui/tests/functional/security/test_dv_certificate.py
+++ b/testing/firefox-ui/tests/functional/security/test_dv_certificate.py
@@ -56,28 +56,28 @@ class TestDVCertificate(PuppeteerMixin,
# Only the secure label is visible in the security view
secure_label = self.identity_popup.view.security.secure_connection_label
self.assertNotEqual(secure_label.value_of_css_property('display'), 'none')
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']))
def opener(mn):
self.identity_popup.view.security.more_info_button.click()
page_info_window = self.browser.open_page_info_window(opener)
deck = page_info_window.deck
self.assertEqual(deck.selected_panel, deck.security)
self.assertEqual(deck.security.domain.get_attribute('value'),
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'])
--- a/testing/firefox-ui/tests/functional/security/test_ev_certificate.py
+++ b/testing/firefox-ui/tests/functional/security/test_ev_certificate.py
@@ -74,24 +74,24 @@ class TestEVCertificate(PuppeteerMixin,
# Check the organization name
self.assertEqual(security_view.owner.get_attribute('textContent'),
cert['organization'])
# 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)
# Open the Page Info window by clicking the More Information button
page_info = self.browser.open_page_info_window(
lambda _: self.identity_popup.view.security.more_info_button.click())
--- a/testing/firefox-ui/tests/functional/security/test_no_certificate.py
+++ b/testing/firefox-ui/tests/functional/security/test_no_certificate.py
@@ -69,13 +69,13 @@ class TestNoCertificate(PuppeteerMixin,
self.assertEqual(page_info.deck.selected_panel, page_info.deck.security)
# Check the domain listed on the security panel contains the url's host name
self.assertIn(urlparse(self.url).hostname,
page_info.deck.security.domain.get_attribute('value'))
# 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'))
--- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py
+++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py
@@ -102,34 +102,34 @@ class TestSafeBrowsingNotificationBar(Pu
# Clean up here since the permission gets set in this function
self.puppeteer.utils.permissions.remove('https://www.itisatrap.org', 'safe-browsing')
# Check the not a forgery or attack button in the notification bar
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}))
self.browser.tabbar.open_tab(lambda _: button.click())
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: report_page in mn.get_url(),
message='The expected safe-browsing report page has not been opened',
)
with self.marionette.using_context('chrome'):
self.browser.tabbar.close_tab()
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()
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
lambda mn: self.browser.default_homepage in mn.get_url(),
message='The default home page has not been loaded',
)
--- 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
@@ -37,17 +37,17 @@ class TestSSLDisabledErrorPage(Puppeteer
# Open the test page
self.assertRaises(MarionetteException, self.marionette.navigate, self.url)
# Wait for the DOM to receive events
time.sleep(1)
# 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
short_description = self.marionette.find_element(By.ID, 'errorShortDescText')
self.assertIn('SSL_ERROR_UNSUPPORTED_VERSION',
short_description.get_property('textContent'))
self.assertIn('mozqa.com', short_description.get_property('textContent'))
--- 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
@@ -107,17 +107,17 @@ class TestSSLStatusAfterRestart(Puppetee
self.assertEqual(page_info.deck.security.domain.get_attribute('value'),
cert['commonName'],
'Domain value matches certificate common name.')
# Verify the owner listed on the security panel
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)
# Verify the verifier listed on the security panel
self.assertEqual(page_info.deck.security.verifier.get_attribute('value'),
cert['issuerOrganization'],
'Verifier matches issuer of certificate for ' + url)
--- 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
@@ -33,17 +33,17 @@ class TestSubmitUnencryptedInfoWarning(P
searchbox = self.marionette.find_element(By.ID, 'q')
button = self.marionette.find_element(By.ID, 'submit')
# Use the page's search box to submit information.
searchbox.send_keys(self.test_string)
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
warning = Alert(self.marionette)
try:
Wait(self.marionette,
ignored_exceptions=NoAlertPresentException,
timeout=self.marionette.timeout.page_load).until(
--- a/testing/firefox-ui/tests/puppeteer/test_l10n.py
+++ b/testing/firefox-ui/tests/puppeteer/test_l10n.py
@@ -1,49 +1,51 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
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
class TestL10n(PuppeteerMixin, MarionetteTestCase):
def setUp(self):
super(TestL10n, self).setUp()
self.l10n = L10n(self.marionette)
def test_dtd_entity_chrome(self):
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')
elm = self.marionette.find_element(By.TAG_NAME, 'title')
self.assertEqual(value, elm.text)
def test_properties(self):
properties = ['chrome://global/locale/filepicker.properties',
'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')
--- a/testing/firefox-ui/tests/puppeteer/test_page_info_window.py
+++ b/testing/firefox-ui/tests/puppeteer/test_page_info_window.py
@@ -77,17 +77,18 @@ class TestPageInfoWindow(PuppeteerMixin,
page_info = self.browser.open_page_info_window(trigger=trigger)
self.assertEquals(page_info, self.puppeteer.windows.current)
page_info.close()
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',
'shortcut',
closer,
)
for trigger in close_strategies:
# menu only works on OS X
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/l10n.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/l10n.py
@@ -1,92 +1,125 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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.
:param dtd_urls: A list of dtd files to search.
:param entity_id: The id to retrieve the value from.
: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 += '<!ENTITY %% %s SYSTEM "%s">%%%s;' % \
- (dtd_id, item, dtd_id)
+ dtd_refs = ''
+ for index, item in enumerate(dtds):
+ dtd_id = 'dtd_%s' % index
+ dtd_refs += '<!ENTITY %% %s SYSTEM "%s">%%%s;' % \
+ (dtd_id, item, dtd_id)
- contents = """<?xml version="1.0"?>
- <!DOCTYPE elem [%s]>
+ contents = """<?xml version="1.0"?>
+ <!DOCTYPE elem [%s]>
- <elem id="entity">&%s;</elem>""" % (dtd_refs, entity_id)
+ <elem id="entity">&%s;</elem>""" % (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
the id.
:param property_urls: A list of property files to search.
:param property_id: The id to retrieve the value from.
: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 MarionetteException('Property not found: %s' % property_id)
+ if not value:
+ raise NoSuchElementException('Property not found: %s' % property_id)
- return value
+ return value
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
@@ -128,17 +128,18 @@ class TabBar(UIBaseLib):
if callable(trigger):
trigger(self.selected_tab)
elif trigger == 'button':
self.window.tabbar.newtab_button.click()
elif trigger == 'menu':
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)
# TODO: Needs to be replaced with event handling code (bug 1121705)
Wait(self.marionette).until(
lambda mn: len(mn.window_handles) == len(start_handles) + 1,
message='No new tab has been opened.')
@@ -307,17 +308,18 @@ class Tab(UIBaseLib):
self.marionette.close()
elif callable(trigger):
trigger(self)
elif trigger == 'button':
self.close_button.click()
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)
Wait(self.marionette).until(
lambda _: len(self.window.tabbar.tabs) == len(start_handles) - 1,
message='Tab with handle "%s" has not been closed.' % handle)
# Ensure to switch to the window handle which represents the new selected tab
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
@@ -144,17 +144,17 @@ class LocationBar(UIBaseLib):
"""Focus the location bar according to the provided event.
:param eventt: The event to synthesize in order to focus the urlbar
(one of `click` or `shortcut`).
"""
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)
Wait(self.marionette).until(
lambda _: self.focused,
message='Location bar has not be focused.')
@@ -258,17 +258,17 @@ class LocationBar(UIBaseLib):
:param force: Whether to cause a forced reload.
"""
# TODO: The force parameter is ignored for the moment. Use
# mouse event modifiers or actions when they're ready.
# Bug 1097705 tracks this feature in marionette.
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)
@property
def stop_button(self):
"""Provides access to the DOM element stop button.
@@ -599,17 +599,17 @@ class IdentityPopupSecurityView(Identity
return self.element.find_element(By.CLASS_NAME, 'identity-popup-connection-not-secure')
@property
def more_info_button(self):
"""The DOM element which represents the identity-popup more info button.
: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))
@property
def owner(self):
"""The DOM element which represents the identity-popup content owner.
:returns: Reference to the identity-popup content owner.
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
@@ -156,17 +156,17 @@ class BrowserWindow(BaseWindow):
"""
def callback(win):
# Prepare action which triggers the opening of the browser window
if callable(trigger):
trigger(win)
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)
BaseWindow.close(self, callback, force)
def get_final_url(self, url):
"""Loads the page at `url` and returns the resulting url.
@@ -195,17 +195,17 @@ class BrowserWindow(BaseWindow):
# Prepare action which triggers the opening of the browser window
if callable(trigger):
trigger(win)
elif trigger == 'menu':
menu_id = 'menu_newPrivateWindow' if is_private else 'menu_newNavigator'
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)
return BaseWindow.open_window(self, callback, BrowserWindow)
def open_about_window(self, trigger='menu'):
"""Opens the about window by using the specified trigger.
@@ -240,17 +240,17 @@ class BrowserWindow(BaseWindow):
# Prepare action which triggers the opening of the browser window
if callable(trigger):
trigger(win)
elif trigger == 'menu':
self.menubar.select_by_id('tools-menu', 'menu_pageInfo')
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
pass
else:
raise ValueError('Unknown opening method: "%s"' % trigger)
return BaseWindow.open_window(self, callback, PageInfoWindow)
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py
@@ -45,17 +45,17 @@ class PageInfoWindow(BaseWindow):
"""
def callback(win):
# Prepare action which triggers the opening of the browser window
if callable(trigger):
trigger(win)
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)
super(PageInfoWindow, self).close(callback, force)
Windows.register_window(PageInfoWindow.window_type, PageInfoWindow)
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/windows.py
@@ -308,37 +308,37 @@ class BaseWindow(BaseLib):
Wait(self.marionette).until(
lambda m: len(m.chrome_window_handles) == prev_win_count - 1,
message='Chrome window with handle "%s" has not been closed.' % handle)
def focus(self):
"""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.
:returns: The localized string for the requested entity.
: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.
:returns: The localized string for the requested property.
: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.
:param callback: Optional, function to trigger the window to open. It is
triggered with the current :class:`BaseWindow` as parameter.
Defaults to `window.open()`.
:param expected_class: Optional, check for the correct window class.