bug 1502268: marionette: provide informative messages for unexpected alert open error; r=whimboo

Provides specific error messages informing the user what action
was taken with the user prompt, based on the configuration of the
unhandled prompt handler.

Differential Revision: https://phabricator.services.mozilla.com/D10089

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2018-10-31 00:37:15 +00:00
Родитель 343e0160ee
Коммит 07c0fa4fe6
1 изменённых файлов: 8 добавлений и 3 удалений

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

@ -3229,6 +3229,8 @@ GeckoDriver.prototype._handleUserPrompts = async function() {
return;
}
let {textContent} = this.dialog.ui.infoBody;
let behavior = this.capabilities.get("unhandledPromptBehavior");
switch (behavior) {
case UnhandledPromptBehavior.Accept:
@ -3237,7 +3239,8 @@ GeckoDriver.prototype._handleUserPrompts = async function() {
case UnhandledPromptBehavior.AcceptAndNotify:
await this.acceptDialog();
throw new UnexpectedAlertOpenError();
throw new UnexpectedAlertOpenError(
`Accepted user prompt dialog: ${textContent}`);
case UnhandledPromptBehavior.Dismiss:
await this.dismissDialog();
@ -3245,10 +3248,12 @@ GeckoDriver.prototype._handleUserPrompts = async function() {
case UnhandledPromptBehavior.DismissAndNotify:
await this.dismissDialog();
throw new UnexpectedAlertOpenError();
throw new UnexpectedAlertOpenError(
`Dismissed user prompt dialog: ${textContent}`);
case UnhandledPromptBehavior.Ignore:
throw new UnexpectedAlertOpenError();
throw new UnexpectedAlertOpenError(
"Encountered unhandled user prompt dialog");
default:
throw new TypeError(`Unknown unhandledPromptBehavior "${behavior}"`);