Bug 1323451 - Fix test failures in test_navigation.py for Fennec. r=ato a=test-only
authorHenrik Skupin <mail@hskupin.info>
Thu, 15 Dec 2016 17:00:20 +0100
changeset 353119 b494291dfc820d0f3beb0bab76461ec27861730d
parent 353118 41b3724c902ea0436391c131b444e6fa1af881c5
child 353120 4543f401f05f833ede3c950e7d7037b87b1d5dfd
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, test-only
bugs1323451
milestone52.0a2
Bug 1323451 - Fix test failures in test_navigation.py for Fennec. r=ato a=test-only MozReview-Commit-ID: 9YmBJIp0vAJ
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1010,56 +1010,21 @@ GeckoDriver.prototype.get = function*(cm
             "Marionette:pollForReadyState" + this.curBrowser.curFrameId,
             cmd.parameters);
       });
 
       yield get;
       break;
 
     case Context.CHROME:
-      // At least on desktop, navigating in chrome scope does not
-      // correspond to something a user can do, and leaves marionette
-      // and the browser in an unusable state. Return a generic error insted.
-      // TODO: Error codes need to be refined as a part of bug 1100545 and
-      // bug 945729.
-      if (this.appName == "Firefox") {
-        throw new UnknownError("Cannot navigate in chrome context");
-      }
-
-      this.getCurrentWindow().location.href = url;
-      yield this.pageLoadPromise();
+      throw new UnsupportedOperationError("Cannot navigate in chrome context");
       break;
   }
 };
 
-GeckoDriver.prototype.pageLoadPromise = function() {
-  let win = this.getCurrentWindow();
-  let timeout = this.pageTimeout;
-  let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-  let start = new Date().getTime();
-  let end = null;
-
-  return new Promise((resolve) => {
-    let checkLoad = function() {
-      end = new Date().getTime();
-      let elapse = end - start;
-      if (timeout === null || elapse <= timeout) {
-        if (win.document.readyState == "complete") {
-          resolve();
-        } else {
-          checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
-        }
-      } else {
-        throw new UnknownError("Error loading page");
-      }
-    };
-    checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
-  });
-};
-
 /**
  * Get a string representing the current URL.
  *
  * On Desktop this returns a string representation of the URL of the
  * current top level browsing context.  This is equivalent to
  * document.location.href.
  *
  * When in the context of the chrome, this returns the canonical URL
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -1,19 +1,21 @@
 # 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/.
 
+from unittest import skip
+
 import contextlib
 import time
 import urllib
 
 from marionette_driver import errors, By, Wait
 
-from marionette_harness import MarionetteTestCase, WindowManagerMixin
+from marionette_harness import MarionetteTestCase, skip_if_mobile, WindowManagerMixin
 
 
 def inline(doc):
     return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
 
 
 class TestNavigate(WindowManagerMixin, MarionetteTestCase):
 
@@ -43,18 +45,18 @@ class TestNavigate(WindowManagerMixin, M
     def test_navigate(self):
         self.marionette.navigate(self.test_doc)
         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(
-                errors.MarionetteException, "Cannot navigate in chrome context",
-                                    self.marionette.navigate, "about:blank")
+                errors.UnsupportedOperationException, "Cannot navigate in chrome context",
+                self.marionette.navigate, "about:blank")
 
     def test_get_current_url_returns_top_level_browsing_context_url(self):
         self.marionette.navigate(self.iframe_doc)
         self.assertEqual(self.iframe_doc, self.location_href)
         frame = self.marionette.find_element(By.CSS_SELECTOR, "#test_iframe")
         self.marionette.switch_to_frame(frame)
         self.assertEqual(self.iframe_doc, self.marionette.get_url())
 
@@ -96,26 +98,26 @@ class TestNavigate(WindowManagerMixin, M
             "return window.document.getElementById('someDiv') == undefined"))
         self.marionette.refresh()
         # TODO(ato): Bug 1291320
         time.sleep(0.2)
         self.assertEqual("Marionette Test", self.marionette.title)
         self.assertTrue(self.marionette.execute_script(
             "return window.document.getElementById('someDiv') == undefined"))
 
-    """ Disabled due to Bug 977899
+    @skip("Disabled due to Bug 977899")
     def test_navigate_frame(self):
         self.marionette.navigate(self.marionette.absolute_url("test_iframe.html"))
         self.marionette.switch_to_frame(0)
         self.marionette.navigate(self.marionette.absolute_url("empty.html"))
         self.assertTrue('empty.html' in self.marionette.get_url())
         self.marionette.switch_to_frame()
         self.assertTrue('test_iframe.html' in self.marionette.get_url())
-    """
 
+    @skip_if_mobile  # Bug 1323755 - Socket timeout
     def test_invalid_protocol(self):
         with self.assertRaises(errors.MarionetteException):
             self.marionette.navigate("thisprotocoldoesnotexist://")
 
     def test_should_navigate_to_requested_about_page(self):
         self.marionette.navigate("about:neterror")
         self.assertEqual(self.marionette.get_url(), "about:neterror")
         self.marionette.navigate(self.marionette.absolute_url("test.html"))
@@ -143,16 +145,17 @@ class TestNavigate(WindowManagerMixin, M
     def test_fragment(self):
         doc = inline("<p id=foo>")
         self.marionette.navigate(doc)
         self.marionette.execute_script("window.visited = true", sandbox=None)
         self.marionette.navigate("%s#foo" % doc)
         self.assertTrue(self.marionette.execute_script(
             "return window.visited", sandbox=None))
 
+    @skip_if_mobile  # Fennec doesn't support other chrome windows
     def test_about_blank_for_new_docshell(self):
         """ Bug 1312674 - Hang when loading about:blank for a new docshell."""
         # Open a window to get a new docshell created for the first tab
         with self.marionette.using_context("chrome"):
             tab = self.open_tab(lambda: self.marionette.execute_script(" window.open() "))
             self.marionette.switch_to_window(tab)
 
         self.marionette.navigate('about:blank')