Backed out changeset dba85e8288af (bug 1291320)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 29 Mar 2017 00:30:51 +0200
changeset 350174 bb3aeeaea5f7630af625bdf7298832f135e6dc39
parent 350173 87a9bacef9df5e40ccfea4977a27286fd846500c
child 350175 7697c16a882838db729af63efdd8790a976f2342
push id39700
push userarchaeopteryx@coole-files.de
push dateTue, 28 Mar 2017 22:32:01 +0000
treeherderautoland@7c1fe74aad56 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1291320
milestone55.0a1
backs outdba85e8288aff3e00f66efebb4f66ffa7f0a3f66
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset dba85e8288af (bug 1291320)
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
testing/marionette/listener.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1123,24 +1123,22 @@ GeckoDriver.prototype.goForward = functi
     this.mm.broadcastAsyncMessage(
         "Marionette:waitForPageLoaded" + this.curBrowser.curFrameId,
         parameters);
   });
 
   yield goForward;
 };
 
-/**
- * Causes the browser to reload the page in in current top-level browsing context.
- */
-GeckoDriver.prototype.refresh = function* (cmd, resp) {
+/** Refresh the page. */
+GeckoDriver.prototype.refresh = function*(cmd, resp) {
   assert.content(this.context);
   assert.window(this.getCurrentWindow());
 
-  yield this.listener.refresh({pageTimeout: this.timeouts.pageLoad});
+  yield this.listener.refresh();
 };
 
 /**
  * Forces an update for the given browser's id.
  */
 GeckoDriver.prototype.updateIdForBrowser = function (browser, newId) {
   this._browserIds.set(browser.permanentKey, newId);
 };
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -1,13 +1,14 @@
 # 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 contextlib
+import time
 import urllib
 
 from marionette_driver import By, errors, expected, Wait
 from marionette_driver.keys import Keys
 from marionette_harness import (
     MarionetteTestCase,
     run_if_e10s,
     run_if_manage_instance,
@@ -21,17 +22,16 @@ def inline(doc):
     return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
 
 
 class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
 
     def setUp(self):
         super(BaseNavigationTestCase, self).setUp()
 
-        self.test_page_frameset = self.marionette.absolute_url("frameset.html")
         self.test_page_insecure = self.fixtures.where_is("test.html", on="https")
         self.test_page_not_remote = "about:robots"
         self.test_page_remote = self.marionette.absolute_url("test.html")
 
         if self.marionette.session_capabilities["platformName"] == "darwin":
             self.mod_key = Keys.META
         else:
             self.mod_key = Keys.CONTROL
@@ -121,24 +121,41 @@ class TestNavigate(BaseNavigationTestCas
         self.assertEqual(page_iframe, self.marionette.get_url())
 
     def test_get_current_url(self):
         self.marionette.navigate(self.test_page_remote)
         self.assertEqual(self.test_page_remote, self.marionette.get_url())
         self.marionette.navigate("about:blank")
         self.assertEqual("about:blank", self.marionette.get_url())
 
+    def test_refresh(self):
+        self.marionette.navigate(self.test_page_remote)
+        self.assertEqual("Marionette Test", self.marionette.title)
+        self.assertTrue(self.marionette.execute_script(
+            """var elem = window.document.createElement('div'); elem.id = 'someDiv';
+            window.document.body.appendChild(elem); return true;"""))
+        self.assertFalse(self.marionette.execute_script(
+            "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"))
+
     def test_navigate_in_child_frame_changes_to_top(self):
-        self.marionette.navigate(self.test_page_frameset)
+        page_frameset = self.marionette.absolute_url("frameset.html")
+
+        self.marionette.navigate(page_frameset)
         frame = self.marionette.find_element(By.NAME, "third")
         self.marionette.switch_to_frame(frame)
         self.assertRaises(errors.NoSuchElementException,
                           self.marionette.find_element, By.NAME, "third")
 
-        self.marionette.navigate(self.test_page_frameset)
+        self.marionette.navigate(page_frameset)
         self.marionette.find_element(By.NAME, "third")
 
     def test_invalid_url(self):
         with self.assertRaises(errors.MarionetteException):
             self.marionette.navigate("foo")
         with self.assertRaises(errors.MarionetteException):
             self.marionette.navigate("thisprotocoldoesnotexist://")
 
@@ -468,75 +485,16 @@ class TestBackForwardNavigation(BaseNavi
              "error": errors.InsecureCertificateException},
             {"url": self.test_page_remote},
             {"url": self.test_page_insecure,
              "error": errors.InsecureCertificateException},
         ]
         self.run_bfcache_test(test_pages)
 
 
-class TestRefresh(BaseNavigationTestCase):
-
-    def test_basic(self):
-        self.marionette.navigate(self.test_page_remote)
-        self.assertEqual(self.test_page_remote, self.marionette.get_url())
-
-        self.marionette.execute_script("""
-          let elem = window.document.createElement('div');
-          elem.id = 'someDiv';
-          window.document.body.appendChild(elem);
-        """)
-        self.marionette.find_element(By.ID, "someDiv")
-
-        self.marionette.refresh()
-        self.assertEqual(self.test_page_remote, self.marionette.get_url())
-        with self.assertRaises(errors.NoSuchElementException):
-            self.marionette.find_element(By.ID, "someDiv")
-
-    def test_refresh_in_child_frame_navigates_to_top(self):
-        self.marionette.navigate(self.test_page_frameset)
-        self.assertEqual(self.test_page_frameset, self.marionette.get_url())
-
-        frame = self.marionette.find_element(By.NAME, "third")
-        self.marionette.switch_to_frame(frame)
-        self.assertRaises(errors.NoSuchElementException,
-                          self.marionette.find_element, By.NAME, "third")
-
-        self.marionette.refresh()
-        self.marionette.find_element(By.NAME, "third")
-
-    def test_image(self):
-        image = self.marionette.absolute_url('black.png')
-
-        self.marionette.navigate(image)
-        self.assertEqual(image, self.marionette.get_url())
-
-        self.marionette.refresh()
-        self.assertEqual(image, self.marionette.get_url())
-
-    def test_timeout_error(self):
-        slow_page = self.marionette.absolute_url("slow?delay=3")
-
-        self.marionette.navigate(slow_page)
-        self.assertEqual(slow_page, self.marionette.get_url())
-
-        self.marionette.timeout.page_load = 0.5
-        with self.assertRaises(errors.TimeoutException):
-            self.marionette.refresh()
-        self.assertEqual(slow_page, self.marionette.get_url())
-
-    def test_insecure_error(self):
-        with self.assertRaises(errors.InsecureCertificateException):
-            self.marionette.navigate(self.test_page_insecure)
-        self.assertEqual(self.test_page_insecure, self.marionette.get_url())
-
-        with self.assertRaises(errors.InsecureCertificateException):
-            self.marionette.refresh()
-
-
 class TestTLSNavigation(MarionetteTestCase):
     insecure_tls = {"acceptInsecureCerts": True}
     secure_tls = {"acceptInsecureCerts": False}
 
     def setUp(self):
         super(TestTLSNavigation, self).setUp()
 
         self.test_page_insecure = self.fixtures.where_is("test.html", on="https")
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -1137,36 +1137,16 @@ function goForward(msg) {
   let {command_id, pageTimeout} = msg.json;
 
   loadListener.navigate(() => {
     curContainer.frame.history.forward();
   }, command_id, pageTimeout);
 }
 
 /**
- * Causes the browser to reload the page in in current top-level browsing context.
- *
- * @param {number} command_id
- *     ID of the currently handled message between the driver and listener.
- * @param {number} pageTimeout
- *     Timeout in milliseconds the method has to wait for the page being finished loading.
- */
-function refresh(msg) {
-  let {command_id, pageTimeout} = msg.json;
-
-  // We need to move to the top frame before navigating
-  sendSyncMessage("Marionette:switchedToFrame", {frameValue: null});
-  curContainer.frame = content;
-
-  loadListener.navigate(() => {
-    curContainer.frame.location.reload(true);
-  }, command_id, pageTimeout);
-}
-
-/**
  * Get URL of the top-level browsing context.
  */
 function getCurrentUrl() {
   return content.location.href;
 }
 
 /**
  * Get the title of the current browsing context.
@@ -1178,16 +1158,29 @@ function getTitle() {
 /**
  * Get source of the current browsing context's DOM.
  */
 function getPageSource() {
   return curContainer.frame.document.documentElement.outerHTML;
 }
 
 /**
+ * Refresh the page
+ */
+function refresh(msg) {
+  let command_id = msg.json.command_id;
+  curContainer.frame.location.reload(true);
+  let listen = function() {
+    removeEventListener("DOMContentLoaded", listen, false);
+    sendOk(command_id);
+  };
+  addEventListener("DOMContentLoaded", listen, false);
+}
+
+/**
  * Find an element in the current browsing context's document using the
  * given search strategy.
  */
 function* findElementContent(strategy, selector, opts = {}) {
   if (!SUPPORTED_STRATEGIES.has(strategy)) {
     throw new InvalidSelectorError("Strategy not supported: " + strategy);
   }