Backed out changeset 51abb63ca246 (bug 1507803) for frequent marionette failures

This commit is contained in:
Noemi Erli 2018-11-18 04:19:09 +02:00
Родитель a685c05ea5
Коммит b8152d4552
19 изменённых файлов: 152 добавлений и 70 удалений

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

@ -117,52 +117,3 @@ class WindowManagerMixin(object):
message="Window with handle '{}'' did not finish loading".format(new_window))
return new_window
def open_chrome_window(self, url):
"""Open a new chrome window with the specified chrome URL.
Can be replaced with "WebDriver:NewWindow" once the command
supports opening generic chrome windows beside browsers (bug 1507771).
"""
def open_with_js():
with self.marionette.using_context("chrome"):
self.marionette.execute_async_script("""
let [url, resolve] = arguments;
function waitForEvent(target, type, args) {
return new Promise(resolve => {
let params = Object.assign({once: true}, args);
target.addEventListener(type, event => {
dump(`** Received DOM event ${event.type} for ${event.target}\n`);
resolve();
}, params);
});
}
function waitForFocus(win) {
return Promise.all([
waitForEvent(win, "activate"),
waitForEvent(win, "focus", {capture: true}),
]);
}
(async function() {
// Open a window, wait for it to receive focus
let win = window.openDialog(url, null, "chrome,centerscreen");
// Bug 1507803 - Missing focus/activate event when tests are
// run in the background.
win.focus();
await waitForFocus(win);
// Now refocus our original window and wait for that to happen.
let focused = waitForFocus(window);
window.focus();
await focused;
resolve();
})();
""", script_args=(url,))
return self.open_window(trigger=open_with_js)

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

@ -17,8 +17,13 @@ class TestAnonymousNodes(WindowManagerMixin, MarionetteTestCase):
super(TestAnonymousNodes, self).setUp()
self.marionette.set_context("chrome")
url = "chrome://marionette/content/test_anonymous_content.xul"
new_window = self.open_chrome_window(url)
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test_anonymous_content.xul',
'foo', 'chrome,centerscreen');
""")
new_window = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(new_window)
def tearDown(self):

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

@ -16,7 +16,13 @@ class TestSelectedChrome(WindowManagerMixin, MarionetteTestCase):
self.marionette.set_context("chrome")
new_window = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'_blank', 'chrome,centerscreen');
""")
new_window = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(new_window)
def tearDown(self):

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

@ -22,7 +22,13 @@ class TestClickChrome(WindowManagerMixin, MarionetteTestCase):
super(TestClickChrome, self).tearDown()
def test_click(self):
win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen'); """)
win = self.open_window(open_with_js)
self.marionette.switch_to_window(win)
def checked():

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

@ -16,7 +16,13 @@ class TestElementState(WindowManagerMixin, MarionetteTestCase):
self.marionette.set_context("chrome")
self.win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
self.win = self.open_window(open_window_with_js)
self.marionette.switch_to_window(self.win)
def tearDown(self):

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

