зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 0faaff778221 (bug 1291320) for frequently failing test_navigation.py TestNavigate.test_focus_after_navigation. r=backout
This commit is contained in:
Родитель
2fd692d1a3
Коммит
f42b8eb770
|
@ -0,0 +1,134 @@
|
|||
# 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 import By, Wait
|
||||
from marionette_driver.keys import Keys
|
||||
|
||||
from marionette_harness import MarionetteTestCase, skip, skip_if_mobile, WindowManagerMixin
|
||||
|
||||
|
||||
class TestAboutPages(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAboutPages, self).setUp()
|
||||
|
||||
if self.marionette.session_capabilities['platformName'] == 'darwin':
|
||||
self.mod_key = Keys.META
|
||||
else:
|
||||
self.mod_key = Keys.CONTROL
|
||||
|
||||
self.remote_uri = self.marionette.absolute_url("windowHandles.html")
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_tabs()
|
||||
|
||||
super(TestAboutPages, self).tearDown()
|
||||
|
||||
def open_tab_with_link(self):
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(self.remote_uri)
|
||||
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
@skip_if_mobile("Bug 1333209 - Process killed because of connection loss")
|
||||
def test_back_forward(self):
|
||||
# Bug 1311041 - Prevent changing of window handle by forcing the test
|
||||
# to be run in a new tab.
|
||||
new_tab = self.open_tab(trigger=self.open_tab_with_link)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.marionette.navigate("about:blank")
|
||||
self.marionette.navigate(self.remote_uri)
|
||||
self.marionette.navigate("about:support")
|
||||
|
||||
self.marionette.go_back()
|
||||
self.assertEqual(self.marionette.get_url(), self.remote_uri)
|
||||
|
||||
self.marionette.go_forward()
|
||||
self.assertEqual(self.marionette.get_url(), "about:support")
|
||||
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
@skip_if_mobile("Bug 1333209 - Process killed because of connection loss")
|
||||
def test_navigate_non_remote_about_pages(self):
|
||||
# Bug 1311041 - Prevent changing of window handle by forcing the test
|
||||
# to be run in a new tab.
|
||||
new_tab = self.open_tab(trigger=self.open_tab_with_link)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.marionette.navigate("about:blank")
|
||||
self.assertEqual(self.marionette.get_url(), "about:blank")
|
||||
self.marionette.navigate("about:support")
|
||||
self.assertEqual(self.marionette.get_url(), "about:support")
|
||||
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
@skip_if_mobile("On Android no shortcuts are available")
|
||||
def test_navigate_shortcut_key(self):
|
||||
def open_with_shortcut():
|
||||
self.marionette.navigate(self.remote_uri)
|
||||
with self.marionette.using_context("chrome"):
|
||||
main_win = self.marionette.find_element(By.ID, "main-window")
|
||||
main_win.send_keys(self.mod_key, Keys.SHIFT, 'a')
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_shortcut)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
Wait(self.marionette).until(lambda mn: mn.get_url() == "about:addons",
|
||||
message="'about:addons' hasn't been loaded")
|
||||
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
@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):
|
||||
# Bug 1311041 - Prevent changing of window handle by forcing the test
|
||||
# to be run in a new tab.
|
||||
new_tab = self.open_tab(trigger=self.open_tab_with_link)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
with self.marionette.using_context("chrome"):
|
||||
urlbar = self.marionette.find_element(By.ID, 'urlbar')
|
||||
urlbar.send_keys(self.mod_key + 'a')
|
||||
urlbar.send_keys(self.mod_key + 'x')
|
||||
urlbar.send_keys('about:support' + Keys.ENTER)
|
||||
Wait(self.marionette).until(lambda mn: mn.get_url() == "about:support",
|
||||
message="'about:support' hasn't been loaded")
|
||||
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
@skip_if_mobile("Interacting with chrome elements not available for Fennec")
|
||||
def test_type_to_remote_tab(self):
|
||||
# Bug 1311041 - Prevent changing of window handle by forcing the test
|
||||
# to be run in a new tab.
|
||||
new_tab = self.open_tab(trigger=self.open_tab_with_link)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
# about:blank keeps remoteness from remote_uri
|
||||
self.marionette.navigate("about:blank")
|
||||
with self.marionette.using_context("chrome"):
|
||||
urlbar = self.marionette.find_element(By.ID, 'urlbar')
|
||||
urlbar.send_keys(self.mod_key + 'a')
|
||||
urlbar.send_keys(self.mod_key + 'x')
|
||||
urlbar.send_keys(self.remote_uri + Keys.ENTER)
|
||||
|
||||
Wait(self.marionette).until(lambda mn: mn.get_url() == self.remote_uri,
|
||||
message="'{}' hasn't been loaded".format(self.remote_uri))
|
||||
|
||||
@skip_if_mobile("Needs application independent method to open a new tab")
|
||||
def test_hang(self):
|
||||
# Bug 1311041 - Prevent changing of window handle by forcing the test
|
||||
# to be run in a new tab.
|
||||
new_tab = self.open_tab(trigger=self.open_tab_with_link)
|
||||
|
||||
# Close the start tab
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.marionette.navigate(self.remote_uri)
|
|
@ -7,7 +7,6 @@ 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,
|
||||
|
@ -22,19 +21,12 @@ def inline(doc):
|
|||
return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
|
||||
|
||||
|
||||
class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
|
||||
class TestBackForwardNavigation(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(BaseNavigationTestCase, self).setUp()
|
||||
super(TestBackForwardNavigation, self).setUp()
|
||||
|
||||
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
|
||||
self.test_page = self.marionette.absolute_url('test.html')
|
||||
|
||||
def open_with_link():
|
||||
link = self.marionette.find_element(By.ID, "new-blank-tab")
|
||||
|
@ -47,52 +39,16 @@ class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertEqual(self.history_length, 1)
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.timeout.reset()
|
||||
self.marionette.switch_to_parent_frame()
|
||||
|
||||
self.close_all_tabs()
|
||||
|
||||
super(BaseNavigationTestCase, self).tearDown()
|
||||
super(TestBackForwardNavigation, self).tearDown()
|
||||
|
||||
@property
|
||||
def history_length(self):
|
||||
return self.marionette.execute_script("return window.history.length;")
|
||||
|
||||
@property
|
||||
def is_remote_tab(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
# TODO: DO NOT USE MOST RECENT WINDOW BUT CURRENT ONE
|
||||
return self.marionette.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
let win = null;
|
||||
|
||||
if (AppConstants.MOZ_APP_NAME == "fennec") {
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
} else {
|
||||
Components.utils.import("resource:///modules/RecentWindow.jsm");
|
||||
win = RecentWindow.getMostRecentBrowserWindow();
|
||||
}
|
||||
|
||||
let tabBrowser = null;
|
||||
|
||||
// Fennec
|
||||
if (win.BrowserApp) {
|
||||
tabBrowser = win.BrowserApp.selectedBrowser;
|
||||
|
||||
// Firefox
|
||||
} else if (win.gBrowser) {
|
||||
tabBrowser = win.gBrowser.selectedBrowser;
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return tabBrowser.isRemoteBrowser;
|
||||
""")
|
||||
|
||||
def run_bfcache_test(self, test_pages):
|
||||
def run_test(self, test_pages):
|
||||
# Helper method to run simple back and forward testcases.
|
||||
for index, page in enumerate(test_pages):
|
||||
if "error" in page:
|
||||
|
@ -103,11 +59,6 @@ class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertEqual(page["url"], self.marionette.get_url())
|
||||
self.assertEqual(self.history_length, index + 1)
|
||||
|
||||
if "is_remote" in page:
|
||||
self.assertEqual(page["is_remote"], self.is_remote_tab,
|
||||
"'{}' doesn't match expected remoteness state: {}".format(
|
||||
page["url"], page["is_remote"]))
|
||||
|
||||
for page in test_pages[-2::-1]:
|
||||
if "error" in page:
|
||||
with self.assertRaises(page["error"]):
|
||||
|
@ -116,11 +67,6 @@ class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.go_back()
|
||||
self.assertEqual(page["url"], self.marionette.get_url())
|
||||
|
||||
if "is_remote" in page:
|
||||
self.assertEqual(page["is_remote"], self.is_remote_tab,
|
||||
"'{}' doesn't match expected remoteness state: {}".format(
|
||||
page["url"], page["is_remote"]))
|
||||
|
||||
for page in test_pages[1::]:
|
||||
if "error" in page:
|
||||
with self.assertRaises(page["error"]):
|
||||
|
@ -129,194 +75,6 @@ class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.go_forward()
|
||||
self.assertEqual(page["url"], self.marionette.get_url())
|
||||
|
||||
if "is_remote" in page:
|
||||
self.assertEqual(page["is_remote"], self.is_remote_tab,
|
||||
"'{}' doesn't match expected remoteness state: {}".format(
|
||||
page["url"], page["is_remote"]))
|
||||
|
||||
|
||||
class TestNavigate(BaseNavigationTestCase):
|
||||
|
||||
def test_set_location_through_execute_script(self):
|
||||
self.marionette.execute_script(
|
||||
"window.location.href = '%s'" % self.test_page_remote)
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.test_page_remote == self.marionette.get_url())
|
||||
self.assertEqual("Marionette Test", self.marionette.title)
|
||||
|
||||
def test_navigate_chrome_unsupported_error(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.assertRaises(errors.UnsupportedOperationException,
|
||||
self.marionette.navigate, "about:blank")
|
||||
self.assertRaises(errors.UnsupportedOperationException, self.marionette.go_back)
|
||||
self.assertRaises(errors.UnsupportedOperationException, self.marionette.go_forward)
|
||||
self.assertRaises(errors.UnsupportedOperationException, self.marionette.refresh)
|
||||
|
||||
def test_get_current_url_returns_top_level_browsing_context_url(self):
|
||||
page_iframe = self.marionette.absolute_url("test_iframe.html")
|
||||
|
||||
self.marionette.navigate(page_iframe)
|
||||
self.assertEqual(page_iframe, self.marionette.get_url())
|
||||
frame = self.marionette.find_element(By.CSS_SELECTOR, "#test_iframe")
|
||||
self.marionette.switch_to_frame(frame)
|
||||
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):
|
||||
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(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://")
|
||||
|
||||
def test_find_element_state_complete(self):
|
||||
self.marionette.navigate(self.test_page_remote)
|
||||
state = self.marionette.execute_script(
|
||||
"return window.document.readyState")
|
||||
self.assertEqual("complete", state)
|
||||
self.assertTrue(self.marionette.find_element(By.ID, "mozLink"))
|
||||
|
||||
def test_navigate_timeout_error_no_remoteness_change(self):
|
||||
is_remote_before_timeout = self.is_remote_tab
|
||||
self.marionette.timeout.page_load = 0.1
|
||||
with self.assertRaises(errors.TimeoutException):
|
||||
self.marionette.navigate(self.marionette.absolute_url("slow"))
|
||||
self.assertEqual(self.is_remote_tab, is_remote_before_timeout)
|
||||
|
||||
@run_if_e10s("Requires e10s mode enabled")
|
||||
def test_navigate_timeout_error_remoteness_change(self):
|
||||
self.assertTrue(self.is_remote_tab)
|
||||
self.marionette.navigate("about:robots")
|
||||
self.assertFalse(self.is_remote_tab)
|
||||
|
||||
self.marionette.timeout.page_load = 0.1
|
||||
with self.assertRaises(errors.TimeoutException):
|
||||
self.marionette.navigate(self.marionette.absolute_url("slow"))
|
||||
|
||||
# Even with the page not finished loading the browser is remote
|
||||
self.assertTrue(self.is_remote_tab)
|
||||
|
||||
def test_navigate_to_same_image_document_twice(self):
|
||||
self.marionette.navigate(self.fixtures.where_is("black.png"))
|
||||
self.assertIn("black.png", self.marionette.title)
|
||||
self.marionette.navigate(self.fixtures.where_is("black.png"))
|
||||
self.assertIn("black.png", self.marionette.title)
|
||||
|
||||
def test_navigate_hash_change(self):
|
||||
doc = inline("<p id=foo>")
|
||||
self.marionette.navigate(doc)
|
||||
self.marionette.execute_script("window.visited = true", sandbox=None)
|
||||
self.marionette.navigate("{}#foo".format(doc))
|
||||
self.assertTrue(self.marionette.execute_script(
|
||||
"return window.visited", sandbox=None))
|
||||
|
||||
@skip_if_mobile("Bug 1334095 - Timeout: No new tab has been opened")
|
||||
def test_about_blank_for_new_docshell(self):
|
||||
self.assertEqual(self.marionette.get_url(), "about:blank")
|
||||
|
||||
self.marionette.navigate('about:blank')
|
||||
|
||||
@run_if_manage_instance("Only runnable if Marionette manages the instance")
|
||||
@skip_if_mobile("Bug 1322993 - Missing temporary folder")
|
||||
def test_focus_after_navigation(self):
|
||||
self.marionette.quit()
|
||||
self.marionette.start_session()
|
||||
|
||||
self.marionette.navigate(inline("<input autofocus>"))
|
||||
focus_el = self.marionette.find_element(By.CSS_SELECTOR, ":focus")
|
||||
self.assertEqual(self.marionette.get_active_element(), focus_el)
|
||||
|
||||
@skip_if_mobile("Needs application independent method to open a new tab")
|
||||
def test_no_hang_when_navigating_after_closing_original_tab(self):
|
||||
# Close the start tab
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.marionette.close()
|
||||
|
||||
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)
|
||||
self.assertFalse(self.is_remote_tab)
|
||||
|
||||
with self.marionette.using_context("chrome"):
|
||||
urlbar = self.marionette.find_element(By.ID, 'urlbar')
|
||||
urlbar.send_keys(self.mod_key + 'a')
|
||||
urlbar.send_keys(self.mod_key + 'x')
|
||||
urlbar.send_keys('about:support' + Keys.ENTER)
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda mn: mn.get_url() == "about:support",
|
||||
message="'about:support' hasn't been loaded")
|
||||
self.assertFalse(self.is_remote_tab)
|
||||
|
||||
@skip_if_mobile("Interacting with chrome elements not available for Fennec")
|
||||
@run_if_e10s("Requires e10s mode enabled")
|
||||
def test_type_to_remote_tab(self):
|
||||
self.assertTrue(self.is_remote_tab)
|
||||
|
||||
with self.marionette.using_context("chrome"):
|
||||
urlbar = self.marionette.find_element(By.ID, 'urlbar')
|
||||
urlbar.send_keys(self.mod_key + 'a')
|
||||
urlbar.send_keys(self.mod_key + 'x')
|
||||
urlbar.send_keys(self.test_page_remote + Keys.ENTER)
|
||||
|
||||
Wait(self.marionette).until(
|
||||
lambda mn: mn.get_url() == self.test_page_remote,
|
||||
message="'{}' hasn't been loaded".format(self.test_page_remote))
|
||||
self.assertTrue(self.is_remote_tab)
|
||||
|
||||
@skip_if_mobile("On Android no shortcuts are available")
|
||||
def test_navigate_shortcut_key(self):
|
||||
|
||||
def open_with_shortcut():
|
||||
self.marionette.navigate(self.test_page_remote)
|
||||
with self.marionette.using_context("chrome"):
|
||||
main_win = self.marionette.find_element(By.ID, "main-window")
|
||||
main_win.send_keys(self.mod_key, Keys.SHIFT, 'a')
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_shortcut)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
Wait(self.marionette).until(lambda mn: mn.get_url() == "about:addons",
|
||||
message="'about:addons' hasn't been loaded")
|
||||
|
||||
|
||||
class TestBackForwardNavigation(BaseNavigationTestCase):
|
||||
|
||||
def test_no_history_items(self):
|
||||
# Both methods should not raise a failure if no navigation is possible
|
||||
self.marionette.go_back()
|
||||
|
@ -325,33 +83,33 @@ class TestBackForwardNavigation(BaseNavigationTestCase):
|
|||
def test_data_urls(self):
|
||||
test_pages = [
|
||||
{"url": inline("<p>foobar</p>")},
|
||||
{"url": self.test_page_remote},
|
||||
{"url": self.test_page},
|
||||
{"url": inline("<p>foobar</p>")},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
def test_same_document_hash_change(self):
|
||||
test_pages = [
|
||||
{"url": "{}#23".format(self.test_page_remote)},
|
||||
{"url": self.test_page_remote},
|
||||
{"url": "{}#42".format(self.test_page_remote)},
|
||||
{"url": "{}#23".format(self.test_page)},
|
||||
{"url": self.test_page},
|
||||
{"url": "{}#42".format(self.test_page)},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
@skip("Causes crashes for JS GC (bug 1344863) and a11y (bug 1344868)")
|
||||
def test_frameset(self):
|
||||
test_pages = [
|
||||
{"url": self.marionette.absolute_url("frameset.html")},
|
||||
{"url": self.test_page_remote},
|
||||
{"url": self.test_page},
|
||||
{"url": self.marionette.absolute_url("frameset.html")},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
def test_frameset_after_navigating_in_frame(self):
|
||||
test_element_locator = (By.ID, "email")
|
||||
|
||||
self.marionette.navigate(self.test_page_remote)
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page_remote)
|
||||
self.marionette.navigate(self.test_page)
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
self.assertEqual(self.history_length, 1)
|
||||
page = self.marionette.absolute_url("frameset.html")
|
||||
self.marionette.navigate(page)
|
||||
|
@ -379,7 +137,7 @@ class TestBackForwardNavigation(BaseNavigationTestCase):
|
|||
# Go back to the non-frameset page
|
||||
self.marionette.switch_to_parent_frame()
|
||||
self.marionette.go_back()
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page_remote)
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
# Go forward to the frameset page
|
||||
self.marionette.go_forward()
|
||||
|
@ -396,48 +154,43 @@ class TestBackForwardNavigation(BaseNavigationTestCase):
|
|||
def test_image_document_to_html(self):
|
||||
test_pages = [
|
||||
{"url": self.marionette.absolute_url('black.png')},
|
||||
{"url": self.test_page_remote},
|
||||
{"url": self.test_page},
|
||||
{"url": self.marionette.absolute_url('white.png')},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
def test_image_document_to_image_document(self):
|
||||
test_pages = [
|
||||
{"url": self.marionette.absolute_url('black.png')},
|
||||
{"url": self.marionette.absolute_url('white.png')},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
@run_if_e10s("Requires e10s mode enabled")
|
||||
def test_remoteness_change(self):
|
||||
test_pages = [
|
||||
{"url": "about:robots", "is_remote": False},
|
||||
{"url": self.test_page_remote, "is_remote": True},
|
||||
{"url": "about:robots", "is_remote": False},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
# TODO: Verify that a remoteness change happened
|
||||
# like: self.assertNotEqual(self.marionette.current_window_handle, self.new_tab)
|
||||
|
||||
@skip_if_mobile("Bug 1333209 - Process killed because of connection loss")
|
||||
def test_non_remote_about_pages(self):
|
||||
# about:robots is always a non-remote page for now
|
||||
test_pages = [
|
||||
{"url": "about:preferences", "is_remote": False},
|
||||
{"url": "about:robots", "is_remote": False},
|
||||
{"url": "about:support", "is_remote": False},
|
||||
{"url": "about:robots"},
|
||||
{"url": self.test_page},
|
||||
{"url": "about:robots"},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
def test_navigate_to_requested_about_page_after_error_page(self):
|
||||
test_pages = [
|
||||
{"url": "about:neterror"},
|
||||
{"url": self.test_page_remote},
|
||||
{"url": self.marionette.absolute_url("test.html")},
|
||||
{"url": "about:blocked"},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
def test_timeout_error(self):
|
||||
urls = [
|
||||
self.marionette.absolute_url('slow'),
|
||||
self.test_page_remote,
|
||||
self.test_page,
|
||||
self.marionette.absolute_url('slow'),
|
||||
]
|
||||
|
||||
|
@ -469,13 +222,154 @@ class TestBackForwardNavigation(BaseNavigationTestCase):
|
|||
|
||||
def test_certificate_error(self):
|
||||
test_pages = [
|
||||
{"url": self.test_page_insecure,
|
||||
{"url": self.fixtures.where_is("/test.html", on="https"),
|
||||
"error": errors.InsecureCertificateException},
|
||||
{"url": self.test_page_remote},
|
||||
{"url": self.test_page_insecure,
|
||||
{"url": self.test_page},
|
||||
{"url": self.fixtures.where_is("/test.html", on="https"),
|
||||
"error": errors.InsecureCertificateException},
|
||||
]
|
||||
self.run_bfcache_test(test_pages)
|
||||
self.run_test(test_pages)
|
||||
|
||||
|
||||
class TestNavigate(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNavigate, self).setUp()
|
||||
|
||||
self.marionette.navigate("about:")
|
||||
self.test_doc = self.marionette.absolute_url("test.html")
|
||||
self.iframe_doc = self.marionette.absolute_url("test_iframe.html")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.timeout.reset()
|
||||
self.close_all_tabs()
|
||||
|
||||
super(TestNavigate, self).tearDown()
|
||||
|
||||
@property
|
||||
def location_href(self):
|
||||
# Windows 8 has recently seen a proliferation of intermittent
|
||||
# test failures to do with failing to compare "about:blank" ==
|
||||
# u"about:blank". For the sake of consistenty, we encode the
|
||||
# returned URL as Unicode here to ensure that the values are
|
||||
# absolutely of the same type.
|
||||
#
|
||||
# (https://bugzilla.mozilla.org/show_bug.cgi?id=1322862)
|
||||
return self.marionette.execute_script("return window.location.href").encode("utf-8")
|
||||
|
||||
def test_set_location_through_execute_script(self):
|
||||
self.marionette.execute_script(
|
||||
"window.location.href = '%s'" % self.test_doc)
|
||||
Wait(self.marionette).until(
|
||||
lambda _: self.test_doc == self.location_href)
|
||||
self.assertEqual("Marionette Test", self.marionette.title)
|
||||
|
||||
def test_navigate_chrome_error(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.assertRaises(errors.UnsupportedOperationException,
|
||||
self.marionette.navigate, "about:blank")
|
||||
self.assertRaises(errors.UnsupportedOperationException, self.marionette.go_back)
|
||||
self.assertRaises(errors.UnsupportedOperationException, self.marionette.go_forward)
|
||||
self.assertRaises(errors.UnsupportedOperationException, self.marionette.refresh)
|
||||
|
||||
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())
|
||||
|
||||
def test_get_current_url(self):
|
||||
self.marionette.navigate(self.test_doc)
|
||||
self.assertEqual(self.test_doc, 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_doc)
|
||||
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):
|
||||
frame_html = self.marionette.absolute_url("frameset.html")
|
||||
|
||||
self.marionette.navigate(frame_html)
|
||||
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(frame_html)
|
||||
self.marionette.find_element(By.NAME, "third")
|
||||
|
||||
@skip_if_mobile("Bug 1323755 - Socket timeout")
|
||||
def test_invalid_protocol(self):
|
||||
with self.assertRaises(errors.MarionetteException):
|
||||
self.marionette.navigate("thisprotocoldoesnotexist://")
|
||||
|
||||
def test_find_element_state_complete(self):
|
||||
self.marionette.navigate(self.test_doc)
|
||||
state = self.marionette.execute_script(
|
||||
"return window.document.readyState")
|
||||
self.assertEqual("complete", state)
|
||||
self.assertTrue(self.marionette.find_element(By.ID, "mozLink"))
|
||||
|
||||
def test_error_when_exceeding_page_load_timeout(self):
|
||||
self.marionette.timeout.page_load = 0.1
|
||||
with self.assertRaises(errors.TimeoutException):
|
||||
self.marionette.navigate(self.marionette.absolute_url("slow"))
|
||||
|
||||
def test_navigate_to_same_image_document_twice(self):
|
||||
self.marionette.navigate(self.fixtures.where_is("black.png"))
|
||||
self.assertIn("black.png", self.marionette.title)
|
||||
self.marionette.navigate(self.fixtures.where_is("black.png"))
|
||||
self.assertIn("black.png", self.marionette.title)
|
||||
|
||||
def test_navigate_hash_change(self):
|
||||
doc = inline("<p id=foo>")
|
||||
self.marionette.navigate(doc)
|
||||
self.marionette.execute_script("window.visited = true", sandbox=None)
|
||||
self.marionette.navigate("{}#foo".format(doc))
|
||||
self.assertTrue(self.marionette.execute_script(
|
||||
"return window.visited", sandbox=None))
|
||||
|
||||
@skip_if_mobile("Bug 1334095 - Timeout: No new tab has been opened")
|
||||
def test_about_blank_for_new_docshell(self):
|
||||
""" Bug 1312674 - Hang when loading about:blank for a new docshell."""
|
||||
def open_with_link():
|
||||
link = self.marionette.find_element(By.ID, "new-blank-tab")
|
||||
link.click()
|
||||
|
||||
# Open a new tab to get a new docshell created
|
||||
self.marionette.navigate(self.marionette.absolute_url("windowHandles.html"))
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assertEqual(self.marionette.get_url(), "about:blank")
|
||||
|
||||
self.marionette.navigate('about:blank')
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
@run_if_manage_instance("Only runnable if Marionette manages the instance")
|
||||
@skip_if_mobile("Bug 1322993 - Missing temporary folder")
|
||||
def test_focus_after_navigation(self):
|
||||
self.marionette.quit()
|
||||
self.marionette.start_session()
|
||||
|
||||
self.marionette.navigate(inline("<input autofocus>"))
|
||||
active_el = self.marionette.execute_script("return document.activeElement")
|
||||
focus_el = self.marionette.find_element(By.CSS_SELECTOR, ":focus")
|
||||
self.assertEqual(active_el, focus_el)
|
||||
|
||||
|
||||
class TestTLSNavigation(MarionetteTestCase):
|
||||
|
@ -483,10 +377,7 @@ class TestTLSNavigation(MarionetteTestCase):
|
|||
secure_tls = {"acceptInsecureCerts": False}
|
||||
|
||||
def setUp(self):
|
||||
super(TestTLSNavigation, self).setUp()
|
||||
|
||||
self.test_page_insecure = self.fixtures.where_is("test.html", on="https")
|
||||
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.delete_session()
|
||||
self.capabilities = self.marionette.start_session(
|
||||
{"requiredCapabilities": self.insecure_tls})
|
||||
|
@ -496,8 +387,7 @@ class TestTLSNavigation(MarionetteTestCase):
|
|||
self.marionette.delete_session()
|
||||
except:
|
||||
pass
|
||||
|
||||
super(TestTLSNavigation, self).tearDown()
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def safe_session(self):
|
||||
|
@ -520,18 +410,19 @@ class TestTLSNavigation(MarionetteTestCase):
|
|||
self.marionette.delete_session()
|
||||
|
||||
def test_navigate_by_command(self):
|
||||
self.marionette.navigate(self.test_page_insecure)
|
||||
self.marionette.navigate(
|
||||
self.fixtures.where_is("/test.html", on="https"))
|
||||
self.assertIn("https", self.marionette.get_url())
|
||||
|
||||
def test_navigate_by_click(self):
|
||||
link_url = self.test_page_insecure
|
||||
link_url = self.fixtures.where_is("/test.html", on="https")
|
||||
self.marionette.navigate(
|
||||
inline("<a href=%s>https is the future</a>" % link_url))
|
||||
self.marionette.find_element(By.TAG_NAME, "a").click()
|
||||
self.assertIn("https", self.marionette.get_url())
|
||||
|
||||
def test_deactivation(self):
|
||||
invalid_cert_url = self.test_page_insecure
|
||||
invalid_cert_url = self.fixtures.where_is("/test.html", on="https")
|
||||
|
||||
print "with safe session"
|
||||
with self.safe_session() as session:
|
||||
|
|
|
@ -32,6 +32,8 @@ skip-if = true # "Bug 896046"
|
|||
|
||||
[test_log.py]
|
||||
|
||||
[test_about_pages.py]
|
||||
|
||||
[test_execute_async_script.py]
|
||||
[test_execute_script.py]
|
||||
[test_simpletest_fail.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче