From 0c281b238cec40c9d00cc5344566e493194b0796 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Thu, 13 Apr 2017 14:57:25 +0200 Subject: [PATCH] Bug 1335778 - Harden test_page_timeout_fail against intermittent failures. r=ato Tests for page timeout durations have to use an HTTPD handler that delays or slows down document load. Otherwise there a risk that the timeout error is not returned before the document finishes loading. MozReview-Commit-ID: HGGcXfCuaSH --HG-- extra : rebase_source : c79b01ca4e56e21877c6fe94309b7b0424d9b552 --- .../marionette_harness/tests/unit/test_timeouts.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py b/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py index 9268e7175d30..6961be880065 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py @@ -24,8 +24,9 @@ class TestTimeouts(MarionetteTestCase): def test_page_timeout_fail(self): self.marionette.timeout.page_load = 0 - test_html = self.marionette.absolute_url("test.html") - self.assertRaises(MarionetteException, self.marionette.navigate, test_html) + test_html = self.marionette.absolute_url("slow") + with self.assertRaises(MarionetteException): + self.marionette.navigate(test_html) def test_page_timeout_pass(self): self.marionette.timeout.page_load = 60 @@ -36,9 +37,11 @@ class TestTimeouts(MarionetteTestCase): test_html = self.marionette.absolute_url("test.html") self.marionette.navigate(test_html) self.marionette.timeout.implicit = 1 - self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page") + with self.assertRaises(NoSuchElementException): + self.marionette.find_element(By.ID, "I'm not on the page") self.marionette.timeout.implicit = 0 - self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page") + with self.assertRaises(NoSuchElementException): + self.marionette.find_element(By.ID, "I'm not on the page") @skip_if_mobile("Bug 1317121 - android emulator is too slow") def test_search_timeout_found_settimeout(self): @@ -82,7 +85,8 @@ class TestTimeouts(MarionetteTestCase): test_html = self.marionette.absolute_url("test.html") self.marionette.navigate(test_html) self.marionette.timeout.script = 1 - self.assertRaises(ScriptTimeoutException, self.marionette.execute_async_script, "var x = 1;") + with self.assertRaises(ScriptTimeoutException): + self.marionette.execute_async_script("var x = 1;") def test_no_timeout_settimeout(self): test_html = self.marionette.absolute_url("test.html")