Bug 1360687 Remove puppeteer addon install notifications code draft
authorAndrew Swan <aswan@mozilla.com>
Fri, 28 Apr 2017 16:30:58 -0700
changeset 570495 4935d895d7fb385a04d8ff017baec46198e4ad9f
parent 569700 ffdedb9c5aadf033a6a230bbc0338bc0e0760db0
child 570628 0687a1e705ac85edcef9cae030a64b7a472d0e89
push id56502
push useraswan@mozilla.com
push dateFri, 28 Apr 2017 23:35:04 +0000
bugs1360687
milestone55.0a1
Bug 1360687 Remove puppeteer addon install notifications code MozReview-Commit-ID: HkRTYyKsbJE
testing/firefox-ui/resources/addons/extensions/restartless_addon_signed.xpi
testing/firefox-ui/resources/addons/extensions/restartless_addon_unsigned.xpi
testing/firefox-ui/tests/puppeteer/manifest.ini
testing/firefox-ui/tests/puppeteer/test_notifications.py
testing/marionette/puppeteer/firefox/docs/index.rst
testing/marionette/puppeteer/firefox/docs/ui/browser/notifications.rst
testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
deleted file mode 100644
index ed86213e7917b3eba0816b547759fcc0cbef6157..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index d0768103d56491bf9c24f49832b25787be7438e5..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/testing/firefox-ui/tests/puppeteer/manifest.ini
+++ b/testing/firefox-ui/tests/puppeteer/manifest.ini
@@ -8,16 +8,15 @@ tags = local
 [test_security.py]
 tags = remote
 [test_software_update.py]
 [test_utils.py]
 
 # UI tests
 [test_about_window.py]
 [test_menubar.py]
-[test_notifications.py]
 [test_page_info_window.py]
 [test_tabbar.py]
 [test_toolbars.py]
 tags = remote
 [test_update_wizard.py]
 tags = remote
 [test_windows.py]
deleted file mode 100644
--- a/testing/firefox-ui/tests/puppeteer/test_notifications.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# 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.ui.browser.notifications import (
-    AddOnInstallFailedNotification,
-    AddOnInstallConfirmationNotification,
-)
-from marionette_driver import By
-from marionette_driver.errors import TimeoutException
-from marionette_harness import MarionetteTestCase
-
-
-class TestNotifications(PuppeteerMixin, MarionetteTestCase):
-
-    def setUp(self):
-        super(TestNotifications, self).setUp()
-
-        self.marionette.set_pref('extensions.install.requireSecureOrigin', False)
-
-        self.addons_url = self.marionette.absolute_url('addons/extensions/')
-        self.puppeteer.utils.permissions.add(self.marionette.baseurl, 'install')
-
-    def tearDown(self):
-        try:
-            self.marionette.clear_pref('extensions.install.requireSecureOrigin')
-            self.marionette.clear_pref('xpinstall.signatures.required')
-
-            self.puppeteer.utils.permissions.remove(self.addons_url, 'install')
-
-            if self.browser.notification:
-                self.browser.notification.close(force=True)
-        finally:
-            super(TestNotifications, self).tearDown()
-
-    def test_open_close_notification(self):
-        """Trigger and dismiss a notification"""
-        self.assertIsNone(self.browser.notification)
-        self.trigger_addon_notification('restartless_addon_signed.xpi')
-        self.browser.notification.close()
-        self.assertIsNone(self.browser.notification)
-
-    def test_wait_for_notification_timeout(self):
-        """Wait for a notification when one is not shown"""
-        message = 'No notification was shown'
-        with self.assertRaisesRegexp(TimeoutException, message):
-            self.browser.wait_for_notification()
-
-    def test_wait_for_specific_notification_timeout(self):
-        """Wait for a notification when one is not shown"""
-        message = 'AddOnInstallFailedNotification was not shown'
-        with self.assertRaisesRegexp(TimeoutException, message):
-            self.browser.wait_for_notification(AddOnInstallFailedNotification)
-
-    def test_wait_for_no_notification_timeout(self):
-        """Wait for no notification when one is shown"""
-        message = 'Unexpected notification shown'
-        self.trigger_addon_notification('restartless_addon_signed.xpi')
-        with self.assertRaisesRegexp(TimeoutException, message):
-            self.browser.wait_for_notification(None)
-
-    def test_notification_with_origin(self):
-        """Trigger a notification with an origin"""
-        self.trigger_addon_notification('restartless_addon_signed.xpi')
-        self.assertIn(self.browser.notification.origin, self.marionette.baseurl)
-        self.assertIsNotNone(self.browser.notification.label)
-
-    def test_addon_install_failed_notification(self):
-        """Trigger add-on blocked notification using an unsigned add-on"""
-        # Ensure that installing unsigned extensions will fail
-        self.marionette.set_pref('xpinstall.signatures.required', True)
-
-        self.trigger_addon_notification(
-            'restartless_addon_unsigned.xpi',
-            notification=AddOnInstallFailedNotification)
-
-    def trigger_addon_notification(self, addon, notification=AddOnInstallConfirmationNotification):
-        with self.marionette.using_context('content'):
-            self.marionette.navigate(self.addons_url)
-            self.marionette.find_element(By.LINK_TEXT, addon).click()
-        self.browser.wait_for_notification(notification)
--- a/testing/marionette/puppeteer/firefox/docs/index.rst
+++ b/testing/marionette/puppeteer/firefox/docs/index.rst
@@ -57,17 +57,16 @@ The following libraries are currently im
 future. Each library is available from an instance of the FirefoxTestCase class.
 
 .. toctree::
 
    ui/about_window/window
    ui/deck
    ui/menu
    ui/pageinfo/window