@ -16,7 +16,13 @@ class TestElementSizeChrome(WindowManagerMixin, MarionetteTestCase):
self.marionette.set_context("chrome")
new_window = self.open_chrome_window("chrome://marionette/content/test2.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test2.xul',
'foo', 'chrome,centerscreen');
""")
new_window = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(new_window)
def tearDown(self):

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

@ -375,8 +375,13 @@ class TestExecuteChrome(WindowManagerMixin, TestExecuteContent):
@skip_if_mobile("New windows not supported in Fennec")
def test_unmarshal_element_collection(self):
def open_window_with_js():
self.marionette.execute_script(
"window.open('chrome://marionette/content/test.xul', 'xul', 'chrome');")
try:
win = self.open_chrome_window("chrome://marionette/content/test.xul")
win = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(win)
expected = self.marionette.find_elements(By.TAG_NAME, "textbox")

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

@ -18,7 +18,13 @@ class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
self.marionette.set_context("chrome")
win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(open_window_with_js)
self.marionette.switch_to_window(win)
def tearDown(self):

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

@ -31,7 +31,15 @@ class TestGetCurrentUrlChrome(WindowManagerMixin, MarionetteTestCase):
@skip_if_mobile("Fennec doesn't support other chrome windows")
def test_no_browser_window(self):
win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
with self.marionette.using_context("chrome"):
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(win)
chrome_url = self.marionette.execute_script("return window.location.href;")

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

@ -13,7 +13,13 @@ class TestPageSourceChrome(WindowManagerMixin, MarionetteTestCase):
super(TestPageSourceChrome, self).setUp()
self.marionette.set_context("chrome")
new_window = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
new_window = self.open_window(open_with_js)
self.marionette.switch_to_window(new_window)
def tearDown(self):

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

@ -135,8 +135,22 @@ class TestScreenCaptureChrome(WindowManagerMixin, ScreenCaptureTestCase):
return [rect.width, rect.height];
"""))
def open_dialog(self):
return self.open_chrome_window("chrome://marionette/content/test_dialog.xul")
def open_dialog(self, url=None, width=None, height=None):
if url is None:
url = "chrome://marionette/content/test_dialog.xul"
def opener():
features = "chrome"
if height is not None:
features += ",height={}".format(height)
if width is not None:
features += ",width={}".format(width)
self.marionette.execute_script("""
window.openDialog(arguments[0], "", arguments[1]);
""", script_args=[url, features])
return self.open_window(opener)
def test_capture_different_context(self):
"""Check that screenshots in content and chrome are different."""

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

@ -15,7 +15,13 @@ class TestSwitchFrameChrome(WindowManagerMixin, MarionetteTestCase):
super(TestSwitchFrameChrome, self).setUp()
self.marionette.set_context("chrome")
new_window = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
new_window = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(new_window)
self.assertNotEqual(self.start_window, self.marionette.current_chrome_window_handle)

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

@ -20,7 +20,14 @@ class TestTitleChrome(WindowManagerMixin, MarionetteTestCase):
super(TestTitleChrome, self).tearDown()
def test_get_chrome_title(self):
win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(open_window_with_js)
self.marionette.switch_to_window(win)
title = self.marionette.execute_script(

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

@ -31,7 +31,14 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
self.assertNotIn(win, self.marionette.window_handles)
def test_close_chrome_window_for_non_browser_window(self):
win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(win)
self.assertIn(win, self.marionette.chrome_window_handles)

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

@ -35,7 +35,15 @@ class TestCloseWindow(WindowManagerMixin, MarionetteTestCase):
@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")
def open_window_with_js():
with self.marionette.using_context("chrome"):
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(win)
self.assertIn(win, self.marionette.chrome_window_handles)

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

@ -66,7 +66,13 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
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 open_via_js():
self.marionette.execute_script("""
window.openDialog(arguments[0]);
""", script_args=(xul_dialog,))
new_win = self.open_window(trigger=open_via_js)
self.assert_window_handles()
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows) + 1)
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
@ -167,7 +173,13 @@ class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
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 open_via_js():
self.marionette.execute_script("""
window.openDialog(arguments[0]);
""", script_args=(xul_dialog,))
new_win = self.open_window(trigger=open_via_js)
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)

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

@ -47,7 +47,15 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
@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")
def open_window_with_js():
with self.marionette.using_context("chrome"):
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(win)
with self.marionette.using_context("chrome"):
self.marionette.switch_to_frame("iframe")

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

@ -56,7 +56,15 @@ class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
@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")
def open_window_with_js():
with self.marionette.using_context("chrome"):
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(win)
with self.marionette.using_context("chrome"):
self.marionette.switch_to_frame("iframe")

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

@ -20,7 +20,14 @@ class TestWindowTypeChrome(WindowManagerMixin, MarionetteTestCase):
super(TestWindowTypeChrome, self).tearDown()
def test_get_window_type(self):
win = self.open_chrome_window("chrome://marionette/content/test.xul")
def open_window_with_js():
self.marionette.execute_script("""
window.open('chrome://marionette/content/test.xul',
'foo', 'chrome,centerscreen');
""")
win = self.open_window(open_window_with_js)
self.marionette.switch_to_window(win)
window_type = self.marionette.execute_script(