Bug 1156427 - Fix test_set_location_through_execute_script by waiting for the page to be loaded. r=ato, r=automatedtester, a=test-only
☠☠ backed out by 132a7234541c ☠ ☠
authorHenrik Skupin <mail@hskupin.info>
Thu, 08 Sep 2016 15:32:59 +0200
changeset 348177 8342c2d542023375b906f1ca123449a7ba12b303
parent 348176 e87992c4904ff879f2b7b25175403c7977a9fe82
child 348178 0ef7c87780c6ffd6f758fed8588c46a82af8311c
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, automatedtester, test-only
bugs1156427
milestone50.0a2
Bug 1156427 - Fix test_set_location_through_execute_script by waiting for the page to be loaded. r=ato, r=automatedtester, a=test-only
testing/marionette/harness/marionette/tests/unit/test_navigation.py
--- a/testing/marionette/harness/marionette/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_navigation.py
@@ -1,40 +1,40 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import time
+import unittest
 import urllib
 
 from marionette import MarionetteTestCase
 from marionette_driver.errors import MarionetteException, TimeoutException
-from marionette_driver.by import By
+from marionette_driver import By, Wait
 
 
 def inline(doc):
     return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
 
 
 class TestNavigate(MarionetteTestCase):
     def setUp(self):
         MarionetteTestCase.setUp(self)
-        self.marionette.execute_script("window.location.href = 'about:blank'")
-        self.assertEqual("about:blank", self.location_href)
+        self.marionette.navigate("about:")
         self.test_doc = self.marionette.absolute_url("test.html")
         self.iframe_doc = self.marionette.absolute_url("test_iframe.html")
 
     def test_set_location_through_execute_script(self):
         self.marionette.execute_script("window.location.href = '%s'" % self.test_doc)
-        self.assertEqual(self.test_doc, self.location_href)
+        Wait(self.marionette).until(lambda _: self.test_doc == self.location_href)
         self.assertEqual("Marionette Test", self.marionette.title)
 
     def test_navigate(self):
         self.marionette.navigate(self.test_doc)
-        self.assertNotEqual("about:blank", self.location_href)
+        self.assertNotEqual("about:", self.location_href)
         self.assertEqual("Marionette Test", self.marionette.title)
 
     def test_navigate_chrome_error(self):
         with self.marionette.using_context("chrome"):
             self.assertRaisesRegexp(MarionetteException, "Cannot navigate in chrome context",
                                     self.marionette.navigate, "about:blank")
 
     def test_get_current_url_returns_top_level_browsing_context_url(self):
@@ -118,16 +118,17 @@ class TestNavigate(MarionetteTestCase):
         self.assertEqual(self.marionette.get_url(), "about:blocked")
 
     def test_find_element_state_complete(self):
         self.marionette.navigate(self.test_doc)
         state = self.marionette.execute_script("return window.document.readyState")
         self.assertEqual("complete", state)
         self.assertTrue(self.marionette.find_element(By.ID, "mozLink"))
 
+    @unittest.skip("Bug 1302707 - No timeout exception raised.")
     def test_should_throw_a_timeoutexception_when_loading_page(self):
         try:
             self.marionette.timeouts("page load", 0)
             self.marionette.navigate(self.test_doc)
             self.assertTrue(self.marionette.find_element(By.ID, "mozLink"))
             self.fail("Should have thrown a MarionetteException")
         except TimeoutException as e:
             self.assertTrue("Error loading page, timed out" in str(e))