Backed out changeset 7571a1477753 (bug 1374672)

This commit is contained in:
Sebastian Hengst 2017-07-08 10:49:13 +02:00
parent d8518d604e
commit 44a554344d
3 changed files with 16 additions and 48 deletions

View File

@ -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("<p id=foo>"))
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("<p id=foo>"))
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)

View File

@ -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);

View File

@ -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:<whatever> 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:<whatever> 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;