Bug 1316851 - Puppeteer has to use super() to call base class methods. r=maja_zf
authorHenrik Skupin <mail@hskupin.info>
Fri, 11 Nov 2016 15:04:52 +0100
changeset 438295 608cebbca5c485f93e6f50c812c0a36b22cdf5cb
parent 438294 ad8f42a8e7f6948b18c534d811b270ddcea7108c
child 438296 af0d5a28645e78a9e7847a1b4e93026943ec3d01
push id35679
push userbmo:timdream@gmail.com
push dateMon, 14 Nov 2016 09:29:38 +0000
reviewersmaja_zf
bugs1316851
milestone52.0a1
Bug 1316851 - Puppeteer has to use super() to call base class methods. r=maja_zf MozReview-Commit-ID: 8xkVLBs9OuR
testing/puppeteer/firefox/firefox_puppeteer/api/utils.py
testing/puppeteer/firefox/firefox_puppeteer/ui/about_window/window.py
testing/puppeteer/firefox/firefox_puppeteer/ui/base.py
testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
testing/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py
testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/dialog.py
testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
testing/puppeteer/firefox/firefox_puppeteer/ui/windows.py
--- a/testing/puppeteer/firefox/firefox_puppeteer/api/utils.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/api/utils.py
@@ -6,17 +6,17 @@ from marionette_driver.errors import Mar
 
 from firefox_puppeteer.base import BaseLib
 
 
 class Utils(BaseLib):
     """Low-level access to utility actions."""
 
     def __init__(self, *args, **kwargs):
-        BaseLib.__init__(self, *args, **kwargs)
+        super(Utils, self).__init__(*args, **kwargs)
 
         self._permissions = Permissions(self.marionette)
 
     @property
     def permissions(self):
         """Handling of various permissions for hosts.
 
         :returns: Instance of the Permissions class.
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/about_window/window.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/about_window/window.py
@@ -12,19 +12,16 @@ class AboutWindow(BaseWindow):
     """Representation of the About window."""
     window_type = 'Browser:About'
 
     dtds = [
         'chrome://branding/locale/brand.dtd',
         'chrome://browser/locale/aboutDialog.dtd',
     ]
 
-    def __init__(self, *args, **kwargs):
-        BaseWindow.__init__(self, *args, **kwargs)
-
     @property
     def deck(self):
         """The :class:`Deck` instance which represents the deck.
 
         :returns: Reference to the deck.
         """
         self.switch_to()
 
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/base.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/base.py
@@ -7,21 +7,21 @@ from marionette_driver.marionette import
 from firefox_puppeteer.base import BaseLib
 from firefox_puppeteer.ui.windows import BaseWindow
 
 
 class UIBaseLib(BaseLib):
     """A base class for all UI element wrapper classes inside a chrome window."""
 
     def __init__(self, marionette, window, element):
+        super(UIBaseLib, self).__init__(marionette)
 
         assert isinstance(window, BaseWindow)
         assert isinstance(element, HTMLElement)
 
-        BaseLib.__init__(self, marionette)
         self._window = window
         self._element = element
 
     @property
     def element(self):
         """Returns the reference to the underlying DOM element.
 
         :returns: Reference to the DOM element
@@ -47,11 +47,8 @@ class DOMElement(HTMLElement):
         instance = object.__new__(cls)
         instance.__dict__ = element.__dict__.copy()
         setattr(instance, 'inner', element)
 
         return instance
 
     def __init__(self, element):
         pass
-
-    def get_marionette(self):
-        return self.marionette
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
@@ -202,17 +202,17 @@ class TabBar(UIBaseLib):
 
         return handle
 
 
 class Tab(UIBaseLib):
     """Wraps a tab DOM element."""
 
     def __init__(self, marionette, window, element):
-        UIBaseLib.__init__(self, marionette, window, element)
+        super(Tab, self).__init__(marionette, window, element)
 
         self._security = Security(self.marionette)
         self._handle = None
 
     # Properties for visual elements of tabs #
 
     @property
     def close_button(self):
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
@@ -7,17 +7,17 @@ from marionette_driver import By, keys, 
 from firefox_puppeteer.ui.base import UIBaseLib
 
 
 class NavBar(UIBaseLib):
     """Provides access to the DOM elements contained in the
     navigation bar as well as the location bar."""
 
     def __init__(self, *args, **kwargs):
-        UIBaseLib.__init__(self, *args, **kwargs)
+        super(NavBar, self).__init__(*args, **kwargs)
 
         self._locationbar = None
 
     @property
     def back_button(self):
         """Provides access to the DOM element back button in the navbar.
 
         :returns: Reference to the back button.
@@ -70,17 +70,17 @@ class NavBar(UIBaseLib):
         return self.element
 
 
 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):
-        UIBaseLib.__init__(self, *args, **kwargs)
+        super(LocationBar, self).__init__(*args, **kwargs)
 
         self._autocomplete_results = None
         self._identity_popup = None
 
     @property
     def autocomplete_results(self):
         """Provides access to and methods for the location bar
         autocomplete results.
