зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1504756 - [marionette] Added opening a new browsing context to Marionette client. r=ato
The patch updates the Marionette client and all Marionette unit tests to make use of the new `Create Window` command as much as possible. Depends on D13663 Differential Revision: https://phabricator.services.mozilla.com/D13664 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c631c98202
Коммит
c820e2d61d
|
@ -1428,6 +1428,20 @@ class Marionette(object):
|
|||
return self._send_message("WebDriver:GetPageSource",
|
||||
key="value")
|
||||
|
||||
def open(self, type=None, focus=False):
|
||||
"""Open a new window, or tab based on the specified context type.
|
||||
|
||||
If no context type is given the application will choose the best
|
||||
option based on tab and window support.
|
||||
|
||||
:param type: Type of window to be opened. Can be one of "tab" or "window"
|
||||
:param focus: If true, the opened window will be focused
|
||||
|
||||
:returns: Dict with new window handle, and type of opened window
|
||||
"""
|
||||
body = {"type": type, "focus": focus}
|
||||
return self._send_message("WebDriver:NewWindow", body)
|
||||
|
||||
def close(self):
|
||||
"""Close the current window, ending the session if it's the last
|
||||
window currently open.
|
||||
|
|
|
@ -6,14 +6,12 @@ from __future__ import absolute_import
|
|||
|
||||
import sys
|
||||
|
||||
from marionette_driver import By, Wait
|
||||
from marionette_driver import Wait
|
||||
from six import reraise
|
||||
|
||||
|
||||
class WindowManagerMixin(object):
|
||||
|
||||
_menu_item_new_tab = (By.ID, "menu_newNavigatorTab")
|
||||
|
||||
def setUp(self):
|
||||
super(WindowManagerMixin, self).setUp()
|
||||
|
||||
|
@ -60,15 +58,18 @@ class WindowManagerMixin(object):
|
|||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
def open_tab(self, trigger="menu"):
|
||||
def open_tab(self, callback=None, focus=False):
|
||||
current_tabs = self.marionette.window_handles
|
||||
|
||||
try:
|
||||
if callable(trigger):
|
||||
trigger()
|
||||
elif trigger == 'menu':
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.find_element(*self._menu_item_new_tab).click()
|
||||
if callable(callback):
|
||||
callback()
|
||||
else:
|
||||
result = self.marionette.open(type="tab", focus=focus)
|
||||
if result["type"] != "tab":
|
||||
raise Exception(
|
||||
"Newly opened browsing context is of type {} and not tab.".format(
|
||||
result["type"]))
|
||||
except Exception:
|
||||
exc, val, tb = sys.exc_info()
|
||||
reraise(exc, 'Failed to trigger opening a new tab: {}'.format(val), tb)
|
||||
|
@ -82,8 +83,9 @@ class WindowManagerMixin(object):
|
|||
|
||||
return new_tab
|
||||
|
||||
def open_window(self, trigger=None):
|
||||
def open_window(self, callback=None, focus=False):
|
||||
current_windows = self.marionette.chrome_window_handles
|
||||
current_tabs = self.marionette.window_handles
|
||||
|
||||
def loaded(handle):
|
||||
with self.marionette.using_context("chrome"):
|
||||
|
@ -95,11 +97,14 @@ class WindowManagerMixin(object):
|
|||
""", script_args=[handle])
|
||||
|
||||
try:
|
||||
if callable(trigger):
|
||||
trigger()
|
||||
if callable(callback):
|
||||
callback()
|
||||
else:
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.execute_script("OpenBrowserWindow();")
|
||||
result = self.marionette.open(type="window", focus=focus)
|
||||
if result["type"] != "window":
|
||||
raise Exception(
|
||||
"Newly opened browsing context is of type {} and not window.".format(
|
||||
result["type"]))
|
||||
except Exception:
|
||||
exc, val, tb = sys.exc_info()
|
||||
reraise(exc, 'Failed to trigger opening a new window: {}'.format(val), tb)
|
||||
|
@ -116,9 +121,16 @@ class WindowManagerMixin(object):
|
|||
lambda _: loaded(new_window),
|
||||
message="Window with handle '{}'' did not finish loading".format(new_window))
|
||||
|
||||
return new_window
|
||||
# Bug 1507771 - Return the correct handle based on the currently selected context
|
||||
# as long as "WebDriver:NewWindow" is not handled separtely in chrome context
|
||||
context = self.marionette._send_message("Marionette:GetContext", key="value")
|
||||
if context == "chrome":
|
||||
return new_window
|
||||
elif context == "content":
|
||||
[new_tab] = list(set(self.marionette.window_handles) - set(current_tabs))
|
||||
return new_tab
|
||||
|
||||
def open_chrome_window(self, url):
|
||||
def open_chrome_window(self, url, focus=False):
|
||||
"""Open a new chrome window with the specified chrome URL.
|
||||
|
||||
Can be replaced with "WebDriver:NewWindow" once the command
|
||||
|
@ -166,4 +178,5 @@ class WindowManagerMixin(object):
|
|||
})();
|
||||
""", script_args=(url,))
|
||||
|
||||
return self.open_window(trigger=open_with_js)
|
||||
with self.marionette.using_context("chrome"):
|
||||
return self.open_window(callback=open_with_js, focus=focus)
|
||||
|
|
|
@ -1,22 +1,5 @@
|
|||
#Copyright 2007-2009 WebDriver committers
|
||||
#Copyright 2007-2009 Google Inc.
|
||||
#
|
||||
#Licensed under the Apache License, Version 2.0 (the "License");
|
||||
#you may not use this file except in compliance with the License.
|
||||
#You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#Unless required by applicable law or agreed to in writing, software
|
||||
#distributed under the License is distributed on an "AS IS" BASIS,
|
||||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#See the License for the specific language governing permissions and
|
||||
#limitations under the License.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from marionette_driver import By
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
|
||||
|
||||
|
@ -25,18 +8,13 @@ class ChromeTests(WindowManagerMixin, MarionetteTestCase):
|
|||
def setUp(self):
|
||||
super(ChromeTests, self).setUp()
|
||||
|
||||
self.marionette.set_context('chrome')
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(ChromeTests, self).tearDown()
|
||||
|
||||
def test_hang_until_timeout(self):
|
||||
def open_with_menu():
|
||||
menu = self.marionette.find_element(By.ID, 'aboutName')
|
||||
menu.click()
|
||||
|
||||
new_window = self.open_window(trigger=open_with_menu)
|
||||
with self.marionette.using_context("chrome"):
|
||||
new_window = self.open_window()
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
try:
|
||||
|
@ -45,7 +23,8 @@ class ChromeTests(WindowManagerMixin, MarionetteTestCase):
|
|||
# while running this test. Otherwise it would mask eg. IOError as
|
||||
# thrown for a socket timeout.
|
||||
raise NotImplementedError('Exception should not cause a hang when '
|
||||
'closing the chrome window')
|
||||
'closing the chrome window in content '
|
||||
'context')
|
||||
finally:
|
||||
self.marionette.close_chrome_window()
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
|
|
@ -449,20 +449,16 @@ class TestClickCloseContext(WindowManagerMixin, MarionetteTestCase):
|
|||
super(TestClickCloseContext, self).tearDown()
|
||||
|
||||
def test_click_close_tab(self):
|
||||
self.marionette.navigate(self.marionette.absolute_url("windowHandles.html"))
|
||||
tab = self.open_tab(
|
||||
lambda: self.marionette.find_element(By.ID, "new-tab").click())
|
||||
self.marionette.switch_to_window(tab)
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.marionette.navigate(self.test_page)
|
||||
self.marionette.find_element(By.ID, "close-window").click()
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_click_close_window(self):
|
||||
self.marionette.navigate(self.marionette.absolute_url("windowHandles.html"))
|
||||
win = self.open_window(
|
||||
lambda: self.marionette.find_element(By.ID, "new-window").click())
|
||||
self.marionette.switch_to_window(win)
|
||||
new_tab = self.open_window()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.marionette.navigate(self.test_page)
|
||||
self.marionette.find_element(By.ID, "close-window").click()
|
||||
|
|
|
@ -77,22 +77,3 @@ class TestKeyActions(WindowManagerMixin, MarionetteTestCase):
|
|||
.key_down("x")
|
||||
.perform())
|
||||
self.assertEqual(self.key_reporter_value, "")
|
||||
|
||||
@skip_if_mobile("Interacting with chrome windows not available for Fennec")
|
||||
def test_open_in_new_window_shortcut(self):
|
||||
|
||||
def open_window_with_action():
|
||||
el = self.marionette.find_element(By.TAG_NAME, "a")
|
||||
(self.key_action.key_down(Keys.SHIFT)
|
||||
.press(el)
|
||||
.release()
|
||||
.key_up(Keys.SHIFT)
|
||||
.perform())
|
||||
|
||||
self.marionette.navigate(inline("<a href='#'>Click</a>"))
|
||||
new_window = self.open_window(trigger=open_window_with_action)
|
||||
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
|
|
@ -54,13 +54,8 @@ class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
|
|||
else:
|
||||
self.mod_key = Keys.CONTROL
|
||||
|
||||
def open_with_link():
|
||||
link = self.marionette.find_element(By.ID, "new-blank-tab")
|
||||
link.click()
|
||||
|
||||
# Always use a blank new tab for an empty history
|
||||
self.marionette.navigate(self.marionette.absolute_url("windowHandles.html"))
|
||||
self.new_tab = self.open_tab(open_with_link)
|
||||
self.new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(self.new_tab)
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda _: self.history_length == 1,
|
||||
|
@ -297,7 +292,6 @@ class TestNavigate(BaseNavigationTestCase):
|
|||
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)
|
||||
|
@ -338,22 +332,6 @@ class TestNavigate(BaseNavigationTestCase):
|
|||
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, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda mn: mn.get_url() == "about:addons",
|
||||
message="'about:addons' hasn't been loaded")
|
||||
|
||||
|
||||
class TestBackForwardNavigation(BaseNavigationTestCase):
|
||||
|
||||
|
|
|
@ -253,7 +253,8 @@ class TestScreenCaptureChrome(WindowManagerMixin, ScreenCaptureTestCase):
|
|||
|
||||
chrome_document_element = self.document_element
|
||||
with self.marionette.using_context('content'):
|
||||
self.assertRaisesRegexp(NoSuchElementException, "Web element reference not seen before",
|
||||
self.assertRaisesRegexp(NoSuchElementException,
|
||||
"Web element reference not seen before",
|
||||
self.marionette.screenshot,
|
||||
highlights=[chrome_document_element])
|
||||
|
||||
|
@ -274,10 +275,9 @@ class TestScreenCaptureContent(WindowManagerMixin, ScreenCaptureTestCase):
|
|||
return [document.body.scrollWidth, document.body.scrollHeight]
|
||||
"""))
|
||||
|
||||
@skip_if_mobile("Needs application independent method to open a new tab")
|
||||
def test_capture_tab_already_closed(self):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
|
||||
self.assertRaises(NoSuchWindowException, self.marionette.screenshot)
|
||||
|
|
|
@ -6,9 +6,8 @@ from __future__ import absolute_import
|
|||
|
||||
import os
|
||||
import sys
|
||||
from unittest import skipIf
|
||||
|
||||
from marionette_driver import By
|
||||
from unittest import skipIf
|
||||
|
||||
# add this directory to the path
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
@ -28,119 +27,70 @@ class TestSwitchWindowChrome(TestSwitchToWindowContent):
|
|||
|
||||
super(TestSwitchWindowChrome, self).tearDown()
|
||||
|
||||
def open_window_in_background(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.execute_async_script("""
|
||||
let callback = arguments[0];
|
||||
(async function() {
|
||||
function promiseEvent(target, type, args) {
|
||||
return new Promise(r => {
|
||||
let params = Object.assign({once: true}, args);
|
||||
target.addEventListener(type, r, params);
|
||||
});
|
||||
}
|
||||
function promiseWindowFocus(w) {
|
||||
return Promise.all([
|
||||
promiseEvent(w, "focus", {capture: true}),
|
||||
promiseEvent(w, "activate"),
|
||||
]);
|
||||
}
|
||||
// Open a window, wait for it to receive focus
|
||||
let win = OpenBrowserWindow();
|
||||
await promiseWindowFocus(win);
|
||||
|
||||
// Now refocus our original window and wait for that to happen.
|
||||
let windowFocusPromise = promiseWindowFocus(window);
|
||||
window.focus();
|
||||
return windowFocusPromise;
|
||||
})().then(() => {
|
||||
// can't just pass `callback`, as we can't JSON-ify the events it'd get passed.
|
||||
callback()
|
||||
});
|
||||
""")
|
||||
|
||||
def open_window_in_foreground(self):
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(self.test_page)
|
||||
link = self.marionette.find_element(By.ID, "new-window")
|
||||
link.click()
|
||||
|
||||
@skipIf(sys.platform.startswith("linux"),
|
||||
"Bug 1511970 - New window isn't moved to the background on Linux")
|
||||
def test_switch_tabs_for_new_background_window_without_focus_change(self):
|
||||
# Open an addition tab in the original window so we can better check
|
||||
# Open an additional tab in the original window so we can better check
|
||||
# the selected index in thew new window to be opened.
|
||||
second_tab = self.open_tab(trigger=self.open_tab_in_foreground)
|
||||
second_tab = self.open_tab(focus=True)
|
||||
self.marionette.switch_to_window(second_tab, focus=True)
|
||||
second_tab_index = self.get_selected_tab_index()
|
||||
self.assertNotEqual(second_tab_index, self.selected_tab_index)
|
||||
|
||||
# Opens a new background window, but we are interested in the tab
|
||||
tab_in_new_window = self.open_tab(trigger=self.open_window_in_background)
|
||||
# Open a new background window, but we are interested in the tab
|
||||
with self.marionette.using_context("content"):
|
||||
tab_in_new_window = self.open_window()
|
||||
self.assertEqual(self.marionette.current_window_handle, second_tab)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.assertEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.empty_page)
|
||||
|
||||
# Switch to the tab in the new window but don't focus it
|
||||
self.marionette.switch_to_window(tab_in_new_window, focus=False)
|
||||
self.assertEqual(self.marionette.current_window_handle, tab_in_new_window)
|
||||
self.assertNotEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.assertEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), "about:blank")
|
||||
|
||||
def test_switch_tabs_for_new_foreground_window_with_focus_change(self):
|
||||
# Open an addition tab in the original window so we can better check
|
||||
# the selected index in thew new window to be opened.
|
||||
second_tab = self.open_tab(trigger=self.open_tab_in_foreground)
|
||||
second_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(second_tab, focus=True)
|
||||
second_tab_index = self.get_selected_tab_index()
|
||||
self.assertNotEqual(second_tab_index, self.selected_tab_index)
|
||||
|
||||
# Opens a new window, but we are interested in the tab
|
||||
tab_in_new_window = self.open_tab(trigger=self.open_window_in_foreground)
|
||||
with self.marionette.using_context("content"):
|
||||
tab_in_new_window = self.open_window(focus=True)
|
||||
self.assertEqual(self.marionette.current_window_handle, second_tab)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
self.marionette.switch_to_window(tab_in_new_window)
|
||||
self.assertEqual(self.marionette.current_window_handle, tab_in_new_window)
|
||||
self.assertNotEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.empty_page)
|
||||
|
||||
self.marionette.switch_to_window(second_tab, focus=True)
|
||||
self.assertEqual(self.marionette.current_window_handle, second_tab)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
# Bug 1335085 - The focus doesn't change even as requested so.
|
||||
# self.assertEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_switch_tabs_for_new_foreground_window_without_focus_change(self):
|
||||
# Open an addition tab in the original window so we can better check
|
||||
# the selected index in thew new window to be opened.
|
||||
second_tab = self.open_tab(trigger=self.open_tab_in_foreground)
|
||||
second_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(second_tab, focus=True)
|
||||
second_tab_index = self.get_selected_tab_index()
|
||||
self.assertNotEqual(second_tab_index, self.selected_tab_index)
|
||||
|
||||
# Opens a new window, but we are interested in the tab which automatically
|
||||
# gets the focus.
|
||||
self.open_tab(trigger=self.open_window_in_foreground)
|
||||
self.open_window(focus=True)
|
||||
self.assertEqual(self.marionette.current_window_handle, second_tab)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
# Switch to the second tab in the first window, but don't focus it.
|
||||
self.marionette.switch_to_window(second_tab, focus=False)
|
||||
self.assertEqual(self.marionette.current_window_handle, second_tab)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), second_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from marionette_driver import Actions, By, Wait
|
||||
from marionette_driver import By
|
||||
from marionette_driver.keys import Keys
|
||||
|
||||
from marionette_harness import MarionetteTestCase, skip_if_mobile, WindowManagerMixin
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
|
||||
|
||||
class TestSwitchToWindowContent(WindowManagerMixin, MarionetteTestCase):
|
||||
|
@ -20,14 +20,8 @@ class TestSwitchToWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
else:
|
||||
self.mod_key = Keys.CONTROL
|
||||
|
||||
self.empty_page = self.marionette.absolute_url("empty.html")
|
||||
self.test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
|
||||
self.selected_tab_index = self.get_selected_tab_index()
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(self.test_page)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_tabs()
|
||||
|
||||
|
@ -69,78 +63,51 @@ class TestSwitchToWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
}
|
||||
""")
|
||||
|
||||
def open_tab_in_background(self):
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
|
||||
action = Actions(self.marionette)
|
||||
action.key_down(self.mod_key).click(link).perform()
|
||||
|
||||
def open_tab_in_foreground(self):
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
def test_switch_tabs_with_focus_change(self):
|
||||
new_tab = self.open_tab(self.open_tab_in_foreground)
|
||||
new_tab = self.open_tab(focus=True)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
# Switch to new tab first because it is already selected
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda _: self.marionette.get_url() == self.empty_page,
|
||||
message="{} has been loaded in the newly opened tab.".format(self.empty_page))
|
||||
|
||||
# Switch to original tab by explicitely setting the focus
|
||||
self.marionette.switch_to_window(self.start_tab, focus=True)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_switch_tabs_without_focus_change(self):
|
||||
new_tab = self.open_tab(self.open_tab_in_foreground)
|
||||
new_tab = self.open_tab(focus=True)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
# Switch to new tab first because it is already selected
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
|
||||
# Switch to original tab by explicitely not setting the focus
|
||||
self.marionette.switch_to_window(self.start_tab, focus=False)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertNotEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertEqual(self.get_selected_tab_index(), self.selected_tab_index)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_switch_from_content_to_chrome_window_should_not_change_selected_tab(self):
|
||||
new_tab = self.open_tab(self.open_tab_in_foreground)
|
||||
new_tab = self.open_tab(focus=True)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
|
@ -150,24 +117,31 @@ class TestSwitchToWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
self.assertEqual(self.get_selected_tab_index(), new_tab_index)
|
||||
|
||||
@skip_if_mobile("New windows not supported in Fennec")
|
||||
def test_switch_to_new_private_browsing_window_has_to_register_browsers(self):
|
||||
def test_switch_to_new_private_browsing_tab(self):
|
||||
# Test that tabs (browsers) are correctly registered for a newly opened
|
||||
# private browsing window. This has to also happen without explicitely
|
||||
# private browsing window/tab. This has to also happen without explicitely
|
||||
# switching to the tab itself before using any commands in content scope.
|
||||
#
|
||||
# Note: Not sure why this only affects private browsing windows only.
|
||||
new_tab = self.open_tab(focus=True)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
def open_private_browsing_window():
|
||||
def open_private_browsing_window_firefox():
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate("about:privatebrowsing")
|
||||
button = self.marionette.find_element(By.ID, "startPrivateBrowsing")
|
||||
button.click()
|
||||
self.marionette.find_element(By.ID, "startPrivateBrowsing").click()
|
||||
|
||||
new_window = self.open_window(open_private_browsing_window)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
self.assertNotEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
def open_private_browsing_tab_fennec():
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.find_element(By.ID, "newPrivateTabLink").click()
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.execute_script(" return true; ")
|
||||
self.marionette.navigate("about:privatebrowsing")
|
||||
if self.marionette.session_capabilities["browserName"] == "fennec":
|
||||
new_pb_tab = self.open_tab(open_private_browsing_tab_fennec)
|
||||
else:
|
||||
new_pb_tab = self.open_tab(open_private_browsing_window_firefox)
|
||||
|
||||
self.marionette.switch_to_window(new_pb_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, new_pb_tab)
|
||||
|
||||
self.marionette.execute_script(" return true; ")
|
||||
|
|
|
@ -21,14 +21,14 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
super(TestCloseWindow, self).tearDown()
|
||||
|
||||
def test_close_chrome_window_for_browser_window(self):
|
||||
win = self.open_window()
|
||||
self.marionette.switch_to_window(win)
|
||||
new_window = self.open_window()
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
self.assertNotIn(win, self.marionette.window_handles)
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
chrome_window_handles = self.marionette.close_chrome_window()
|
||||
self.assertNotIn(win, chrome_window_handles)
|
||||
self.assertNotIn(new_window, chrome_window_handles)
|
||||
self.assertListEqual(self.start_windows, chrome_window_handles)
|
||||
self.assertNotIn(win, self.marionette.window_handles)
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
|
||||
def test_close_chrome_window_for_non_browser_window(self):
|
||||
win = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
|
@ -50,20 +50,20 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertIsNotNone(self.marionette.session)
|
||||
|
||||
def test_close_window_for_browser_tab(self):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
window_handles = self.marionette.close()
|
||||
self.assertNotIn(tab, window_handles)
|
||||
self.assertNotIn(new_tab, window_handles)
|
||||
self.assertListEqual(self.start_tabs, window_handles)
|
||||
|
||||
def test_close_window_for_browser_window_with_single_tab(self):
|
||||
win = self.open_window()
|
||||
self.marionette.switch_to_window(win)
|
||||
new_window = self.open_window()
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
self.assertEqual(len(self.start_tabs) + 1, len(self.marionette.window_handles))
|
||||
window_handles = self.marionette.close()
|
||||
self.assertNotIn(win, window_handles)
|
||||
self.assertNotIn(new_window, window_handles)
|
||||
self.assertListEqual(self.start_tabs, window_handles)
|
||||
self.assertListEqual(self.start_windows, self.marionette.chrome_window_handles)
|
||||
|
||||
|
|
|
@ -24,26 +24,27 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
|
||||
@skip_if_mobile("Interacting with chrome windows not available for Fennec")
|
||||
def test_close_chrome_window_for_browser_window(self):
|
||||
win = self.open_window()
|
||||
self.marionette.switch_to_window(win)
|
||||
with self.marionette.using_context("chrome"):
|
||||
new_window = self.open_window()
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
self.assertNotIn(win, self.marionette.window_handles)
|
||||
self.assertIn(new_window, self.marionette.chrome_window_handles)
|
||||
chrome_window_handles = self.marionette.close_chrome_window()
|
||||
self.assertNotIn(win, chrome_window_handles)
|
||||
self.assertNotIn(new_window, chrome_window_handles)
|
||||
self.assertListEqual(self.start_windows, chrome_window_handles)
|
||||
self.assertNotIn(win, self.marionette.window_handles)
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
|
||||
@skip_if_mobile("Interacting with chrome windows not available for Fennec")
|
||||
def test_close_chrome_window_for_non_browser_window(self):
|
||||
win = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
self.marionette.switch_to_window(win)
|
||||
new_window = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
self.assertIn(win, self.marionette.chrome_window_handles)
|
||||
self.assertNotIn(win, self.marionette.window_handles)
|
||||
self.assertIn(new_window, self.marionette.chrome_window_handles)
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
chrome_window_handles = self.marionette.close_chrome_window()
|
||||
self.assertNotIn(win, chrome_window_handles)
|
||||
self.assertNotIn(new_window, chrome_window_handles)
|
||||
self.assertListEqual(self.start_windows, chrome_window_handles)
|
||||
self.assertNotIn(win, self.marionette.window_handles)
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
|
||||
@skip_if_mobile("Interacting with chrome windows not available for Fennec")
|
||||
def test_close_chrome_window_for_last_open_window(self):
|
||||
|
@ -54,19 +55,17 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertListEqual([self.start_window], self.marionette.chrome_window_handles)
|
||||
self.assertIsNotNone(self.marionette.session)
|
||||
|
||||
@skip_if_mobile("Needs application independent method to open a new tab")
|
||||
def test_close_window_for_browser_tab(self):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
window_handles = self.marionette.close()
|
||||
self.assertNotIn(tab, window_handles)
|
||||
self.assertNotIn(new_tab, window_handles)
|
||||
self.assertListEqual(self.start_tabs, window_handles)
|
||||
|
||||
@skip_if_mobile("Needs application independent method to open a new tab")
|
||||
def test_close_window_with_dismissed_beforeunload_prompt(self):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.marionette.navigate(inline("""
|
||||
<input type="text">
|
||||
|
@ -82,12 +81,12 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
|
||||
@skip_if_mobile("Interacting with chrome windows not available for Fennec")
|
||||
def test_close_window_for_browser_window_with_single_tab(self):
|
||||
win = self.open_window()
|
||||
self.marionette.switch_to_window(win)
|
||||
new_tab = self.open_window()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
self.assertEqual(len(self.start_tabs) + 1, len(self.marionette.window_handles))
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
window_handles = self.marionette.close()
|
||||
self.assertNotIn(win, window_handles)
|
||||
self.assertNotIn(new_tab, window_handles)
|
||||
self.assertListEqual(self.start_tabs, window_handles)
|
||||
self.assertListEqual(self.start_windows, self.marionette.chrome_window_handles)
|
||||
|
||||
|
@ -104,8 +103,8 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
self.close_all_tabs()
|
||||
|
||||
test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.navigate(test_page)
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from __future__ import absolute_import
|
|||
|
||||
import types
|
||||
|
||||
from marionette_driver import By, errors, Wait
|
||||
from marionette_driver import errors
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
|
||||
|
@ -16,9 +16,7 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
def setUp(self):
|
||||
super(TestWindowHandles, self).setUp()
|
||||
|
||||
self.empty_page = self.marionette.absolute_url("empty.html")
|
||||
self.test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
self.marionette.navigate(self.test_page)
|
||||
self.xul_dialog = "chrome://marionette/content/test_dialog.xul"
|
||||
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
|
@ -42,17 +40,16 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertIsInstance(handle, types.StringTypes)
|
||||
|
||||
def test_chrome_window_handles_with_scopes(self):
|
||||
# Open a browser and a non-browser (about window) chrome window
|
||||
self.open_window(
|
||||
trigger=lambda: self.marionette.execute_script("OpenBrowserWindow();"))
|
||||
new_browser = self.open_window()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows) + 1)
|
||||
self.assertIn(new_browser, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
self.open_window(
|
||||
trigger=lambda: self.marionette.find_element(By.ID, "aboutName").click())
|
||||
new_dialog = self.open_chrome_window(self.xul_dialog)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows) + 2)
|
||||
self.assertIn(new_dialog, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
chrome_window_handles_in_chrome_scope = self.marionette.chrome_window_handles
|
||||
|
@ -64,117 +61,112 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertEqual(self.marionette.window_handles,
|
||||
window_handles_in_chrome_scope)
|
||||
|
||||
def test_chrome_window_handles_after_opening_new_dialog(self):
|
||||
xul_dialog = "chrome://marionette/content/test_dialog.xul"
|
||||
new_win = self.open_chrome_window(xul_dialog)
|
||||
def test_chrome_window_handles_after_opening_new_chrome_window(self):
|
||||
new_window = self.open_chrome_window(self.xul_dialog)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows) + 1)
|
||||
self.assertIn(new_window, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
# Check that the new tab has the correct page loaded
|
||||
self.marionette.switch_to_window(new_win)
|
||||
# Check that the new chrome window has the correct URL loaded
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_win)
|
||||
self.assertEqual(self.marionette.get_url(), xul_dialog)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
self.assertEqual(self.marionette.get_url(), self.xul_dialog)
|
||||
|
||||
# Close the opened dialog and carry on in our original tab.
|
||||
# Close the chrome window, and carry on in our original window.
|
||||
self.marionette.close_chrome_window()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows))
|
||||
self.assertNotIn(new_window, self.marionette.chrome_window_handles)
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_chrome_window_handles_after_opening_new_window(self):
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-window")
|
||||
link.click()
|
||||
|
||||
# We open a new window but are actually interested in the new tab
|
||||
new_win = self.open_window(trigger=open_with_link)
|
||||
new_window = self.open_window()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows) + 1)
|
||||
self.assertIn(new_window, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
# Check that the new tab has the correct page loaded
|
||||
self.marionette.switch_to_window(new_win)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_win)
|
||||
with self.marionette.using_context("content"):
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda mn: mn.get_url() == self.empty_page,
|
||||
message="{} did not load after opening a new tab".format(self.empty_page))
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
|
||||
# Ensure navigate works in our current window
|
||||
other_page = self.marionette.absolute_url("test.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(other_page)
|
||||
self.assertEqual(self.marionette.get_url(), other_page)
|
||||
|
||||
# Close the opened window and carry on in our original tab.
|
||||
# Close the opened window and carry on in our original window.
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows))
|
||||
self.assertNotIn(new_window, self.marionette.chrome_window_handles)
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_window_handles_after_opening_new_tab(self):
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
with self.marionette.using_context("content"):
|
||||
new_tab = self.open_tab()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertIn(new_tab, self.marionette.window_handles)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
with self.marionette.using_context("content"):
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda mn: mn.get_url() == self.empty_page,
|
||||
message="{} did not load after opening a new tab".format(self.empty_page))
|
||||
|
||||
# Ensure navigate works in our current tab
|
||||
other_page = self.marionette.absolute_url("test.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(other_page)
|
||||
self.assertEqual(self.marionette.get_url(), other_page)
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
self.assertNotIn(new_tab, self.marionette.window_handles)
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
def test_window_handles_after_opening_new_dialog(self):
|
||||
xul_dialog = "chrome://marionette/content/test_dialog.xul"
|
||||
new_win = self.open_chrome_window(xul_dialog)
|
||||
def test_window_handles_after_opening_new_foreground_tab(self):
|
||||
with self.marionette.using_context("content"):
|
||||
new_tab = self.open_tab(focus=True)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertIn(new_tab, self.marionette.window_handles)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
# We still have the default tab set as our window handle. This
|
||||
# get_url command should be sent immediately, and not be forever-queued.
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.get_url()
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
self.assertNotIn(new_tab, self.marionette.window_handles)
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
self.marionette.switch_to_window(new_win)
|
||||
def test_window_handles_after_opening_new_chrome_window(self):
|
||||
new_window = self.open_chrome_window(self.xul_dialog)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.get_url(), xul_dialog)
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.get_url(), self.xul_dialog)
|
||||
|
||||
# Check that the opened dialog is not accessible via window handles
|
||||
with self.assertRaises(errors.NoSuchWindowException):
|
||||
|
@ -190,111 +182,23 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_window_handles_after_opening_new_window(self):
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-window")
|
||||
link.click()
|
||||
|
||||
# We open a new window but are actually interested in the new tab
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
# Check that the new tab has the correct page loaded
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
with self.marionette.using_context("content"):
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda mn: mn.get_url() == self.empty_page,
|
||||
message="{} did not load after opening a new tab".format(self.empty_page))
|
||||
|
||||
# Ensure navigate works in our current window
|
||||
other_page = self.marionette.absolute_url("test.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(other_page)
|
||||
self.assertEqual(self.marionette.get_url(), other_page)
|
||||
|
||||
# Close the opened window and carry on in our original tab.
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
def test_window_handles_after_closing_original_tab(self):
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
with self.marionette.using_context("content"):
|
||||
new_tab = self.open_tab()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertIn(new_tab, self.marionette.window_handles)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
self.assertIn(new_tab, self.marionette.window_handles)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
with self.marionette.using_context("content"):
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda mn: mn.get_url() == self.empty_page,
|
||||
message="{} did not load after opening a new tab".format(self.empty_page))
|
||||
|
||||
def test_window_handles_no_switch(self):
|
||||
"""Regression test for bug 1294456.
|
||||
This test is testing the case where Marionette attempts to send a
|
||||
command to a window handle when the browser has opened and selected
|
||||
a new tab. Before bug 1294456 landed, the Marionette driver was getting
|
||||
confused about which window handle the client cared about, and assumed
|
||||
it was the window handle for the newly opened and selected tab.
|
||||
|
||||
This caused Marionette to think that the browser needed to do a remoteness
|
||||
flip in the e10s case, since the tab opened by menu_newNavigatorTab is
|
||||
about:newtab (which is currently non-remote). This meant that commands
|
||||
sent to what should have been the original window handle would be
|
||||
queued and never sent, since the remoteness flip in the new tab was
|
||||
never going to happen.
|
||||
"""
|
||||
def open_with_menu():
|
||||
menu_new_tab = self.marionette.find_element(By.ID, 'menu_newNavigatorTab')
|
||||
menu_new_tab.click()
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_menu)
|
||||
self.assert_window_handles()
|
||||
|
||||
# We still have the default tab set as our window handle. This
|
||||
# get_url command should be sent immediately, and not be forever-queued.
|
||||
with self.marionette.using_context("content"):
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
def test_window_handles_after_closing_last_window(self):
|
||||
self.close_all_windows()
|
||||
|
|
|
@ -7,7 +7,7 @@ from __future__ import absolute_import
|
|||
import types
|
||||
import urllib
|
||||
|
||||
from marionette_driver import By, errors, Wait
|
||||
from marionette_driver import errors
|
||||
|
||||
from marionette_harness import MarionetteTestCase, skip_if_mobile, WindowManagerMixin
|
||||
|
||||
|
@ -21,9 +21,7 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
def setUp(self):
|
||||
super(TestWindowHandles, self).setUp()
|
||||
|
||||
self.empty_page = self.marionette.absolute_url("empty.html")
|
||||
self.test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
self.marionette.navigate(self.test_page)
|
||||
self.xul_dialog = "chrome://marionette/content/test_dialog.xul"
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_tabs()
|
||||
|
@ -39,12 +37,8 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
for handle in self.marionette.window_handles:
|
||||
self.assertIsInstance(handle, types.StringTypes)
|
||||
|
||||
def test_window_handles_after_opening_new_tab(self):
|
||||
def open_with_link():
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
def tst_window_handles_after_opening_new_tab(self):
|
||||
new_tab = self.open_tab()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
@ -52,13 +46,9 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
|
||||
lambda mn: mn.get_url() == self.empty_page,
|
||||
message="{} did not load after opening a new tab".format(self.empty_page))
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
|
@ -69,29 +59,15 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
def test_window_handles_after_opening_new_browser_window(self):
|
||||
def open_with_link():
|
||||
link = self.marionette.find_element(By.ID, "new-window")
|
||||
link.click()
|
||||
|
||||
# We open a new window but are actually interested in the new tab
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
def tst_window_handles_after_opening_new_browser_window(self):
|
||||
new_tab = self.open_window()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
# Check that the new tab has the correct page loaded
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
Wait(self.marionette, self.marionette.timeout.page_load).until(
|
||||
lambda _: self.marionette.get_url() == self.empty_page,
|
||||
message="The expected page '{}' has not been loaded".format(self.empty_page))
|
||||
|
||||
# Ensure navigate works in our current window
|
||||
other_page = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(other_page)
|
||||
self.assertEqual(self.marionette.get_url(), other_page)
|
||||
|
||||
# Close the opened window and carry on in our original tab.
|
||||
self.marionette.close()
|
||||
|
@ -101,31 +77,16 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertEqual(self.marionette.get_url(), self.test_page)
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_window_handles_after_opening_new_non_browser_window(self):
|
||||
def open_with_link():
|
||||
self.marionette.navigate(inline("""
|
||||
<a id="blob-download" download="foo.html">Download</a>
|
||||
|
||||
<script>
|
||||
const string = "test";
|
||||
const blob = new Blob([string], { type: "text/html" });
|
||||
|
||||
const link = document.getElementById("blob-download");
|
||||
link.href = URL.createObjectURL(blob);
|
||||
</script>
|
||||
"""))
|
||||
link = self.marionette.find_element(By.ID, "blob-download")
|
||||
link.click()
|
||||
|
||||
new_win = self.open_window(trigger=open_with_link)
|
||||
def tst_window_handles_after_opening_new_non_browser_window(self):
|
||||
new_window = self.open_chrome_window(self.xul_dialog)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertNotIn(new_window, self.marionette.window_handles)
|
||||
|
||||
self.marionette.switch_to_window(new_win)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assert_window_handles()
|
||||
|
||||
# Check that the opened window is not accessible via window handles
|
||||
|
@ -144,26 +105,21 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
|
||||
def test_window_handles_after_closing_original_tab(self):
|
||||
def open_with_link():
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
new_tab = self.open_tab(trigger=open_with_link)
|
||||
new_tab = self.open_tab()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
|
||||
self.assertEqual(self.marionette.current_window_handle, self.start_tab)
|
||||
self.assertIn(new_tab, self.marionette.window_handles)
|
||||
|
||||
self.marionette.close()
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
|
||||
self.assertNotIn(self.start_tab, self.marionette.window_handles)
|
||||
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.assert_window_handles()
|
||||
self.assertEqual(self.marionette.current_window_handle, new_tab)
|
||||
Wait(self.marionette, self.marionette.timeout.page_load).until(
|
||||
lambda _: self.marionette.get_url() == self.empty_page,
|
||||
message="The expected page '{}' has not been loaded".format(self.empty_page))
|
||||
|
||||
def test_window_handles_after_closing_last_tab(self):
|
||||
def tst_window_handles_after_closing_last_tab(self):
|
||||
self.close_all_tabs()
|
||||
self.assertEqual(self.marionette.close(), [])
|
||||
|
|
|
@ -21,15 +21,9 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window(self):
|
||||
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
self.marionette.navigate(test_page)
|
||||
self.marionette.find_element(By.ID, "new-window").click()
|
||||
|
||||
win = self.open_window(open_with_link)
|
||||
self.marionette.switch_to_window(win)
|
||||
with self.marionette.using_context("chrome"):
|
||||
new_window = self.open_window()
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
# When closing a browser window both handles are not available
|
||||
|
@ -43,12 +37,12 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window_while_in_frame(self):
|
||||
win = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
self.marionette.switch_to_window(win)
|
||||
new_window = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
self.marionette.switch_to_window(new_window)
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.switch_to_frame("iframe")
|
||||
self.marionette.close_chrome_window()
|
||||
|
@ -61,13 +55,12 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
def test_closed_tab(self):
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.close()
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
|
||||
# Check that only the content window is not available in both contexts
|
||||
for context in ("chrome", "content"):
|
||||
|
@ -79,25 +72,26 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
def test_closed_tab_while_in_frame(self):
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.navigate(self.marionette.absolute_url("test_iframe.html"))
|
||||
frame = self.marionette.find_element(By.ID, "test_iframe")
|
||||
self.marionette.switch_to_frame(frame)
|
||||
self.marionette.close()
|
||||
self.marionette.close()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
|
||||
class TestNoSuchWindowChrome(TestNoSuchWindowContent):
|
||||
|
@ -121,42 +115,22 @@ class TestSwitchWindow(WindowManagerMixin, MarionetteTestCase):
|
|||
self.close_all_windows()
|
||||
super(TestSwitchWindow, self).tearDown()
|
||||
|
||||
def test_windows(self):
|
||||
def open_browser_with_js():
|
||||
self.marionette.execute_script(" window.open(); ")
|
||||
|
||||
new_window = self.open_window(trigger=open_browser_with_js)
|
||||
def test_switch_window_after_open_and_close(self):
|
||||
with self.marionette.using_context("chrome"):
|
||||
new_window = self.open_window()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows) + 1)
|
||||
self.assertIn(new_window, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
# switch to the other window
|
||||
# switch to the new chrome window and close it
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
self.assertNotEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
# switch back and close original window
|
||||
self.marionette.close_chrome_window()
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows))
|
||||
self.assertNotIn(new_window, self.marionette.chrome_window_handles)
|
||||
|
||||
# switch back to the original chrome window
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
self.assertNotIn(self.start_window, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows))
|
||||
|
||||
def test_should_load_and_close_a_window(self):
|
||||
def open_window_with_link():
|
||||
test_html = self.marionette.absolute_url("test_windows.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(test_html)
|
||||
self.marionette.find_element(By.LINK_TEXT, "Open new window").click()
|
||||
|
||||
new_window = self.open_window(trigger=open_window_with_link)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), 2)
|
||||
|
||||
with self.marionette.using_context('content'):
|
||||
self.assertEqual(self.marionette.title, "We Arrive Here")
|
||||
|
||||
# Let's close and check
|
||||
self.marionette.close_chrome_window()
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), 1)
|
||||
|
|
|
@ -15,30 +15,15 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
def setUp(self):
|
||||
super(TestNoSuchWindowContent, self).setUp()
|
||||
|
||||
self.test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(self.test_page)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(TestNoSuchWindowContent, self).tearDown()
|
||||
|
||||
def open_tab_in_foreground(self):
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window(self):
|
||||
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
self.marionette.navigate(test_page)
|
||||
self.marionette.find_element(By.ID, "new-window").click()
|
||||
|
||||
win = self.open_window(open_with_link)
|
||||
self.marionette.switch_to_window(win)
|
||||
with self.marionette.using_context("chrome"):
|
||||
new_window = self.open_window()
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
# When closing a browser window both handles are not available
|
||||
|
@ -52,12 +37,13 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window_while_in_frame(self):
|
||||
win = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
self.marionette.switch_to_window(win)
|
||||
new_window = self.open_chrome_window("chrome://marionette/content/test.xul")
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.switch_to_frame("iframe")
|
||||
self.marionette.close_chrome_window()
|
||||
|
@ -70,13 +56,12 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
|
||||
def test_closed_tab(self):
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab(self.open_tab_in_foreground)
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.close()
|
||||
new_tab = self.open_tab(focus=True)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
self.marionette.close()
|
||||
|
||||
# Check that only the content window is not available in both contexts
|
||||
for context in ("chrome", "content"):
|
||||
|
@ -88,22 +73,24 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
|||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
def test_closed_tab_while_in_frame(self):
|
||||
new_tab = self.open_tab()
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab(self.open_tab_in_foreground)
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.navigate(self.marionette.absolute_url("test_iframe.html"))
|
||||
frame = self.marionette.find_element(By.ID, "test_iframe")
|
||||
self.marionette.switch_to_frame(frame)
|
||||
self.marionette.close()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
self.marionette.close()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.switch_to_window(new_tab)
|
||||
|
|
Загрузка…
Ссылка в новой задаче