-   ui/browser/notifications
    ui/browser/tabbar
    ui/browser/toolbars
    ui/browser/window
    ui/update_wizard/dialog
    ui/windows
    api/appinfo
    api/keys
    api/l10n
deleted file mode 100644
--- a/testing/marionette/puppeteer/firefox/docs/ui/browser/notifications.rst
+++ /dev/null
@@ -1,44 +0,0 @@
-.. py:currentmodule:: firefox_puppeteer.ui.browser.notifications
-
-Notifications
-=============
-
-AddOnInstallBlockedNotification
--------------------------------
-
-.. autoclass:: AddOnInstallBlockedNotification
-   :members:
-   :inherited-members:
-   :show-inheritance:
-
-AddOnInstallConfirmationNotification
-------------------------------------
-
-.. autoclass:: AddOnInstallConfirmationNotification
-   :members:
-   :inherited-members:
-   :show-inheritance:
-
-AddOnInstallCompleteNotification
---------------------------------
-
-.. autoclass:: AddOnInstallCompleteNotification
-   :members:
-   :inherited-members:
-   :show-inheritance:
-
-AddOnInstallFailedNotification
-------------------------------
-
-.. autoclass:: AddOnInstallFailedNotification
-   :members:
-   :inherited-members:
-   :show-inheritance:
-
-AddOnProgressNotification
--------------------------
-
-.. autoclass:: AddOnProgressNotification
-   :members:
-   :inherited-members:
-   :show-inheritance:
deleted file mode 100644
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# 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 abc import ABCMeta
-
-from marionette_driver import By
-
-from firefox_puppeteer.ui.base import UIBaseLib
-
-
-class BaseNotification(UIBaseLib):
-    """Abstract base class for any kind of notification."""
-
-    __metaclass__ = ABCMeta
-
-    @property
-    def close_button(self):
-        """Provide access to the close button.
-
-        :returns: The close button.
-        """
-        return self.element.find_element(By.ANON_ATTRIBUTE,
-                                         {'anonid': 'closebutton'})
-
-    @property
-    def label(self):
-        """Provide access to the notification label.
-
-        :returns: The notification label.
-        """
-        return self.element.get_attribute('label')
-
-    @property
-    def origin(self):
-        """Provide access to the notification origin.
-
-        :returns: The notification origin.
-        """
-        return self.element.get_attribute('origin')
-
-    def close(self, force=False):
-        """Close the notification.
-
-        :param force: Optional, if True force close the notification.
-         Defaults to False.
-        """
-        if force:
-            self.marionette.execute_script('arguments[0].click()',
-                                           script_args=[self.close_button])
-        else:
-            self.close_button.click()
-
-        self.window.wait_for_notification(None)
-
-
-class AddOnInstallBlockedNotification(BaseNotification):
-    """Add-on install blocked notification."""
-
-    @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'})
-
-
-class AddOnInstallConfirmationNotification(BaseNotification):
-    """Add-on install confirmation notification."""
-
-    @property
-    def addon_name(self):
-        """Provide access to the add-on name.
-
-        :returns: The add-on name.
-        """
-        label = self.element.find_element(
-            By.CSS_SELECTOR, '#addon-install-confirmation-content label')
-        return label.get_attribute('value')
-
-    def cancel_button(self):
-        """Provide access to the cancel button.
-
-        :returns: The cancel button.
-        """
-        return self.element.find_element(
-            By.ID, 'addon-install-confirmation-cancel')
-
-    def install_button(self):
-        """Provide access to the install button.
-
-        :returns: The install button.
-        """
-        return self.element.find_element(
-            By.ID, 'addon-install-confirmation-accept')
-
-
-class AddOnInstallCompleteNotification(BaseNotification):
-    """Add-on install complete notification."""
-
-    pass
-
-
-class AddOnInstallFailedNotification(BaseNotification):
-    """Add-on install failed notification."""
-
-    pass
-
-
-class AddOnProgressNotification(BaseNotification):
-    """Add-on progress notification."""
-
-    pass
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py
@@ -1,23 +1,15 @@
 # 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 marionette_driver import By, Wait
