Bug 1259055 - Update Marionette unit tests to use correct handles for chrome windows. r=maja_zf

MozReview-Commit-ID: 5q8Vt8M6PK3

--HG--
extra : rebase_source : 768bd768899ea89b4a80308d43bc0e1c7773b576
This commit is contained in:
Henrik Skupin 2016-10-19 10:45:23 +02:00
Родитель cfe379f3ba
Коммит 1d0f7ed303
10 изменённых файлов: 66 добавлений и 67 удалений

Просмотреть файл

@ -15,14 +15,14 @@ class TestAnonymousContent(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.win = self.marionette.current_chrome_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test_anonymous_content.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
self.marionette.close_chrome_window()
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)

Просмотреть файл

@ -10,16 +10,16 @@ class TestSelectedChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.win = self.marionette.current_chrome_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', '_blank', 'chrome,centerscreen');")
def tearDown(self):
self.marionette.execute_script("window.close();")
self.marionette.close_chrome_window()
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_selected(self):
wins = self.marionette.window_handles
wins = self.marionette.chrome_window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)

Просмотреть файл

@ -10,20 +10,20 @@ class TestElementSizeChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.win = self.marionette.current_chrome_window_handle
self.marionette.execute_script(
"window.open('chrome://marionette/content/test2.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
self.marionette.close_chrome_window()
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def testShouldReturnTheSizeOfAnInput(self):
wins = self.marionette.window_handles
wins = self.marionette.chrome_window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)

Просмотреть файл

@ -106,16 +106,16 @@ class TestImportScriptContent(MarionetteTestCase):
def test_imports_apply_globally(self):
self.marionette.navigate(
self.marionette.absolute_url("test_windows.html"))
original_window = self.marionette.current_window_handle
original_window = self.marionette.current_chrome_window_handle
self.marionette.find_element(By.LINK_TEXT, "Open new window").click()
windows = set(self.marionette.window_handles)
windows = set(self.marionette.chrome_window_handles)
print "windows={}".format(windows)
new_window = windows.difference([original_window]).pop()
self.marionette.switch_to_window(new_window)
self.marionette.import_script(self.script_file)
self.marionette.close()
self.marionette.close_chrome_window()
print "switching to original window: {}".format(original_window)
self.marionette.switch_to_window(original_window)

Просмотреть файл

@ -80,11 +80,11 @@ class TestKeyActions(MarionetteTestCase):
.key_up(Keys.SHIFT)
.perform())
self.wait_for_condition(
lambda mn: len(self.marionette.window_handles) == 2)
lambda mn: len(self.marionette.chrome_window_handles) == 2)
chrome_window_handles = self.marionette.chrome_window_handles
chrome_window_handles.remove(start_win)
[new_win] = chrome_window_handles
self.marionette.switch_to_window(new_win)
self.marionette.close()
self.marionette.close_chrome_window()
self.marionette.switch_to_window(start_win)
self.assertEqual(self.key_reporter_value, "")

Просмотреть файл

@ -9,19 +9,19 @@ class TestPageSourceChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.win = self.marionette.current_chrome_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
self.marionette.close_chrome_window()
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def testShouldReturnXULDetails(self):
wins = self.marionette.window_handles
wins = self.marionette.chrome_window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)

Просмотреть файл

@ -11,19 +11,19 @@ class TestTextChrome(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
self.marionette.set_context("chrome")
self.win = self.marionette.current_window_handle
self.win = self.marionette.current_chrome_window_handle
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
self.marionette.switch_to_window('foo')
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
def tearDown(self):
self.assertNotEqual(self.win, self.marionette.current_window_handle)
self.marionette.execute_script("window.close();")
self.assertNotEqual(self.win, self.marionette.current_chrome_window_handle)
self.marionette.close_chrome_window()
self.marionette.switch_to_window(self.win)
MarionetteTestCase.tearDown(self)
def test_getText(self):
wins = self.marionette.window_handles
wins = self.marionette.chrome_window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
@ -31,7 +31,7 @@ class TestTextChrome(MarionetteTestCase):
self.assertEqual("test", box.text)
def test_clearText(self):
wins = self.marionette.window_handles
wins = self.marionette.chrome_window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)
@ -41,7 +41,7 @@ class TestTextChrome(MarionetteTestCase):
self.assertEqual("", box.text)
def test_sendKeys(self):
wins = self.marionette.window_handles
wins = self.marionette.chrome_window_handles
wins.remove(self.win)
newWin = wins.pop()
self.marionette.switch_to_window(newWin)