@@ -406,17 +406,17 @@ class AutocompleteResults(UIBaseLib):
         """
         return self.results.get_attribute('selectedIndex')
 
 
 class IdentityPopup(UIBaseLib):
     """Wraps DOM elements and methods for interacting with the identity popup."""
 
     def __init__(self, *args, **kwargs):
-        UIBaseLib.__init__(self, *args, **kwargs)
+        super(IdentityPopup, self).__init__(*args, **kwargs)
 
         self._view = None
 
     @property
     def is_open(self):
         """Returns whether this popup is currently open.
 
         :returns: True when the popup is open, otherwise false.
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
@@ -35,17 +35,17 @@ class BrowserWindow(BaseWindow):
         'chrome://branding/locale/brand.properties',
         'chrome://branding/locale/browserconfig.properties',
         'chrome://browser/locale/browser.properties',
         'chrome://browser/locale/preferences/preferences.properties',
         'chrome://global/locale/browser.properties',
     ]
 
     def __init__(self, *args, **kwargs):
-        BaseWindow.__init__(self, *args, **kwargs)
+        super(BrowserWindow, self).__init__(*args, **kwargs)
 
         self._navbar = None
         self._tabbar = None
 
         # Timeout for loading remote web pages
         self.timeout_page_load = 30
 
     @property
@@ -253,9 +253,10 @@ class BrowserWindow(BaseWindow):
             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)
 
+
 Windows.register_window(BrowserWindow.window_type, BrowserWindow)
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/window.py
@@ -18,19 +18,16 @@ class PageInfoWindow(BaseWindow):
     ]
 
     properties = [
         'chrome://browser/locale/browser.properties',
         'chrome://browser/locale/pageInfo.properties',
         'chrome://pippki/locale/pippki.properties',
     ]
 
-    def __init__(self, *args, **kwargs):
-        BaseWindow.__init__(self, *args, **kwargs)
-
     @property
     def deck(self):
         """The :class:`Deck` instance which represents the deck.
 
         :returns: Reference to the deck.
         """
         deck = self.window_element.find_element(By.ID, 'mainDeck')
         return Deck(self.marionette, self, deck)
@@ -53,11 +50,12 @@ 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'),
                                   accel=True)
             else:
                 raise ValueError('Unknown closing method: "%s"' % trigger)
 
-        BaseWindow.close(self, callback, force)
+        super(PageInfoWindow, self).close(callback, force)
+
 
 Windows.register_window(PageInfoWindow.window_type, PageInfoWindow)
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/dialog.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/dialog.py
@@ -18,19 +18,16 @@ class UpdateWizardDialog(BaseWindow):
         'chrome://mozapps/locale/update/updates.dtd',
     ]
 
     properties = [
         'chrome://branding/locale/brand.properties',
         'chrome://mozapps/locale/update/updates.properties',
     ]
 
-    def __init__(self, *args, **kwargs):
-        BaseWindow.__init__(self, *args, **kwargs)
-
     @property
     def wizard(self):
         """The :class:`Wizard` instance which represents the wizard.
 
         :returns: Reference to the wizard.
         """
         # The deck is also the root element
         wizard = self.marionette.find_element(By.ID, 'updates')
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
@@ -6,17 +6,17 @@ from marionette_driver import By, Wait
 
 from firefox_puppeteer.ui.base import UIBaseLib
 from firefox_puppeteer.ui.deck import Panel
 
 
 class Wizard(UIBaseLib):
 
     def __init__(self, *args, **kwargs):
-        UIBaseLib.__init__(self, *args, **kwargs)
+        super(Wizard, self).__init__(*args, **kwargs)
 
         Wait(self.marionette).until(
             lambda _: self.selected_panel,
             message='No panel has been selected by default.')
 
     def _create_panel_for_id(self, panel_id):
         """Creates an instance of :class:`Panel` for the specified panel id.
 
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/windows.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/windows.py
@@ -209,17 +209,18 @@ class Windows(BaseLib):
 class BaseWindow(BaseLib):
     """Base class for any kind of chrome window."""
 
     # l10n class attributes will be set by each window class individually
     dtds = []
     properties = []
 
     def __init__(self, marionette, window_handle):
-        BaseLib.__init__(self, marionette)
+        super(BaseWindow, self).__init__(marionette)
+
         self._l10n = L10n(self.marionette)
         self._prefs = Preferences(self.marionette)
         self._windows = Windows(self.marionette)
 
         if window_handle not in self.marionette.chrome_window_handles:
             raise errors.UnknownWindowError('Window with handle "%s" does not exist' %
                                             window_handle)
         self._handle = window_handle