Bug 1587627 - [fxui] Update firefox-puppeteer for removal of anonymous nodes. r=webdriver-reviewers,maja_zf
authorHenrik Skupin <mail@hskupin.info>
Mon, 28 Oct 2019 18:24:57 +0000
changeset 499575 3ab59c714f29eca25c56f620f5c75f79046b8b0f
parent 499574 1b369258bfad995e2b773e3f1c6ac261af2918a7
child 499576 79be8382d57a67860918b238e2ddc47043d523ea
push id114161
push userncsoregi@mozilla.com
push dateTue, 29 Oct 2019 21:34:24 +0000
treeherdermozilla-inbound@25bf8e097e60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswebdriver-reviewers, maja_zf
bugs1587627
milestone72.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
Bug 1587627 - [fxui] Update firefox-puppeteer for removal of anonymous nodes. r=webdriver-reviewers,maja_zf The patch removes the usage of elements based on anonymous nodes, which are soon to be completely removed. Also code which is no longer in use by Firefox-UI tests can simply be removed. Differential Revision: https://phabricator.services.mozilla.com/D50803
testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py
testing/firefox-ui/tests/puppeteer/test_toolbars.py
testing/marionette/puppeteer/firefox/docs/ui/browser/tabbar.rst
testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
--- a/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py
+++ b/testing/firefox-ui/tests/functional/keyboard_shortcuts/test_browser_window.py
@@ -45,16 +45,15 @@ class TestBrowserWindowShortcuts(Puppete
             key = 'searchFocusUnix.commandkey'
         else:
             key = 'searchFocus.commandkey'
         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="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;
             """)
             return selection_name == "input"
 
         Wait(self.marionette).until(has_input_selected)
--- a/testing/firefox-ui/tests/puppeteer/test_toolbars.py
+++ b/testing/firefox-ui/tests/puppeteer/test_toolbars.py
@@ -82,22 +82,16 @@ class TestLocationBar(PuppeteerMixin, Ma
     def setUp(self):
         super(TestLocationBar, self).setUp()
 
         self.locationbar = self.browser.navbar.locationbar
 
     def test_elements(self):
         self.assertEqual(self.locationbar.urlbar_input.get_property('id'), 'urlbar-input')
 
-        self.assertEqual(self.locationbar.identity_box.get_property('localName'), 'box')
-        self.assertEqual(self.locationbar.identity_country_label.get_property('localName'),
-                         'label')
-        self.assertEqual(self.locationbar.identity_organization_label.get_property('localName'),
-                         'label')
-        self.assertEqual(self.locationbar.identity_icon.get_property('localName'), 'image')
         self.assertEqual(self.locationbar.reload_button.get_property('localName'),
                          'toolbarbutton')
         self.assertEqual(self.locationbar.stop_button.get_property('localName'),
                          'toolbarbutton')
 
     def test_reload(self):
         event_types = ["shortcut", "shortcut2", "button"]
         for event in event_types:
@@ -118,87 +112,8 @@ class TestLocationBar(PuppeteerMixin, Ma
         self.assertEqual(self.locationbar.value, '')
 
     def test_load_url(self):
         data_uri = 'data:text/html,<title>Title</title>'
         self.locationbar.load_url(data_uri)
 
         with self.marionette.using_context('content'):
             Wait(self.marionette).until(lambda mn: mn.get_url() == data_uri)
-
-
-class TestIdentityPopup(PuppeteerMixin, MarionetteTestCase):
-    def setUp(self):
-        super(TestIdentityPopup, self).setUp()
-
-        self.locationbar = self.browser.navbar.locationbar
-        self.identity_popup = self.locationbar.identity_popup
-
-        self.url = 'https://extended-validation.badssl.com'
-
-        with self.marionette.using_context('content'):
-            self.marionette.navigate(self.url)
-
-    def tearDown(self):
-        try:
-            self.identity_popup.close(force=True)
-        finally:
-            super(TestIdentityPopup, self).tearDown()
-
-    def test_elements(self):
-        self.locationbar.open_identity_popup()
-
-        # Test main view elements
-        main = self.identity_popup.view.main
-        self.assertEqual(main.element.get_property('localName'), 'panelview')
-
-        self.assertEqual(main.expander.get_property('localName'), 'button')
-        self.assertEqual(main.insecure_connection_label.get_property('localName'),
-                         'description')
-        self.assertEqual(main.internal_connection_label.get_property('localName'),
-                         'description')
-        self.assertEqual(main.secure_connection_label.get_property('localName'),
-                         'description')
-
-        self.assertEqual(main.permissions.get_property('localName'), 'vbox')
-
-        # Test security view elements
-        security = self.identity_popup.view.security
-        self.assertEqual(security.element.get_property('localName'), 'panelview')
-
-        self.assertEqual(security.host.get_property('localName'), 'label')
-        self.assertEqual(security.insecure_connection_label.get_property('localName'),
-                         'description')
-        self.assertEqual(security.secure_connection_label.get_property('localName'),
-                         'description')
-
-        self.assertEqual(security.owner.get_property('localName'), 'description')
-        self.assertEqual(security.owner_location.get_property('localName'), 'description')
-        self.assertEqual(security.verifier.get_property('localName'), 'description')
-
-        self.assertEqual(security.disable_mixed_content_blocking_button.get_property('localName'),
-                         'button')
-        self.assertEqual(security.enable_mixed_content_blocking_button.get_property('localName'),
-                         'button')
-
-        self.assertEqual(security.more_info_button.get_property('localName'), 'button')
-
-    def test_open_close(self):
-        with self.marionette.using_context('content'):
-            self.marionette.navigate(self.url)
-
-        self.assertFalse(self.identity_popup.is_open)
-
-        self.locationbar.open_identity_popup()
-
-        self.identity_popup.close()
-        self.assertFalse(self.identity_popup.is_open)
-
-    def test_force_close(self):
-        with self.marionette.using_context('content'):
-            self.marionette.navigate(self.url)
-
-        self.assertFalse(self.identity_popup.is_open)
-
-        self.locationbar.open_identity_popup()
-
-        self.identity_popup.close(force=True)
-        self.assertFalse(self.identity_popup.is_open)
--- a/testing/marionette/puppeteer/firefox/docs/ui/browser/tabbar.rst
+++ b/testing/marionette/puppeteer/firefox/docs/ui/browser/tabbar.rst
@@ -9,14 +9,8 @@ TabBar
 .. autoclass:: TabBar
    :members:
 
 Tab
 ---
 
 .. autoclass:: Tab
    :members:
-
-MenuPanel
-----------
-
-.. autoclass:: MenuPanel
-   :members:
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
@@ -60,18 +60,17 @@ class AddOnInstallBlockedNotification(Ba
 
     @property
     def allow_button(self):
         """Provide access to the allow button.
 
         :returns: The allow button.
         """
         return self.element.find_element(
-            By.ANON_ATTRIBUTE, {'anonid': 'button'}).find_element(
-            By.ANON_ATTRIBUTE, {'anonid': 'button'})
+            By.CLASS, "popup-notification-primary-button")
 
 
 class AddOnInstallConfirmationNotification(BaseNotification):
     """Add-on install confirmation notification."""
 
     pass
 
 
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
@@ -3,39 +3,28 @@
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import
 
 from marionette_driver import (
     By, Wait
 )
 
-from marionette_driver.errors import NoSuchElementException
-
 import firefox_puppeteer.errors as errors
 
 from firefox_puppeteer.api.security import Security
-from firefox_puppeteer.ui.base import UIBaseLib, DOMElement
+from firefox_puppeteer.ui.base import UIBaseLib
 
 
 class TabBar(UIBaseLib):
     """Wraps the tabs toolbar DOM element inside a browser window."""
 
     # Properties for visual elements of the tabs toolbar #
 
     @property
-    def menupanel(self):
-        """A :class:`MenuPanel` instance which represents the menu panel
-        at the far right side of the tabs toolbar.
-
-        :returns: :class:`MenuPanel` instance.
-        """
-        return MenuPanel(self.marionette, self.window)
-
-    @property
     def newtab_button(self):
         """The DOM element which represents the new tab button.
 
         :returns: Reference to the new tab button.
         """
         return self.toolbar.find_element(By.ID, 'tabs-newtab-button')
 
     @property
@@ -357,52 +346,8 @@ class Tab(UIBaseLib):
 
     def switch_to(self):
         """Switches the context of Marionette to this tab.
 
         Please keep in mind that calling this method will not select the tab.
         Use the :func:`~Tab.select` method instead.
         """
         self.marionette.switch_to_window(self.handle)
-
-
-class MenuPanel(UIBaseLib):
-
-    @property
-    def popup(self):
-        """
-        :returns: The :class:`MenuPanelElement`.
-        """
-        popup = self.marionette.find_element(By.ID, 'PanelUI-popup')
-        return self.MenuPanelElement(popup)
-
-    class MenuPanelElement(DOMElement):
-        """Wraps the menu panel."""
-        _buttons = None
-
-        @property
-        def buttons(self):
-            """
-            :returns: A list of all the clickable buttons in the menu panel.
-            """
-            if not self._buttons:
-                self._buttons = (self.find_element(By.ID, 'PanelUI-multiView')
-                                     .find_element(By.ANON_ATTRIBUTE,
-                                                   {'anonid': 'viewContainer'})
-                                     .find_elements(By.TAG_NAME,
-                                                    'toolbarbutton'))
-            return self._buttons
-
-        def click(self, target=None):
-            """
-            Overrides HTMLElement.click to provide a target to click.
-
-            :param target: The label associated with the button to click on,
-             e.g., `New Private Window`.
-            """
-            if not target:
-                return DOMElement.click(self)
-
-            for button in self.buttons:
-                if button.get_attribute('label') == target:
-                    return button.click()
-            raise NoSuchElementException('Could not find "{}"" in the '
-                                         'menu panel UI'.format(target))
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
@@ -74,17 +74,16 @@ class NavBar(UIBaseLib):
 
 class LocationBar(UIBaseLib):
     """Provides access to and methods for the DOM elements contained in the
     locationbar (the text area of the ui that typically displays the current url)."""
 
     def __init__(self, *args, **kwargs):
         super(LocationBar, self).__init__(*args, **kwargs)
 
-        self._autocomplete_results = None
         self._identity_popup = None
 
     def clear(self):
         """Clears the contents of the url bar (via the DELETE shortcut)."""
         self.focus('shortcut')
         self.urlbar.send_keys(keys.Keys.DELETE)
         Wait(self.marionette).until(
             lambda _: self.value == '',
@@ -241,122 +240,16 @@ class LocationBar(UIBaseLib):
     def value(self):
         """Provides access to the currently displayed value of the urlbar.
 
         :returns: The urlbar value.
         """
         return self.urlbar_input.get_property('value')
 
 
-class AutocompleteResults(UIBaseLib):
-    """Wraps DOM elements and methods for interacting with autocomplete results."""
-
-    def close(self, force=False):
-        """Closes the urlbar autocomplete popup.
-
-        :param force: If true, the popup is closed by its own hide function,
-                      otherwise a key event is sent to close the popup.
-        """
-        if not self.is_open:
-            return
-
-        if force:
-            self.marionette.execute_script("""
-              arguments[0].hidePopup();
-            """, script_args=[self.element])
-        else:
-            self.element.send_keys(keys.Keys.ESCAPE)
-
-        Wait(self.marionette).until(
-            lambda _: not self.is_open,
-            message='Autocomplete popup has not been closed.')
-
-    def get_matching_text(self, result, match_type):
-        """Returns an array of strings of the matching text within an autocomplete
-        result in the urlbar.
-
-        :param result: The result to inspect for matches.
-        :param match_type: The type of match to search for (one of `title` or `url`).
-        """
-
-        if match_type not in ('title', 'url'):
-            raise ValueError('match_type provided must be one of'
-                             '"title" or "url", not %s' % match_type)
-
-        # Search for nodes of the given type with emphasized text
-        emphasized_nodes = result.find_elements(
-            By.ANON_ATTRIBUTE,
-            {'class': 'ac-emphasize-text ac-emphasize-text-%s' % match_type}
-        )
-
-        return [node.get_property('textContent') for node in emphasized_nodes]
-
-    @property
-    def visible_results(self):
-        """Supplies the list of visible autocomplete result nodes.
-
-        :returns: The list of visible results.
-        """
-        match_count = self.element.get_property('matchCount')
-
-        return self.marionette.execute_script("""
-          let rv = [];
-          let node = arguments[0];
-          let count = arguments[1];
-
-          for (let i = 0; i < count; ++i) {
-            rv.push(node.getItemAtIndex(i));
-          }
-
-          return rv;
-        """, script_args=[self.results, match_count])
-
-    @property
-    def is_open(self):
-        """Returns whether this popup is currently open.
-
-        :returns: True when the popup is open, otherwise false.
-        """
-        return self.element.get_property('state') == 'open'
-
-    @property
-    def is_complete(self):
-        """Returns when this popup is open and autocomplete results are complete.
-
-        :returns: True, when autocomplete results have been populated.
-        """
-        return self.marionette.execute_script("""
-          Components.utils.import("resource://gre/modules/Services.jsm");
-
-          let win = Services.focus.activeWindow;
-          if (win) {
-            return win.gURLBar.controller.searchStatus >=
-                   Components.interfaces.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
-          }
-
-          return null;
-        """)
-
-    @property
-    def results(self):
-        """
-        :returns: The autocomplete result container node.
-        """
-        return self.element.find_element(By.ANON_ATTRIBUTE,
-                                         {'anonid': 'richlistbox'})
-
-    @property
-    def selected_index(self):
-        """Provides the index of the selected item in the autocomplete list.
-
-        :returns: The index.
-        """
-        return self.results.get_property('selectedIndex')
-
-
 class IdentityPopup(UIBaseLib):
     """Wraps DOM elements and methods for interacting with the identity popup."""
 
     def __init__(self, *args, **kwargs):
         super(IdentityPopup, self).__init__(*args, **kwargs)
 
         self._view = None