[Pkg-mozext-commits] [requestpolicy] 123/257: [tst][add] r21n library: the "allow" button

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:20:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 6ddaa0711d85f797ad8df33d9af409389c9c624b
Author: Martin Kimmerle <dev at 256k.de>
Date:   Thu Oct 29 23:30:54 2015 +0100

    [tst][add] r21n library: the "allow" button
    
    Add the `RedirectNotification.allow()` function and tests for
    that button.
---
 .../tests/test_redirect_notification.py            | 18 ++++++-
 .../rp_puppeteer/ui/redirect_notification.py       | 22 +++++++++
 .../tests/redirections/test_auto_redirect.py       | 57 ++++++++++++++++++++++
 3 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/tests/marionette/rp_puppeteer/tests/test_redirect_notification.py b/tests/marionette/rp_puppeteer/tests/test_redirect_notification.py
index 795415a..a3d1709 100644
--- a/tests/marionette/rp_puppeteer/tests/test_redirect_notification.py
+++ b/tests/marionette/rp_puppeteer/tests/test_redirect_notification.py
@@ -7,6 +7,8 @@ from rp_ui_harness import RequestPolicyTestCase
 
 PRE_PATH = "http://www.maindomain.test/"
 PAGE_WITH_REDIRECT = PRE_PATH + "redirect-meta-tag-01-immediate.html"
+PAGE_WITH_REDIRECT__DEST = ("http://www.otherdomain.test/destination.html?"
+                            "redirect-meta-tag-01%20redirected%20here.")
 PREF_DEFAULT_ALLOW = "extensions.requestpolicy.defaultPolicy.allow"
 
 
@@ -24,9 +26,23 @@ class TestRedirectNotification(RequestPolicyTestCase):
         finally:
             super(TestRedirectNotification, self).tearDown()
 
+    def test_allow(self):
+        with self.marionette.using_context("content"):
+            # FIXME: Remove the "?..." part when #726 is fixed.
+            self.marionette.navigate(PAGE_WITH_REDIRECT + "?test_allow")
+
+        self.assertTrue(self.redir.is_shown())
+        self.redir.allow()
+
+        with self.marionette.using_context("content"):
+            self.assertEqual(self.marionette.get_url(),
+                             PAGE_WITH_REDIRECT__DEST)
+        self.assertFalse(self.redir.is_shown())
+
     def test_close(self):
         with self.marionette.using_context("content"):
-            self.marionette.navigate(PAGE_WITH_REDIRECT)
+            # FIXME: Remove the "?..." part when #726 is fixed.
+            self.marionette.navigate(PAGE_WITH_REDIRECT + "?test_close")
 
         self.assertTrue(self.redir.is_shown())
         self.redir.close()
diff --git a/tests/marionette/rp_puppeteer/ui/redirect_notification.py b/tests/marionette/rp_puppeteer/ui/redirect_notification.py
index 0c54ae1..f041027 100644
--- a/tests/marionette/rp_puppeteer/ui/redirect_notification.py
+++ b/tests/marionette/rp_puppeteer/ui/redirect_notification.py
@@ -3,6 +3,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from firefox_puppeteer.base import BaseLib
+from rp_puppeteer.api.l10n import L10n
+from firefox_puppeteer.ui.windows import Windows
+from rp_puppeteer.ui.tabs import Tabs
 from marionette_driver.errors import NoSuchElementException
 from marionette_driver.wait import Wait
 import time
@@ -30,10 +33,23 @@ class RedirectNotification(BaseLib):
         except NoSuchElementException:
             return False
 
+    def allow(self):
+        """Allow the redirection."""
+
+        self._allow_button.click()
+
+        # Wait for the tab to load.
+        # TODO: Bug 1140470: use replacement for mozmill's waitForPageLoad
+        Wait(self.marionette).until(lambda _: not self.is_shown())
+        win = Windows(lambda: self.marionette).current
+        tab = win.tabbar.selected_tab
+        Tabs(lambda: self.marionette).wait_until_loaded(tab)
+
     def close(self):
         """Close the notification bar."""
 
         self._close_button.click()
