def test_submit_unencrypted_info_warning(self):
        with self.marionette.using_context('content'):
            self.marionette.navigate(self.url)

            # Get the page's search box and submit button.
            searchbox = self.marionette.find_element(By.ID, 'q')
            button = self.marionette.find_element(By.ID, 'submit')

            # Use the page's search box to submit information.
            searchbox.send_keys(self.test_string)
            button.click()

            # Get the expected warning text and replace its two instances of "##" with "\n\n".
            message = self.browser.get_property('formPostSecureToInsecureWarning.message')
            message = message.replace('##', '\n\n')

            # Wait for the warning, verify the expected text matches warning, accept the warning
            warning = Alert(self.marionette)
            try:
                Wait(self.marionette, ignored_exceptions=NoAlertPresentException).until(
                    lambda _: warning.text == message)
            finally:
                warning.accept()

            # Wait while the page updates
            self.wait_for_condition(expected.element_stale(searchbox))

            # Check that search_term contains the test string.
            search_term = self.marionette.find_element(By.ID, 'search-term')
            self.assertEqual(search_term.get_attribute('textContent'), self.test_string)
    def check_report_button(self, unsafe_page):
        button = self.marionette.find_element(By.ID, "reportButton")
        button.click()

        # Wait for the button to become stale, then wait for page load
        # so we can verify the url
        self.wait_for_condition(expected.element_stale(button))
        # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
        self.wait_for_condition(lambda mn: mn.execute_script("""
          return document.readyState == 'complete';
        """))

        # Get the base URL to check; this will result in a redirect.
        with self.marionette.using_context('chrome'):
            if 'its-a-trap' in unsafe_page:
                url = self.marionette.execute_script("""
                  Components.utils.import("resource://gre/modules/Services.jsm");
                  return Services.urlFormatter.formatURLPref("app.support.baseURL")
                                                             + "phishing-malware";
                """)
            else:
                url = self.marionette.execute_script("""
                  Components.utils.import("resource://gre/modules/Services.jsm");
                  return Services.urlFormatter.formatURLPref(
                  "browser.safebrowsing.malware.reportURL") + arguments[0];
                """, script_args=[unsafe_page])

        # check that our current url matches the final url we expect
        self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(url))
 def test_element_stale(self):
     self.marionette.navigate(static_element)
     el = self.marionette.find_element(By.TAG_NAME, "p")
     self.assertIsNotNone(el)
     self.marionette.execute_script(remove_element_by_tag_name.format("p"))
     r = expected.element_stale(el)(self.marionette)
     self.assertTrue(r)
Beispiel #4
0
 def test_element_stale(self):
     self.marionette.navigate(static_element)
     el = self.marionette.find_element(By.TAG_NAME, "p")
     self.assertIsNotNone(el)
     self.marionette.execute_script(remove_element_by_tag_name.format("p"))
     r = expected.element_stale(el)(self.marionette)
     self.assertTrue(r)
    def check_report_button(self, unsafe_page):
        # Get the URL of the support site for phishing and malware. This may result in a redirect.
        with self.marionette.using_context('chrome'):
            url = self.marionette.execute_script("""
              Components.utils.import("resource://gre/modules/Services.jsm");
              return Services.urlFormatter.formatURLPref("app.support.baseURL")
                                                         + "phishing-malware";
            """)

        button = self.marionette.find_element(By.ID, "reportButton")
        button.click()

        # Wait for the button to become stale, whereby a longer timeout is needed
        # here to not fail in case of slow connections.
        Wait(self.marionette, timeout=self.browser.timeout_page_load).until(
            expected.element_stale(button))

        # Wait for page load to be completed, so we can verify the URL even if a redirect happens.
        # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
        Wait(self.marionette, timeout=self.browser.timeout_page_load).until(
            lambda mn: mn.execute_script(
                'return document.readyState == "DOMContentLoaded" ||'
                '       document.readyState == "complete";'))

        # check that our current url matches the final url we expect
        self.assertEquals(self.marionette.get_url(),
                          self.browser.get_final_url(url))
    def check_report_link(self, unsafe_page):
        # Get the URL of the support site for phishing and malware. This may result in a redirect.
        with self.marionette.using_context('chrome'):
            url = self.marionette.execute_script("""
              Components.utils.import("resource://gre/modules/Services.jsm");
              return Services.urlFormatter.formatURLPref("app.support.baseURL")
                                                         + "phishing-malware";
            """)

        button = self.marionette.find_element(By.ID, 'seeDetailsButton')
        button.click()
        link = self.marionette.find_element(By.ID, "firefox_support")
        link.click()

        # Wait for the button to become stale, whereby a longer timeout is needed
        # here to not fail in case of slow connections.
        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
            expected.element_stale(button))

        # Wait for page load to be completed, so we can verify the URL even if a redirect happens.
        # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
        expected_url = self.browser.get_final_url(url)
        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
            lambda mn: expected_url == mn.get_url(),
            message="The expected URL '{}' has not been loaded".format(expected_url)
        )

        topic = self.marionette.find_element(By.ID, "topic")
        self.assertEquals(topic.text, "phishing-malware")
