[Pkg-mozext-commits] [requestpolicy] 77/257: [tst][add] Marionette test: auto-redirections

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:19:59 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 be35aeafd67040f00420cd8e2fb01c10ffdb1f38
Author: Martin Kimmerle <dev at 256k.de>
Date:   Wed Oct 14 02:40:55 2015 +0200

    [tst][add] Marionette test: auto-redirections
    
    Convert Mozmill test
    "testRedirect/testAutoRedirect.js"
    to Marionette.
---
 tests/marionette/tests/manifest.ini                |  1 +
 tests/marionette/tests/redirections/manifest.ini   |  1 +
 .../tests/redirections/test_auto_redirect.py       | 76 ++++++++++++++++++++++
 3 files changed, 78 insertions(+)

diff --git a/tests/marionette/tests/manifest.ini b/tests/marionette/tests/manifest.ini
index 7bf2dcf..120286d 100644
--- a/tests/marionette/tests/manifest.ini
+++ b/tests/marionette/tests/manifest.ini
@@ -1,4 +1,5 @@
 [include:addon_install_and_upgrade/manifest.ini]
 [include:links/manifest.ini]
 [include:policy/manifest.ini]
+[include:redirections/manifest.ini]
 [test_setup_page.py]
diff --git a/tests/marionette/tests/redirections/manifest.ini b/tests/marionette/tests/redirections/manifest.ini
new file mode 100644
index 0000000..9c6b428
--- /dev/null
+++ b/tests/marionette/tests/redirections/manifest.ini
@@ -0,0 +1 @@
+[test_auto_redirect.py]
diff --git a/tests/marionette/tests/redirections/test_auto_redirect.py b/tests/marionette/tests/redirections/test_auto_redirect.py
new file mode 100644
index 0000000..fbbcdf8
--- /dev/null
+++ b/tests/marionette/tests/redirections/test_auto_redirect.py
@@ -0,0 +1,76 @@
+# 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 rp_ui_harness.testcases import RequestPolicyTestCase
+from marionette_driver.errors import TimeoutException
+
+
+PREF_DEFAULT_ALLOW = "extensions.requestpolicy.defaultPolicy.allow"
+
+
+class TestAutoRedirect(RequestPolicyTestCase):
+
+    def setUp(self):
+        super(TestAutoRedirect, self).setUp()
+
+        self.prefs.set_pref(PREF_DEFAULT_ALLOW, False)
+
+    def tearDown(self):
+        try:
+            self.prefs.reset_pref(PREF_DEFAULT_ALLOW)
+        finally:
+            super(TestAutoRedirect, self).tearDown()
+
+    def test_redirect_notification_appears_or_not(self):
+        """Using some pages which cause redirections, this test ensures
+        that the redirect notification appears when it's expected and stays
+        hidden when it's not expected.
+        """
+
+        def test_no_appear(path):
+            test_url = "http://www.maindomain.test/" + path
+
+            with self.marionette.using_context("content"):
+                self.marionette.navigate(test_url)
+
+            self.assertNotEqual(self.marionette.get_url(), test_url,
+                                "The URL in the urlbar has changed.")
+            self.assertFalse(self.redir.is_shown(),
+                             "There's no redirect notification.")
+
+        def test_appear(path):
+            test_url = "http://www.maindomain.test/" + path
+
+            initial_uri = self.marionette.get_url()
+
+            # Load the page, expecting a TimeoutException, because when
+            # RequestPolicy blocks a redirection, the page never loads.
+            with self.marionette.using_context("content"):
+                # Set the timeout to a low value in order to speed up the
+                # test.
+                self.marionette.timeouts("page load", 100)
+                self.assertRaises(TimeoutException, self.marionette.navigate,
+                                  test_url)
+                self.marionette.timeouts("page load", 20000)
+
+            self.assertTrue(self.redir.is_shown(),
+                            "The redirect notification has been displayed.")
+            self.assertIn(self.marionette.get_url(), [test_url, initial_uri],
+                          "The URL in the urlbar did not change.")
+
+            self.redir.close()
+
+        test_appear("redirect-http-location-header.php")
+        test_appear("redirect-http-refresh-header.php")
+        test_appear("redirect-js-document-location-auto.html")
+        test_appear("redirect-meta-tag-01-immediate.html")
+        test_appear("redirect-meta-tag-02-delayed.html")
+        test_appear("redirect-meta-tag-03-multiple.html")
+        test_appear("redirect-meta-tag-08.html")
+
+        test_no_appear("redirect-meta-tag-04-relative-without-slash.html")
+        test_no_appear("redirect-meta-tag-05-relative-with-slash.html")
+        test_no_appear("redirect-meta-tag-06-different-formatting.html")
+        test_no_appear("redirect-meta-tag-07-different-formatting-delayed.html")
+        test_no_appear("redirect-meta-tag-09-relative.html")

-- 
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