From 44a554344d2ffc9ebe273dbcc7656489ca5ce25c Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Sat, 8 Jul 2017 10:49:13 +0200 Subject: [PATCH] Backed out changeset 7571a1477753 (bug 1374672) --- .../tests/unit/test_navigation.py | 16 ------- testing/marionette/listener.js | 4 +- testing/marionette/navigate.js | 44 ++++++------------- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py index 9931cd4e6540..4a518cd6e301 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py @@ -197,22 +197,6 @@ class TestNavigate(BaseNavigationTestCase): self.assertTrue(self.marionette.execute_script( "return window.visited", sandbox=None)) - def test_navigate_hash_argument_identical(self): - test_page = "{}#foo".format(inline("

")) - - self.marionette.navigate(test_page) - self.marionette.find_element(By.ID, "foo") - self.marionette.navigate(test_page) - self.marionette.find_element(By.ID, "foo") - - def test_navigate_hash_argument_differnt(self): - test_page = "{}#Foo".format(inline("

")) - - self.marionette.navigate(test_page) - self.marionette.find_element(By.ID, "foo") - self.marionette.navigate(test_page.lower()) - self.marionette.find_element(By.ID, "foo") - @skip_if_mobile("Test file is only located on host machine") def test_navigate_file_url(self): self.marionette.navigate(self.test_page_file_url) diff --git a/testing/marionette/listener.js b/testing/marionette/listener.js index d93e2ec70714..08334be94bad 100644 --- a/testing/marionette/listener.js +++ b/testing/marionette/listener.js @@ -1137,9 +1137,9 @@ function get(msg) { try { if (typeof url == "string") { try { + let requestedURL = new URL(url).toString(); if (loadEventExpected === null) { - loadEventExpected = navigate.isLoadEventExpected( - curContainer.frame.location, url); + loadEventExpected = navigate.isLoadEventExpected(requestedURL); } } catch (e) { let err = new InvalidArgumentError("Malformed URL: " + e.message); diff --git a/testing/marionette/navigate.js b/testing/marionette/navigate.js index ab15194e46f3..20f424afbf91 100644 --- a/testing/marionette/navigate.js +++ b/testing/marionette/navigate.js @@ -14,45 +14,29 @@ this.navigate = {}; /** * Determines if we expect to get a DOM load event (DOMContentLoaded) - * on navigating to the |future| URL. + * on navigating to the |url|. * - * @param {string} current - * URL the browser is currently visiting. - * @param {string=} future - * Destination URL, if known. + * @param {string} url + * Destination URL * * @return {boolean} - * Full page load would be expected if future is followed. + * Full page load would be expected if url gets loaded. * * @throws TypeError - * If |current| is not defined, or any of |current| or |future| - * are invalid URLs. + * If |url| is an invalid URL. */ -navigate.isLoadEventExpected = function(current, future = undefined) { +navigate.isLoadEventExpected = function(url) { // assume we will go somewhere exciting - if (typeof current == "undefined") { - throw TypeError("Expected at least one URL"); + if (typeof url == "undefined") { + throw TypeError("Expected destination URL"); } - // Assume we will go somewhere exciting - if (typeof future == "undefined") { - return true; - } - - let cur = new URL(current); - let fut = new URL(future); - - // Assume javascript: will modify the current document - // but this is not an entirely safe assumption to make, - // considering it could be used to set window.location - if (fut.protocol == "javascript:") { - return false; - } - - // If hashes are present and identical - if (cur.href.includes("#") && fut.href.includes("#") && - cur.hash === fut.hash) { - return false; + switch (new URL(url).protocol) { + // assume javascript: will modify current document + // but this is not an entirely safe assumption to make, + // considering it could be used to set window.location + case "javascript:": + return false; } return true;