Beispiel #7
0
    def check_report_link(self, unsafe_page):
        # Get the URL of the support site for phishing and malware. This may result in a redirect.
        with self.marionette.using_context('chrome'):
            url = self.marionette.execute_script("""
              Components.utils.import("resource://gre/modules/Services.jsm");
              return Services.urlFormatter.formatURLPref("app.support.baseURL")
                                                         + "phishing-malware";
            """)

        button = self.marionette.find_element(By.ID, 'seeDetailsButton')
        button.click()
        link = self.marionette.find_element(By.ID, "firefox_support")
        link.click()

        # Wait for the button to become stale, whereby a longer timeout is needed
        # here to not fail in case of slow connections.
        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
            expected.element_stale(button))

        # Wait for page load to be completed, so we can verify the URL even if a redirect happens.
        # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
        expected_url = self.browser.get_final_url(url)
        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
            lambda mn: expected_url == mn.get_url(),
            message="The expected URL '{}' has not been loaded".format(
                expected_url))

        topic = self.marionette.find_element(By.ID, "topic")
        self.assertEquals(topic.text, "phishing-malware")
Beispiel #8
0
    def check_report_button(self, unsafe_page):
        button = self.marionette.find_element(By.ID, "reportButton")
        button.click()

        # Wait for the button to become stale, then wait for page load
        # so we can verify the url
        self.wait_for_condition(expected.element_stale(button))
        # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
        self.wait_for_condition(lambda mn: mn.execute_script("""
          return document.readyState == 'complete';
        """))

        # Get the base URL to check; this will result in a redirect.
        with self.marionette.using_context('chrome'):
            if 'its-a-trap' in unsafe_page:
                url = self.marionette.execute_script("""
                  Components.utils.import("resource://gre/modules/Services.jsm");
                  return Services.urlFormatter.formatURLPref("app.support.baseURL")
                                                             + "phishing-malware";
                """)
            else:
                url = self.marionette.execute_script("""
                  Components.utils.import("resource://gre/modules/Services.jsm");
                  return Services.urlFormatter.formatURLPref(
                  "browser.safebrowsing.malware.reportURL") + arguments[0];
                """,
                                                     script_args=[unsafe_page])

        # check that our current url matches the final url we expect
        self.assertEquals(self.marionette.get_url(),
                          self.browser.get_final_url(url))
Beispiel #9
0
    def test_submit_unencrypted_info_warning(self):
        with self.marionette.using_context('content'):
            self.marionette.navigate(self.url)

            # Get the page's search box and submit button.
            searchbox = self.marionette.find_element(By.ID, 'q')
            button = self.marionette.find_element(By.ID, 'submit')

            # Use the page's search box to submit information.
            searchbox.send_keys(self.test_string)
            button.click()

            # Get the expected warning text and replace its two instances of "##" with "\n\n".
            message = self.browser.get_property(
                'formPostSecureToInsecureWarning.message')
            message = message.replace('##', '\n\n')

            # Wait for the warning, verify the expected text matches warning, accept the warning
            warning = Alert(self.marionette)
            try:
                Wait(self.marionette,
                     ignored_exceptions=NoAlertPresentException).until(
                         lambda _: warning.text == message)
            finally:
                warning.accept()

            # Wait while the page updates
            self.wait_for_condition(expected.element_stale(searchbox))

            # Check that search_term contains the test string.
            search_term = self.marionette.find_element(By.ID, 'search-term')
            self.assertEqual(search_term.get_attribute('textContent'),
                             self.test_string)
    def check_report_button(self, unsafe_page):
        # Get the URL of the support site for phishing and malware. This may result in a redirect.
        with self.marionette.using_context("chrome"):
            url = self.marionette.execute_script(
                """
              Components.utils.import("resource://gre/modules/Services.jsm");
              return Services.urlFormatter.formatURLPref("app.support.baseURL")
                                                         + "phishing-malware";
            """
            )

        button = self.marionette.find_element(By.ID, "reportButton")
        button.click()

        # Wait for the button to become stale, whereby a longer timeout is needed
        # here to not fail in case of slow connections.
        Wait(self.marionette, timeout=self.browser.timeout_page_load).until(expected.element_stale(button))

        # Wait for page load to be completed, so we can verify the URL even if a redirect happens.
        # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
        Wait(self.marionette, timeout=self.browser.timeout_page_load).until(
            lambda mn: mn.execute_script(
                'return document.readyState == "DOMContentLoaded" ||' '       document.readyState == "complete";'
            )
        )

        # check that our current url matches the final url we expect
        self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(url))
 def check_x_button(self):
     with self.marionette.using_context('chrome'):
         # TODO: update to use safe browsing notification bar class when bug 1139544 lands
         button = (self.marionette.find_element(By.ID, 'content')
                   .find_element('anon attribute', {'value': 'blocked-badware-page'})
                   .find_element('anon attribute',
                                 {'class': 'messageCloseButton close-icon tabbable'}))
         button.click()
         self.wait_for_condition(expected.element_stale(button))
    def check_ignore_warning_button(self, unsafe_page):
        button = self.marionette.find_element(By.ID, 'ignoreWarningButton')
        button.click()

        Wait(self.marionette).until(expected.element_stale(button))
        Wait(self.marionette).until(expected.element_present(By.ID, 'main-feature'))
        self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(unsafe_page))

        # Clean up by removing safe browsing permission for unsafe page
        self.utils.remove_perms('www.itisatrap.org', 'safe-browsing')
    def check_ignore_warning_button(self, unsafe_page):
        button = self.marionette.find_element(By.ID, "ignoreWarningButton")
        button.click()

        Wait(self.marionette).until(expected.element_stale(button))
        Wait(self.marionette).until(expected.element_present(By.ID, "main-feature"))
        self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(unsafe_page))

        # Clean up here since the permission gets set in this function
        self.utils.remove_perms("www.itisatrap.org", "safe-browsing")
 def check_x_button(self):
     with self.marionette.using_context("chrome"):
         # TODO: update to use safe browsing notification bar class when bug 1139544 lands
         button = (
             self.marionette.find_element(By.ID, "content")
             .find_element("anon attribute", {"value": "blocked-badware-page"})
             .find_element("anon attribute", {"class": "messageCloseButton close-icon tabbable"})
         )
         button.click()
         Wait(self.marionette).until(expected.element_stale(button))
    def check_ignore_warning_button(self, unsafe_page):
        button = self.marionette.find_element(By.ID, 'ignoreWarningButton')
        button.click()

        self.wait_for_condition(expected.element_stale(button))
        self.wait_for_condition(expected.element_present(By.ID, 'main-feature'))
        self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(unsafe_page))

        # Clean up here since the permission gets set in this function
        self.utils.remove_perms('www.itisatrap.org', 'safe-browsing')
    def check_x_button(self):
        with self.marionette.using_context('chrome'):
            # TODO: update to use safe browsing notification bar class when bug 1139544 lands
            button = (self.marionette.find_element(By.ID, 'content')
                      .find_element('anon attribute', {'value': 'blocked-badware-page'})
                      .find_element('anon attribute',
                                    {'class': 'messageCloseButton close-icon tabbable'}))
            button.click()

            Wait(self.marionette, timeout=self.browser.timeout_page_load).until(
                expected.element_stale(button))
    def check_ignore_warning_button(self, unsafe_page):
        button = self.marionette.find_element(By.ID, 'ignoreWarningButton')
        button.click()

        self.wait_for_condition(expected.element_stale(button))
        self.wait_for_condition(expected.element_present(
            By.ID, 'main-feature'))
        self.assertEquals(self.marionette.get_url(),
                          self.browser.get_final_url(unsafe_page))

        # Clean up here since the permission gets set in this function
        self.utils.remove_perms('www.itisatrap.org', 'safe-browsing')
Beispiel #18
0
    def check_x_button(self):
        with self.marionette.using_context('chrome'):
            # TODO: update to use safe browsing notification bar class when bug 1139544 lands
            button = (self.marionette.find_element(By.ID, 'content')
                      .find_element('anon attribute', {'value': 'blocked-badware-page'})
                      .find_element('anon attribute',
                                    {'class': 'messageCloseButton close-icon tabbable'}))
            button.click()

            Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
                expected.element_stale(button),
                message='The notification bar has not been closed',
            )
Beispiel #19
0
    def check_x_button(self):
        with self.marionette.using_context('chrome'):
            button = (self.marionette.find_element(
                By.ID, 'tabbrowser-tabbox').find_element(
                    By.CSS_SELECTOR,
                    'notification[value=blocked-badware-page]').find_element(
                        By.CSS_SELECTOR, '.messageCloseButton'))
            button.click()

            Wait(self.marionette,
                 timeout=self.marionette.timeout.page_load).until(
                     expected.element_stale(button),
                     message='The notification bar has not been closed',
                 )
Beispiel #20
0
    def check_x_button(self):
        with self.marionette.using_context("chrome"):
            notification_box = self.marionette.find_element(
                By.CSS_SELECTOR, 'vbox.notificationbox-stack[slot="selected"]')
            message = notification_box.find_element(
                By.CSS_SELECTOR,
                "notification-message[value=blocked-badware-page]")
            button = message.get_property("closeButton")
            button.click()

            Wait(self.marionette,
                 timeout=self.marionette.timeout.page_load).until(
                     expected.element_stale(button),
                     message="The notification bar has not been closed",
                 )
    def test_submit_unencrypted_info_warning(self):
        with self.marionette.using_context('content'):
            self.marionette.navigate(self.url)

            # Get the page's search box and submit button.
            searchbox = self.marionette.find_element(By.ID, 'q')
            button = self.marionette.find_element(By.ID, 'submit')

            # Use the page's search box to submit information.
            searchbox.send_keys(self.test_string)
            button.click()

            # Get the expected warning text and replace its two instances of "##" with "\n\n".
            message = self.browser.get_property(
                'formPostSecureToInsecureWarning.message')
            message = message.replace('##', '\n\n')

            # Wait for the warning, verify the expected text matches warning, accept the warning
            warning = Alert(self.marionette)
            try:
                Wait(self.marionette,
                     ignored_exceptions=NoAlertPresentException,
                     timeout=self.browser.timeout_page_load).until(
                         lambda _: warning.text == message)
            finally:
                warning.accept()

            # Wait for the search box to become stale, then wait for the page to be reloaded.
            Wait(self.marionette).until(expected.element_stale(searchbox))

            # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
            Wait(self.marionette,
                 timeout=self.browser.timeout_page_load).until(
                     lambda mn: mn.execute_script(
                         'return document.readyState == "DOMContentLoaded" ||'
                         '       document.readyState == "complete";'))

            # Check that search_term contains the test string.
            search_term = self.marionette.find_element(By.ID, 'search-term')
            self.assertEqual(search_term.get_attribute('textContent'),
                             self.test_string)
    def test_submit_unencrypted_info_warning(self):
        with self.marionette.using_context('content'):
            self.marionette.navigate(self.url)

            # Get the page's search box and submit button.
            searchbox = self.marionette.find_element(By.ID, 'q')
            button = self.marionette.find_element(By.ID, 'submit')

            # Use the page's search box to submit information.
            searchbox.send_keys(self.test_string)
            button.click()

            # Get the expected warning text and replace its two instances of "##" with "\n\n".
            message = self.browser.get_property('formPostSecureToInsecureWarning.message')
            message = message.replace('##', '\n\n')

            # Wait for the warning, verify the expected text matches warning, accept the warning
            warning = Alert(self.marionette)
            try:
                Wait(self.marionette,
                     ignored_exceptions=NoAlertPresentException,
                     timeout=self.browser.timeout_page_load).until(
                    lambda _: warning.text == message)
            finally:
                warning.accept()

            # Wait for the search box to become stale, then wait for the page to be reloaded.
            Wait(self.marionette).until(expected.element_stale(searchbox))

            # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad
            Wait(self.marionette, timeout=self.browser.timeout_page_load).until(
                lambda mn: mn.execute_script('return document.readyState == "DOMContentLoaded" ||'
                                             '       document.readyState == "complete";')
            )

            # Check that search_term contains the test string.
            search_term = self.marionette.find_element(By.ID, 'search-term')
            self.assertEqual(search_term.get_property('textContent'), self.test_string)
Beispiel #23
0
 def test_element_stale_is_not_stale(self):
     self.marionette.navigate(static_element)
     el = self.marionette.find_element(By.TAG_NAME, "p")
     r = expected.element_stale(el)(self.marionette)
     self.assertFalse(r)
 def test_element_stale_is_not_stale(self):
     self.marionette.navigate(static_element)
     el = self.marionette.find_element(By.TAG_NAME, "p")
     r = expected.element_stale(el)(self.marionette)
     self.assertFalse(r)