+        # TODO: Bug 1140470: use replacement for mozmill's waitForPageLoad
         Wait(self.marionette).until(lambda _: not self.is_shown())
 
     ##################################
@@ -50,6 +66,12 @@ class RedirectNotification(BaseLib):
                               "[value='request-policy-meta-redirect']"))
 
     @property
+    def _allow_button(self):
+        label = L10n(lambda: self.marionette).get_rp_property("allow")
+        return self._panel.find_element("css selector",
+                                        "[label='{}']".format(label))
+
+    @property
     def _close_button(self):
         return (
             self._panel
diff --git a/tests/marionette/tests/redirections/test_auto_redirect.py b/tests/marionette/tests/redirections/test_auto_redirect.py
index 940a281..b102c02 100644
--- a/tests/marionette/tests/redirections/test_auto_redirect.py
+++ b/tests/marionette/tests/redirections/test_auto_redirect.py
@@ -4,6 +4,7 @@
 
 from rp_ui_harness.testcases import RequestPolicyTestCase
 from marionette_driver.errors import TimeoutException
+from marionette import SkipTest
 
 
 PREF_DEFAULT_ALLOW = "extensions.requestpolicy.defaultPolicy.allow"
@@ -34,6 +35,8 @@ class TestAutoRedirect(RequestPolicyTestCase):
 
         def test_no_appear(path):
             test_url = "http://www.maindomain.test/" + path
+            # FIXME: Remove the following line when #726 is fixed.
+            test_url += "?test_redirect_notification_appears_or_not"
 
             with self.marionette.using_context("content"):
                 self.marionette.navigate(test_url)
@@ -45,6 +48,8 @@ class TestAutoRedirect(RequestPolicyTestCase):
 
         def test_appear(path):
             test_url = "http://www.maindomain.test/" + path
+            # FIXME: Remove the following line when #726 is fixed.
+            test_url += "?test_redirect_notification_appears_or_not"
 
             initial_uri = self.marionette.get_url()
 
@@ -75,6 +80,58 @@ class TestAutoRedirect(RequestPolicyTestCase):
         test_no_appear("redirect-meta-tag-07-different-formatting-delayed.html")
         test_no_appear("redirect-meta-tag-09-relative.html")
 
+    def test_allow(self):
+
+        def test(path, dest_uri):
+            test_url = "http://www.maindomain.test/" + path
+            # FIXME: Remove the following line when #726 is fixed.
+            test_url += "?test_allow"
+
+            self._navigate_expecting_r21n(test_url)
+            self.assertTrue(self.redir.is_shown())
+            self.redir.allow()
+            self.assertFalse(self.redir.is_shown())
+            with self.marionette.using_context("content"):
+                self.assertEqual(self.marionette.get_url(), dest_uri)
+
+        # FIXME: Issue #727
+        if not self.browser_info.e10s_enabled:
+            # Header redirection
+            test("redirect-http-location-header.php",
+                 "http://www.otherdomain.test/")
+
+        # JavaScript redirection
+        test("redirect-js-document-location-auto.html",
+             "http://www.otherdomain.test/")
+        # <meta> redirection
+        test("redirect-meta-tag-01-immediate.html",
+             ("http://www.otherdomain.test/destination.html?"
+              "redirect-meta-tag-01%20redirected%20here."))
+
+    def test_r21n_appears_again_after_allow(self):
+        raise SkipTest("Skipping due to issue #726.")
+
+        def test(path):
+            test_url = "http://www.maindomain.test/" + path
+
+            self._navigate_expecting_r21n(test_url)
+            self.assertTrue(self.redir.is_shown())
+            self.redir.allow()
+
+            self._navigate_expecting_r21n(test_url)
+            self.assertTrue(self.redir.is_shown())
+            self.redir.close()
+
+        # FIXME: Issue #727
+        if not self.browser_info.e10s_enabled:
+            # Header redirection
+            test("redirect-http-location-header.php")
+
+        # JavaScript redirection
+        test("redirect-js-document-location-auto.html")
+        # <meta> redirection
+        test("redirect-meta-tag-01-immediate.html")
+
     ##########################
     # Private Helper Methods #
     ##########################

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list