Intermittent test_safe_browsing_warning_pages.py patch (bug 1334996) draft
authorui.aseem_yadav <justaseem51@gmail.com>
Tue, 28 Feb 2017 20:01:22 +0530
changeset 490475 4c387d9a5386593604bda8a171df5c69840ff2c5
parent 482164 855e6b2f6199189f37cea093cbdd1735e297e8aa
child 492032 ee355298911352c972d923a3b6b51950dbd417a1
push id47109
push userbmo:justaseem51@gmail.com
push dateTue, 28 Feb 2017 15:37:40 +0000
bugs1334996
milestone54.0a1
Intermittent test_safe_browsing_warning_pages.py patch (bug 1334996) MozReview-Commit-ID: B48fa8FMeCk
testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py
--- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py
+++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py
@@ -86,26 +86,36 @@ class TestSafeBrowsingWarningPages(Puppe
 
         # 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
-        Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
-            lambda mn: mn.execute_script('return document.readyState == "DOMContentLoaded" ||'
-                                         '       document.readyState == "complete";')
-        )
+        #Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
+        #    lambda mn: mn.execute_script('return document.readyState == "DOMContentLoaded" ||'
+        #                                 '       document.readyState == "complete";')
+        #)
+        if not self.wait_url(self.marionette.get_url(), self.browser.get_final_url(url)):
+            exit()
 
         # 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_ignore_warning_button(self, unsafe_page):
         button = self.marionette.find_element(By.ID, 'ignoreWarningButton')
         button.click()
 
         Wait(self.marionette, timeout=self.marionette.timeout.page_load).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.puppeteer.utils.permissions.remove('https://www.itisatrap.org', 'safe-browsing')
+    
+    def  wait_url(self, actual_url, checked_url):
+        ## will look for target URL from current time to 500 secs and poll every 5 secs
+        mustend=time.time() + 500
+        while time.time() < mustend:
+            if actual_url == checked_url : return True
+            time.sleep(5)
+        return 
\ No newline at end of file