-from marionette_driver.errors import NoSuchElementException
+from marionette_driver import By
 
 from firefox_puppeteer.ui.about_window.window import AboutWindow
-from firefox_puppeteer.ui.browser.notifications import (
-    AddOnInstallBlockedNotification,
-    AddOnInstallConfirmationNotification,
-    AddOnInstallCompleteNotification,
-    AddOnInstallFailedNotification,
-    AddOnProgressNotification,
-    BaseNotification)
 from firefox_puppeteer.ui.browser.tabbar import TabBar
 from firefox_puppeteer.ui.browser.toolbars import NavBar
 from firefox_puppeteer.ui.pageinfo.window import PageInfoWindow
 from firefox_puppeteer.ui.windows import BaseWindow, Windows
 
 
 class BrowserWindow(BaseWindow):
     """Representation of a browser window."""
@@ -78,65 +70,16 @@ class BrowserWindow(BaseWindow):
 
         if not self._navbar:
             navbar = self.window_element.find_element(By.ID, 'nav-bar')
             self._navbar = NavBar(self.marionette, self, navbar)
 
         return self._navbar
 
     @property
-    def notification(self):
-        """Provides access to the currently displayed notification."""
-
-        notifications_map = {
-            'addon-install-blocked-notification': AddOnInstallBlockedNotification,
-            'addon-install-confirmation-notification': AddOnInstallConfirmationNotification,
-            'addon-install-complete-notification': AddOnInstallCompleteNotification,
-            'addon-install-failed-notification': AddOnInstallFailedNotification,
-            'addon-progress-notification': AddOnProgressNotification,
-        }
-
-        try:
-            notification = self.window_element.find_element(
-                By.CSS_SELECTOR, '#notification-popup popupnotification')
-
-            notification_id = notification.get_attribute('id')
-            return notifications_map.get(notification_id, BaseNotification)(
-                self.marionette, self, notification)
-
-        except NoSuchElementException:
-            return None  # no notification is displayed
-
-    def wait_for_notification(self, notification_class=BaseNotification,
-                              timeout=5):
-        """Waits for the specified notification to be displayed.
-
-        :param notification_class: Optional, the notification class to wait for.
-         If `None` is specified it will wait for any notification to be closed.
-         Defaults to `BaseNotification`.
-        :param timeout: Optional, how long to wait for the expected notification.
-         Defaults to 5 seconds.
-        """
-        wait = Wait(self.marionette, timeout=timeout)
-
-        if notification_class:
-            if notification_class is BaseNotification:
-                message = 'No notification was shown.'
-            else:
-                message = '{0} was not shown.'.format(notification_class.__name__)
-            wait.until(
-                lambda _: isinstance(self.notification, notification_class),
-                message=message)
-        else:
-            message = 'Unexpected notification shown.'
-            wait.until(
-                lambda _: self.notification is None,
-                message='Unexpected notification shown.')
-
-    @property
     def tabbar(self):
         """Provides access to the tab bar.
 
         See the :class:`~ui.browser.tabbar.TabBar` reference.
         """
         self.switch_to()
 
         if not self._tabbar: