Bug 1107336: correct loop imports for marionette; r=jgriffin

--HG--
extra : rebase_source : 81184a8bdee191e4e9592f885b165ac467b65520
extra : source : 9aec81381396931906b3ebe40615618ba80024ed
This commit is contained in:
David Burns 2015-02-10 00:49:24 +00:00
Родитель c240465531
Коммит 22b1c82346
4 изменённых файлов: 77 добавлений и 8 удалений

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

@ -1,12 +1,18 @@
from marionette_test import MarionetteTestCase
from by import By
import urlparse
from errors import NoSuchElementException, StaleElementException
# noinspection PyUnresolvedReferences
from wait import Wait
try:
from by import By
from errors import NoSuchElementException, StaleElementException
# noinspection PyUnresolvedReferences
from wait import Wait
except ImportError:
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException, StaleElementException
# noinspection PyUnresolvedReferences
from marionette_driver import Wait
import os
import sys
import urlparse
sys.path.insert(1, os.path.dirname(os.path.abspath(__file__)))
import pyperclip

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

@ -1,5 +1,5 @@
from marionette_test import MarionetteTestCase
from errors import NoSuchElementException
from marionette_driver.errors import NoSuchElementException
import threading
import SimpleHTTPServer
import SocketServer

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

@ -2,7 +2,6 @@
# 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_test import MarionetteTestCase, skip_if_b2g, skip_if_e10s
from errors import MarionetteException, TimeoutException
class TestNavigate(MarionetteTestCase):

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

@ -2,10 +2,13 @@
# 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 import Keys
from marionette_test import MarionetteTestCase, skip_if_e10s
from marionette_driver.keys import Keys
class TestWindowHandles(MarionetteTestCase):
@skip_if_e10s # Interactions with about: pages need e10s support (bug 1096488).
def test_new_tab_window_handles(self):
keys = [Keys.SHIFT]
if self.marionette.session_capabilities['platformName'] == 'DARWIN':
@ -89,5 +92,66 @@ from marionette import Keys
self.assertEqual(len(self.marionette.window_handles), 1)
self.marionette.switch_to_window(start_tab)
# This sequence triggers an exception in Marionette:register with e10s on (bug 1120809).
@skip_if_e10s
def test_tab_and_window_handles(self):
start_tab = self.marionette.current_window_handle
start_chrome_window = self.marionette.current_chrome_window_handle
tab_open_page = self.marionette.absolute_url("windowHandles.html")
window_open_page = self.marionette.absolute_url("test_windows.html")
# Open a new tab and switch to it.
self.marionette.navigate(tab_open_page)
link = self.marionette.find_element("id", "new-tab")
link.click()
self.wait_for_condition(lambda mn: len(mn.window_handles) == 2)
self.assertEqual(len(self.marionette.chrome_window_handles), 1)
self.assertEqual(self.marionette.current_chrome_window_handle, start_chrome_window)
handles = self.marionette.window_handles
handles.remove(start_tab)
new_tab = handles.pop()
self.marionette.switch_to_window(new_tab)
self.assertEqual(self.marionette.get_url(), "about:blank")
# Open a new window from the new tab.
self.marionette.navigate(window_open_page)
link = self.marionette.find_element("link text", "Open new window")
link.click()
self.wait_for_condition(lambda mn: len(mn.window_handles) == 3)
self.assertEqual(len(self.marionette.chrome_window_handles), 2)
self.assertEqual(self.marionette.current_chrome_window_handle, start_chrome_window)
# Find the new window and switch to it.
handles = self.marionette.window_handles
handles.remove(start_tab)
handles.remove(new_tab)
new_window = handles.pop()
self.marionette.switch_to_window(new_window)
results_page = self.marionette.absolute_url("resultPage.html")
self.assertEqual(self.marionette.get_url(), results_page)
self.assertEqual(len(self.marionette.chrome_window_handles), 2)
self.assertNotEqual(self.marionette.current_chrome_window_handle, start_chrome_window)
# Return to our original tab and close it.
self.marionette.switch_to_window(start_tab)
self.marionette.close()
self.assertEquals(len(self.marionette.window_handles), 2)
# Close the opened window and carry on in our new tab.
self.marionette.switch_to_window(new_window)
self.marionette.close()
self.assertEqual(len(self.marionette.window_handles), 1)
self.marionette.switch_to_window(new_tab)
self.assertEqual(self.marionette.get_url(), results_page)
self.marionette.navigate("about:blank")
self.assertEqual(len(self.marionette.chrome_window_handles), 1)
self.assertEqual(self.marionette.current_chrome_window_handle, start_chrome_window)