Bug 1353447 - Fix race condition in TestBackForwardNavigation.test_timeout_error. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 24 Apr 2017 13:08:13 +0200
changeset 567083 301271f0f088e550d7e0f72cf0080b3da7ea9f93
parent 566881 73752931e273091185e1e4b5231c28beed657cc8
child 567131 f0908663187b3c5fd595a3573651acd25a13c279
push id55435
push userbmo:hskupin@gmail.com
push dateMon, 24 Apr 2017 11:08:33 +0000
bugs1353447
milestone55.0a1
Bug 1353447 - Fix race condition in TestBackForwardNavigation.test_timeout_error. The test doesn't care about the page load status when a timeout error happened for a back and forward command. It only compares the urlbar for the expected url, but doesn't actually wait for the required element on the page. MozReview-Commit-ID: 8w0iP62rlQZ
testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -442,34 +442,34 @@ class TestBackForwardNavigation(BaseNavi
         self.assertEqual(urls[1], self.marionette.get_url())
 
         # Force triggering a timeout error
         self.marionette.timeout.page_load = 0.5
         with self.assertRaises(errors.TimeoutException):
             self.marionette.go_back()
         self.marionette.timeout.reset()
 
-        Wait(self.marionette, self.marionette.timeout.page_load).until(
-            lambda mn: urls[0] == mn.get_url(),
-            message="'{}' has been successfully loaded after going back".format(urls[0]))
-        self.assertEqual(self.marionette.find_element(By.ID, "delay").text, "3")
+        delay = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
+            expected.element_present(By.ID, "delay"),
+            message="Target element 'delay' has not been found after timeout in 'back'")
+        self.assertEqual(delay.text, "3")
 
         self.marionette.go_forward()
         self.assertEqual(urls[1], self.marionette.get_url())
 
         # Force triggering a timeout error
         self.marionette.timeout.page_load = 0.5
         with self.assertRaises(errors.TimeoutException):
             self.marionette.go_forward()
         self.marionette.timeout.reset()
 
-        Wait(self.marionette, self.marionette.timeout.page_load).until(
-            lambda mn: urls[2] == mn.get_url(),
-            message="'{}' has been successfully loaded after going back".format(urls[2]))
-        self.assertEqual(self.marionette.find_element(By.ID, "delay").text, "4")
+        delay = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
+            expected.element_present(By.ID, "delay"),
+            message="Target element 'delay' has not been found after timeout in 'forward'")
+        self.assertEqual(delay.text, "4")
 
     def test_certificate_error(self):
         test_pages = [
             {"url": self.test_page_insecure,
              "error": errors.InsecureCertificateException},
             {"url": self.test_page_remote},
             {"url": self.test_page_insecure,
              "error": errors.InsecureCertificateException},