mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 1368101 - getCurrentUrl can retrieve the URL via the chrome process. r=ato
There is no reason for the command to call into the content framescript. It's only adding overhead and can currently cause hangs if the framescript gets reloaded. Instead use the content browser which is always aware of the current URL. MozReview-Commit-ID: 9Ui7qClFEWJ --HG-- extra : rebase_source : e428e71ddb66e0152d164f2aebd20efb0593ceec
This commit is contained in:
parent
4e3f82bfc8
commit
2d096423ea
@ -1022,7 +1022,12 @@ GeckoDriver.prototype.getCurrentUrl = function (cmd) {
|
||||
return win.location.href;
|
||||
|
||||
case Context.CONTENT:
|
||||
return this.listener.getCurrentUrl();
|
||||
if (this.curBrowser.contentBrowser) {
|
||||
return this.curBrowser.contentBrowser.currentURI.spec;
|
||||
} else {
|
||||
throw new NoSuchWindowError(
|
||||
"Not a browser window, or no tab currently selected");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1112,7 +1117,7 @@ GeckoDriver.prototype.goBack = function* (cmd, resp) {
|
||||
return;
|
||||
}
|
||||
|
||||
let currentURL = yield this.listener.getCurrentUrl();
|
||||
let currentURL = this.getCurrentUrl();
|
||||
let goBack = this.listener.goBack({pageTimeout: this.timeouts.pageLoad});
|
||||
|
||||
// If a remoteness update interrupts our page load, this will never return
|
||||
@ -1159,7 +1164,7 @@ GeckoDriver.prototype.goForward = function* (cmd, resp) {
|
||||
return;
|
||||
}
|
||||
|
||||
let currentURL = yield this.listener.getCurrentUrl();
|
||||
let currentURL = this.getCurrentUrl();
|
||||
let goForward = this.listener.goForward({pageTimeout: this.timeouts.pageLoad});
|
||||
|
||||
// If a remoteness update interrupts our page load, this will never return
|
||||
|
@ -0,0 +1,49 @@
|
||||
# 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 marionette_driver.errors import NoSuchWindowException
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin, skip_if_mobile
|
||||
|
||||
|
||||
class TestGetCurrentUrlChrome(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestGetCurrentUrlChrome, self).setUp()
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(TestGetCurrentUrlChrome, self).tearDown()
|
||||
|
||||
def test_browser_window(self):
|
||||
url = self.marionette.absolute_url("test.html")
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(url)
|
||||
self.assertEqual(self.marionette.get_url(), url)
|
||||
|
||||
chrome_url = self.marionette.execute_script("return window.location.href;")
|
||||
self.assertEqual(self.marionette.get_url(), chrome_url)
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_no_browser_window(self):
|
||||
|
||||
def open_window_with_js():
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
win = self.open_window(trigger=open_window_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
chrome_url = self.marionette.execute_script("return window.location.href;")
|
||||
self.assertEqual(self.marionette.get_url(), chrome_url)
|
||||
|
||||
# With no tabbrowser available an exception will be thrown
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.get_url()
|
@ -217,7 +217,6 @@ class TestNavigate(BaseNavigationTestCase):
|
||||
self.marionette.switch_to_window(self.new_tab)
|
||||
self.marionette.navigate(self.test_page_remote)
|
||||
|
||||
@skip("Bug 1334137 - Intermittent: Process killed because of hang in getCurrentUrl()")
|
||||
@skip_if_mobile("Interacting with chrome elements not available for Fennec")
|
||||
def test_type_to_non_remote_tab(self):
|
||||
self.marionette.navigate(self.test_page_not_remote)
|
||||
|
@ -39,6 +39,7 @@ skip-if = true # "Bug 896046"
|
||||
[test_findelement_chrome.py]
|
||||
skip-if = appname == 'fennec'
|
||||
|
||||
[test_get_current_url_chrome.py]
|
||||
[test_navigation.py]
|
||||
|
||||
[test_timeouts.py]
|
||||
|
@ -469,7 +469,6 @@ var getElementTextFn = dispatch(getElementText);
|
||||
var getElementTagNameFn = dispatch(getElementTagName);
|
||||
var getElementRectFn = dispatch(getElementRect);
|
||||
var isElementEnabledFn = dispatch(isElementEnabled);
|
||||
var getCurrentUrlFn = dispatch(getCurrentUrl);
|
||||
var findElementContentFn = dispatch(findElementContent);
|
||||
var findElementsContentFn = dispatch(findElementsContent);
|
||||
var isElementSelectedFn = dispatch(isElementSelected);
|
||||
@ -508,7 +507,6 @@ function startListeners() {
|
||||
addMessageListenerId("Marionette:get", get);
|
||||
addMessageListenerId("Marionette:waitForPageLoaded", waitForPageLoaded);
|
||||
addMessageListenerId("Marionette:cancelRequest", cancelRequest);
|
||||
addMessageListenerId("Marionette:getCurrentUrl", getCurrentUrlFn);
|
||||
addMessageListenerId("Marionette:getTitle", getTitleFn);
|
||||
addMessageListenerId("Marionette:getPageSource", getPageSourceFn);
|
||||
addMessageListenerId("Marionette:goBack", goBack);
|
||||
@ -587,7 +585,6 @@ function deleteSession(msg) {
|
||||
removeMessageListenerId("Marionette:cancelRequest", cancelRequest);
|
||||
removeMessageListenerId("Marionette:getTitle", getTitleFn);
|
||||
removeMessageListenerId("Marionette:getPageSource", getPageSourceFn);
|
||||
removeMessageListenerId("Marionette:getCurrentUrl", getCurrentUrlFn);
|
||||
removeMessageListenerId("Marionette:goBack", goBack);
|
||||
removeMessageListenerId("Marionette:goForward", goForward);
|
||||
removeMessageListenerId("Marionette:refresh", refresh);
|
||||
@ -1222,13 +1219,6 @@ function refresh(msg) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL of the top-level browsing context.
|
||||
*/
|
||||
function getCurrentUrl() {
|
||||
return content.location.href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the current browsing context.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user