Просмотреть файл

@ -95,31 +95,30 @@ class TestWindowHandles(MarionetteTestCase):
self.marionette.navigate(opener_page)
# Window handles don't persist in cases of remoteness change.
start_tab = self.marionette.current_window_handle
start_win = self.marionette.current_chrome_window_handle
self.marionette.find_element(By.ID, "new-window").click()
self.assertEqual(len(self.marionette.window_handles), 2)
self.assertEqual(len(self.marionette.chrome_window_handles), 2)
windows = self.marionette.window_handles
windows.remove(start_tab)
dest_tab = windows.pop()
self.marionette.switch_to_window(dest_tab)
self.assertEqual(len(self.marionette.window_handles), 2)
windows = self.marionette.chrome_window_handles
windows.remove(start_win)
dest_win = windows.pop()
self.marionette.switch_to_window(dest_win)
self.marionette.navigate(opener_page)
new_tab_link = self.marionette.find_element(By.ID, "new-tab")
for i in range(3):
new_tab_link.click()
self.marionette.switch_to_window(dest_tab)
self.marionette.switch_to_window(dest_win)
self.wait_for_condition(lambda mn: len(mn.window_handles) == i + 3)
self.assertEqual(len(self.marionette.chrome_window_handles), 2)
self.marionette.close_chrome_window()
self.assertEqual(len(self.marionette.chrome_window_handles), 1)
self.assertEqual(len(self.marionette.window_handles), 1)
self.marionette.switch_to_window(start_tab)
self.marionette.switch_to_window(start_win)
def test_chrome_window_handles_with_scopes(self):
start_tab = self.marionette.current_window_handle

Просмотреть файл

