Backed out changeset 3350eb992270 (bug 1487358) for causing the Mn and Wd intermittent/perma failures

This commit is contained in:
Coroiu Cristina 2019-05-28 09:09:10 +03:00
Родитель 12ee428e36
Коммит a92cfdcfdb
3 изменённых файлов: 112 добавлений и 84 удалений

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

@ -3171,7 +3171,7 @@ GeckoDriver.prototype.dismissDialog = async function() {
await dialogClosed;
this.dialog = modal.findModalDialogs(this.curBrowser);
this.dialog = null;
};
/**
@ -3189,7 +3189,7 @@ GeckoDriver.prototype.acceptDialog = async function() {
await dialogClosed;
this.dialog = modal.findModalDialogs(this.curBrowser);
this.dialog = null;
};
/**

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

@ -1,3 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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 __future__ import absolute_import
from marionette_driver.by import By
@ -6,7 +10,7 @@ from marionette_driver import errors
from marionette_driver.marionette import Alert
from marionette_driver.wait import Wait
from marionette_harness import MarionetteTestCase, parameterized, WindowManagerMixin
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class BaseAlertTestCase(WindowManagerMixin, MarionetteTestCase):
@ -23,6 +27,10 @@ class BaseAlertTestCase(WindowManagerMixin, MarionetteTestCase):
Wait(self.marionette, timeout=timeout).until(
lambda _: self.alert_present)
def wait_for_alert_closed(self, timeout=None):
Wait(self.marionette, timeout=timeout).until(
lambda _: not self.alert_present)
class TestTabModalAlerts(BaseAlertTestCase):
@ -35,12 +43,13 @@ class TestTabModalAlerts(BaseAlertTestCase):
self.marionette.navigate(self.test_page)
def tearDown(self):
# Ensure to close all possible remaining tab modal dialogs
# Ensure to close a possible remaining tab modal dialog
try:
while True:
alert = self.marionette.switch_to_alert()
alert.dismiss()
except errors.NoAlertPresentException:
alert = self.marionette.switch_to_alert()
alert.dismiss()
self.wait_for_alert_closed()
except:
pass
super(TestTabModalAlerts, self).tearDown()
@ -51,6 +60,50 @@ class TestTabModalAlerts(BaseAlertTestCase):
with self.assertRaises(errors.NoAlertPresentException):
Alert(self.marionette).dismiss()
def test_alert_accept(self):
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.accept()
def test_alert_dismiss(self):
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.dismiss()
def test_confirm_accept(self):
self.marionette.find_element(By.ID, "tab-modal-confirm").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.accept()
self.wait_for_condition(
lambda mn: mn.find_element(By.ID, "confirm-result").text == "true")
def test_confirm_dismiss(self):
self.marionette.find_element(By.ID, "tab-modal-confirm").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.dismiss()
self.wait_for_condition(
lambda mn: mn.find_element(By.ID, "confirm-result").text == "false")
def test_prompt_accept(self):
self.marionette.find_element(By.ID, "tab-modal-prompt").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.accept()
self.wait_for_condition(
lambda mn: mn.find_element(By.ID, "prompt-result").text == "")
def test_prompt_dismiss(self):
self.marionette.find_element(By.ID, "tab-modal-prompt").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.dismiss()
self.wait_for_condition(
lambda mn: mn.find_element(By.ID, "prompt-result").text == "null")
def test_alert_opened_before_session_starts(self):
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
@ -62,45 +115,40 @@ class TestTabModalAlerts(BaseAlertTestCase):
alert = self.marionette.switch_to_alert()
alert.dismiss()
@parameterized("alert", "alert", "undefined")
@parameterized("confirm", "confirm", "true")
@parameterized("prompt", "prompt", "")
def test_accept(self, value, result):
self.marionette.find_element(By.ID, "tab-modal-{}".format(value)).click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.accept()
self.assertEqual(self.marionette.find_element(By.ID, "text").text, result)
@parameterized("alert", "alert", "undefined")
@parameterized("confirm", "confirm", "false")
@parameterized("prompt", "prompt", "null")
def test_dismiss(self, value, result):
self.marionette.find_element(By.ID, "tab-modal-{}".format(value)).click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.dismiss()
self.assertEqual(self.marionette.find_element(By.ID, "text").text, result)
@parameterized("alert", "alert", "Marionette alert")
@parameterized("confirm", "confirm", "Marionette confirm")
@parameterized("prompt", "prompt", "Marionette prompt")
def test_text(self, value, text):
def test_alert_text(self):
with self.assertRaises(errors.NoAlertPresentException):
alert = self.marionette.switch_to_alert()
alert.text
self.marionette.find_element(By.ID, "tab-modal-{}".format(value)).click()
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
self.assertEqual(alert.text, text)
self.assertEqual(alert.text, "Marionette alert")
alert.accept()
@parameterized("alert", "alert")
@parameterized("confirm", "confirm")
def test_set_text_throws(self, value):
def test_prompt_text(self):
with self.assertRaises(errors.NoAlertPresentException):
alert = self.marionette.switch_to_alert()
alert.text
self.marionette.find_element(By.ID, "tab-modal-prompt").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
self.assertEqual(alert.text, "Marionette prompt")
alert.accept()
def test_confirm_text(self):
with self.assertRaises(errors.NoAlertPresentException):
alert = self.marionette.switch_to_alert()
alert.text
self.marionette.find_element(By.ID, "tab-modal-confirm").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
self.assertEqual(alert.text, "Marionette confirm")
alert.accept()
def test_set_text_throws(self):
with self.assertRaises(errors.NoAlertPresentException):
Alert(self.marionette).send_keys("Foo")
self.marionette.find_element(By.ID, "tab-modal-{}".format(value)).click()
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
with self.assertRaises(errors.ElementNotInteractableException):
@ -111,9 +159,10 @@ class TestTabModalAlerts(BaseAlertTestCase):
self.marionette.find_element(By.ID, "tab-modal-prompt").click()
self.wait_for_alert()
alert = self.marionette.switch_to_alert()
alert.send_keys("Foo bar")
alert.send_keys("Some text!")
alert.accept()
self.assertEqual(self.marionette.find_element(By.ID, "text").text, "Foo bar")
self.wait_for_condition(
lambda mn: mn.find_element(By.ID, "prompt-result").text == "Some text!")
def test_set_text_dismiss(self):
self.marionette.find_element(By.ID, "tab-modal-prompt").click()
@ -121,51 +170,35 @@ class TestTabModalAlerts(BaseAlertTestCase):
alert = self.marionette.switch_to_alert()
alert.send_keys("Some text!")
alert.dismiss()
self.assertEqual(self.marionette.find_element(By.ID, "text").text, "null")
self.wait_for_condition(
lambda mn: mn.find_element(By.ID, "prompt-result").text == "null")
def test_unrelated_command_when_alert_present(self):
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
with self.assertRaises(errors.UnexpectedAlertOpen):
self.marionette.find_element(By.ID, "text")
self.marionette.find_element(By.ID, "click-result")
def test_modal_is_dismissed_after_unexpected_alert(self):
self.marionette.find_element(By.ID, "tab-modal-alert").click()
self.wait_for_alert()
with self.assertRaises(errors.UnexpectedAlertOpen):
self.marionette.find_element(By.ID, "text")
self.marionette.find_element(By.ID, "click-result")
assert not self.alert_present
def test_handle_two_modal_dialogs(self):
self.marionette.find_element(By.ID, "open-two-dialogs").click()
self.wait_for_alert()
alert1 = self.marionette.switch_to_alert()
alert1.send_keys("foo")
alert1.accept()
alert2 = self.marionette.switch_to_alert()
alert2.send_keys("bar")
alert2.accept()
self.assertEqual(self.marionette.find_element(By.ID, "text1").text, "foo")
self.assertEqual(self.marionette.find_element(By.ID, "text2").text, "bar")
class TestModalAlerts(BaseAlertTestCase):
def setUp(self):
super(TestModalAlerts, self).setUp()
self.marionette.set_pref(
"network.auth.non-web-content-triggered-resources-http-auth-allow",
True)
self.marionette.set_pref("network.auth.non-web-content-triggered-resources-http-auth-allow",
True)
def tearDown(self):
# Ensure to close a possible remaining modal dialog
self.close_all_windows()
self.marionette.clear_pref(
"network.auth.non-web-content-triggered-resources-http-auth-allow")
self.marionette.clear_pref("network.auth.non-web-content-triggered-resources-http-auth-allow")
super(TestModalAlerts, self).tearDown()
@ -176,6 +209,8 @@ class TestModalAlerts(BaseAlertTestCase):
alert = self.marionette.switch_to_alert()
alert.dismiss()
self.wait_for_alert_closed()
status = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(
element_present(By.ID, "status")
)
@ -191,3 +226,5 @@ class TestModalAlerts(BaseAlertTestCase):
alert = self.marionette.switch_to_alert()
alert.dismiss()
self.wait_for_alert_closed()

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

@ -7,37 +7,28 @@
<head>
<title>Dialog Test</title>
<script type="text/javascript">
function setInnerText(id, value) {
document.getElementById(id).innerHTML = "<p>" + value + "</p>";
}
function handleAlert () {
setInnerText("text", alert("Marionette alert"));
window.alert('Marionette alert');
}
function handleConfirm () {
setInnerText("text", confirm("Marionette confirm"));
var alertAccepted = window.confirm('Marionette confirm');
document.getElementById('confirm-result').innerHTML = alertAccepted;
}
function handlePrompt () {
setInnerText("text", prompt("Marionette prompt"));
}
function handleTwoDialogs() {
setInnerText("text1", prompt("First"));
setInnerText("text2", prompt("Second"));
var promptText = window.prompt('Marionette prompt');
document.getElementById('prompt-result').innerHTML = promptText === null ? 'null' : promptText;
}
</script>
</head>
<body>
<a href="#" id="tab-modal-alert" onclick="handleAlert()">Open an alert dialog.</a>
<a href="#" id="tab-modal-confirm" onclick="handleConfirm()">Open a confirm dialog.</a>
<a href="#" id="tab-modal-prompt" onclick="handlePrompt()">Open a prompt dialog.</a>
<a href="#" id="open-two-dialogs" onclick="handleTwoDialogs()">Open two prompts.</a>
<a href="#" id="click-handler" onclick="document.getElementById('text').innerHTML='result';">Make text appear.</a>
<div id="text"></div>
<div id="text1"></div>
<div id="text2"></div>
<a href="#" id="tab-modal-alert" onclick="handleAlert()">Open an alert dialog.</a>
<a href="#" id="tab-modal-confirm" onclick="handleConfirm()">Open a confirm dialog.</a>
<a href="#" id="tab-modal-prompt" onclick="handlePrompt()">Open a prompt dialog.</a>
<a href="#" id="click-handler" onclick="document.getElementById('click-result').innerHTML='result';">Make text appear.</a>
<div id="confirm-result"></div>
<div id="prompt-result"></div>
<div id="click-result"></div>
</body>
</html>