def _test_appear(self, test_url, dest_url, info):
        self._open_page_and_click_on_first_link(test_url)

        self.assertTrue(self.redir.is_shown(),
                        "The redirect notification has been displayed.")
        redirections.assert_url_does_not_load(self, dest_url,
            expected_delay=info["delay"])

        self.redir.close()
        def test_appear(test_url, dest_url, info, *args):
            open_page_and_open_first_link_in_new_tab(test_url, *args)

            # Select the new tab
            tabbar.tabs[1].select()

            self.assertTrue(self.redir.is_shown(),
                            "The redirect notification has been displayed "
                            "in the destination tab.")
            redirections.assert_url_does_not_load(self, dest_url,
                expected_delay=info["delay"])

            # Close the new tab.
            tabbar.close_tab()

            self.assertFalse(self.redir.is_shown(),
                             "There's no redirect notification in the "
                             "origin tab.")
        def test_appear(test_url, dest_url, info, *args):
            open_page_and_open_first_link_in_new_tab(test_url, *args)

            # Select the new tab
            tabbar.tabs[1].select()

            redirections.assert_redir_is_shown(
                self, test_url, dest_url, is_shown=True,
                additional_info="destination tab")
            redirections.assert_url_does_not_load(
                self, dest_url,
                expected_delay=info["delay"])

            # Close the new tab.
            tabbar.close_tab()

            redirections.assert_redir_is_shown(
                self, test_url, dest_url, is_shown=False,
                additional_info="origin tab")
    def test_r21n_appears_again_after_allow(self):
        raise SkipTest("Skipping due to issue #726.")

        def test((test_url, dest_url), info):
            if info["is_same_host"]:
                # the notification won't appear
                return

            self._load_about_blank()
            self._navigate_expecting_r21n(test_url)
            self.assertTrue(self.redir.is_shown())
            redirections.assert_url_does_not_load(self, dest_url,
                expected_delay=info["delay"])
            self.redir.allow()

            self._load_about_blank()
            self._navigate_expecting_r21n(test_url)
            self.assertTrue(self.redir.is_shown())
            redirections.assert_url_does_not_load(self, dest_url,
                expected_delay=info["delay"])
            self.redir.close()
Example #5
0
    def test_r21n_appears_again_after_allow(self):
        raise SkipTest("Skipping due to issue #726.")

        def test((test_url, dest_url), info):
            if info["is_same_host"]:
                # the notification won't appear
                return

            self._load_about_blank()
            self._navigate_expecting_r21n(test_url)
            self.assertTrue(self.redir.is_shown())
            redirections.assert_url_does_not_load(self,
                                                  dest_url,
                                                  expected_delay=info["delay"])
            self.redir.allow()

            self._load_about_blank()
            self._navigate_expecting_r21n(test_url)
            self.assertTrue(self.redir.is_shown())
            redirections.assert_url_does_not_load(self,
                                                  dest_url,
                                                  expected_delay=info["delay"])
            self.redir.close()
            def test_appear(test_url, dest_url, info, *args):
                open_page_and_open_first_link_in_new_tab(test_url, *args)

                # Select the new tab
                tabbar.tabs[1].select()

                redirections.assert_redir_is_shown(
                    self,
                    test_url,
                    dest_url,
                    is_shown=True,
                    additional_info="destination tab")
                redirections.assert_url_does_not_load(
                    self, dest_url, expected_delay=info["delay"])

                # Close the new tab.
                tabbar.close_tab()

                redirections.assert_redir_is_shown(
                    self,
                    test_url,
                    dest_url,
                    is_shown=False,
                    additional_info="origin tab")
Example #7
0
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()

    ################
    # Test Methods #
    ################

    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((test_url, dest_url), info):
            with self.marionette.using_context("content"):
                self.marionette.navigate(test_url)

            # The page might redirect with a delay. There shouldn't be the
            # notification neither before nor after the redirection.
            self.assertFalse(self.redir.is_shown(),
                             "There's no redirect notification.")
            redirections.wait_until_url_load(self, dest_url,
                                             "The location has changed.")
            self.assertFalse(self.redir.is_shown(),
                             "There's no redirect notification.")

        def test_appear((test_url, dest_url), info):
            self._load_about_blank()
            self._navigate_expecting_r21n(test_url)

            self.assertTrue(self.redir.is_shown(),
                            "The redirect notification has been displayed.")
            redirections.assert_url_does_not_load(self,
                                                  dest_url,
                                                  expected_delay=info["delay"])

            self.redir.close()