Bug 1314891 - create_window_instance() should not fail with UnknownWindowError but create a BaseWindow. r=maja_zf

MozReview-Commit-ID: 8UMSB34OkUD

--HG--
extra : rebase_source : ab4a1d777e9d4f7eadbc06ea003cc7401f9b5cd0
This commit is contained in:
Henrik Skupin 2016-11-03 10:12:10 +01:00
parent 94e5cc5c56
commit 3f766ce36c
2 changed files with 15 additions and 9 deletions

View File

@ -44,7 +44,7 @@ class TestWindows(BaseWindowTestCase):
finally:
BaseWindowTestCase.tearDown(self)
def test_windows(self):
def test_switch_to(self):
url = self.marionette.absolute_url('layout/mozilla.html')
# Open two more windows
@ -87,6 +87,18 @@ class TestWindows(BaseWindowTestCase):
self.assertEqual(len(self.windows.all), 1)
def test_switch_to_unknown_window_type(self):
def open_by_js(_):
with self.marionette.using_context('chrome'):
self.marionette.execute_script("""
window.open('chrome://browser/content/safeMode.xul', '_blank',
'chrome,centerscreen,resizable=no');
""")
win = self.browser.open_window(callback=open_by_js, expected_window_class=BaseWindow)
win.close()
self.browser.switch_to()
class TestBaseWindow(BaseWindowTestCase):

View File

@ -106,12 +106,7 @@ class Windows(BaseLib):
# Retrieve window type to determine the type of chrome window
if handle != self.marionette.current_chrome_window_handle:
self.switch_to(handle)
window_type = Wait(self.marionette).until(
lambda mn: mn.get_window_type(),
message='Cannot get window type for chrome window handle "%s"' % handle
)
window_type = self.marionette.get_window_type()
finally:
# Ensure to switch back to the original window
if handle != current_handle:
@ -120,8 +115,7 @@ class Windows(BaseLib):
if window_type in self.windows_map:
window = self.windows_map[window_type](lambda: self.marionette, handle)
else:
raise errors.UnknownWindowError('Unknown window type "%s" for handle: "%s"' %
(window_type, handle))
window = BaseWindow(lambda: self.marionette, handle)
if expected_class is not None and type(window) is not expected_class:
raise errors.UnexpectedWindowTypeError('Expected window "%s" but got "%s"' %