@ -34,17 +34,17 @@ if (win != null)
self.marionette.set_context("content")
def test_windows(self):
orig_win = self.marionette.current_window_handle
orig_available = self.marionette.window_handles
orig_win = self.marionette.current_chrome_window_handle
orig_available = self.marionette.chrome_window_handles
self.open_new_window()
# assert we're still in the original window
self.assertEqual(self.marionette.current_window_handle, orig_win)
self.assertEqual(self.marionette.current_chrome_window_handle, orig_win)
# assert we can find the new window
Wait(self.marionette).until(
lambda _: len(self.marionette.window_handles) == len(orig_available) + 1,
lambda _: len(self.marionette.chrome_window_handles) == len(orig_available) + 1,
message="The new window has not been opened.")
# assert that our window is there
now_available = self.marionette.window_handles
now_available = self.marionette.chrome_window_handles
self.assertIn(orig_win, now_available)
new_win = None
for win in now_available:
@ -52,25 +52,25 @@ if (win != null)
new_win = win
# switch to another window
self.marionette.switch_to_window(new_win)
self.assertEqual(self.marionette.current_window_handle, new_win)
self.assertNotEqual(self.marionette.current_window_handle, orig_win)
self.assertEqual(self.marionette.current_chrome_window_handle, new_win)
self.assertNotEqual(self.marionette.current_chrome_window_handle, orig_win)
# switch back
self.marionette.switch_to_window(orig_win)
self.assertEqual(self.marionette.current_window_handle, orig_win)
self.assertEqual(self.marionette.current_chrome_window_handle, orig_win)
self.close_new_window()
self.assertNotIn(new_win, self.marionette.window_handles)
self.assertEqual(self.marionette.current_window_handle, orig_win)
self.assertEqual(len(self.marionette.window_handles), len(orig_available))
self.assertNotIn(new_win, self.marionette.chrome_window_handles)
self.assertEqual(self.marionette.current_chrome_window_handle, orig_win)
self.assertEqual(len(self.marionette.chrome_window_handles), len(orig_available))
def testShouldLoadAWindowAndThenCloseIt(self):
test_html = self.marionette.absolute_url("test_windows.html")
self.marionette.navigate(test_html)
current = self.marionette.current_window_handle
current = self.marionette.current_chrome_window_handle
self.marionette.find_element(By.LINK_TEXT, "Open new window").click()
count = 0
while True:
window_handles = self.marionette.window_handles
window_handles = self.marionette.chrome_window_handles
window_handles.remove(current)
if len(window_handles) > 0:
break
@ -83,30 +83,30 @@ if (win != null)
self.marionette.switch_to_window(window_handles[0])
self.assertEqual(self.marionette.title, "We Arrive Here")
handle = self.marionette.current_window_handle
handle = self.marionette.current_chrome_window_handle
self.assertEqual(self.marionette.current_window_handle, handle)
self.assertEqual(2, len(self.marionette.window_handles))
self.assertEqual(self.marionette.current_chrome_window_handle, handle)
self.assertEqual(2, len(self.marionette.chrome_window_handles))
# Let's close and check
self.marionette.close()
self.marionette.close_chrome_window()
self.marionette.switch_to_window(current)
self.assertEqual(1, len(self.marionette.window_handles))
self.assertEqual(1, len(self.marionette.chrome_window_handles))
def testShouldCauseAWindowToLoadAndCheckItIsOpenThenCloseIt(self):
test_html = self.marionette.absolute_url("test_windows.html")
self.marionette.navigate(test_html)
current = self.marionette.current_window_handle
current = self.marionette.current_chrome_window_handle
self.marionette.find_element(By.LINK_TEXT,"Open new window").click()
all_handles = self.marionette.window_handles
all_handles = self.marionette.chrome_window_handles
self.assertEqual(2, len(all_handles))
self.marionette.switch_to_window([x for x in all_handles if x != current][0])
# Let's close and check
self.marionette.close()
self.marionette.close_chrome_window()
self.marionette.switch_to_window(current)
self.assertEqual(1, len(self.marionette.window_handles))
self.assertEqual(1, len(self.marionette.chrome_window_handles))
def tearDown(self):
#ensure that we close the window, regardless of pass/failure

Просмотреть файл

@ -14,11 +14,11 @@ class TestWindowSwitching(MarionetteTestCase):
test_html = self.marionette.absolute_url("test_windows.html")
self.marionette.navigate(test_html)
self.current_window = self.marionette.current_window_handle
self.current_window = self.marionette.current_chrome_window_handle
link = self.marionette.find_element(By.LINK_TEXT, "Open new window")
link.click()
windows = self.marionette.window_handles
windows = self.marionette.chrome_window_handles
windows.remove(self.current_window)
self.marionette.switch_to_window(windows[0])
@ -30,20 +30,20 @@ class TestWindowSwitching(MarionetteTestCase):
#ensure navigate works in our current window
other_page = self.marionette.absolute_url("test.html")
self.marionette.navigate(other_page)
other_window = self.marionette.current_window_handle
other_window = self.marionette.current_chrome_window_handle
#try to access its dom
#since Bug 720714 stops us from checking DOMContentLoaded, we wait a bit
Wait(self.marionette, timeout=30, ignored_exceptions=NoSuchElementException).until(
lambda m: m.find_element(By.ID, 'mozLink'))
self.assertEqual(other_window, self.marionette.current_window_handle)
self.assertEqual(other_window, self.marionette.current_chrome_window_handle)
self.marionette.switch_to_window(self.current_window)
self.assertEqual(self.current_window, self.marionette.current_window_handle)
self.assertEqual(self.current_window, self.marionette.current_chrome_window_handle)
def tearDown(self):
window_handles = self.marionette.window_handles
window_handles = self.marionette.chrome_window_handles
window_handles.remove(self.current_window)
for handle in window_handles:
self.marionette.switch_to_window(handle)
self.marionette.close()
self.marionette.close_chrome_window()