Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9778ad7130 |
@@ -1403,14 +1403,13 @@ func checkOtherPages(ctx context.Context, t *testing.T, urls ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
// answerPrompt returns a script that stands in for the user at the
|
||||
// browser's prompt: it makes window.confirm record the question in
|
||||
// window.asked and give answer. It also records in window.sent whether
|
||||
// a form is sent once its submit event is handled, from a listener on
|
||||
// window, which the event reaches after the listener static/js/app.js
|
||||
// adds to document.
|
||||
func answerPrompt(answer bool) string {
|
||||
return fmt.Sprintf(`
|
||||
// answerPrompt stands in for the user at the browser's prompt: it makes
|
||||
// window.confirm record the question in window.asked and give answer.
|
||||
// It also records in window.sent whether a form is sent once its submit
|
||||
// event is handled, from a listener on window, which the event reaches
|
||||
// after the listener static/js/app.js adds to document.
|
||||
func answerPrompt(answer bool) chromedp.Action {
|
||||
return chromedp.Evaluate(fmt.Sprintf(`
|
||||
window.asked = "";
|
||||
window.sent = false;
|
||||
window.confirm = (question) => {
|
||||
@@ -1419,7 +1418,7 @@ func answerPrompt(answer bool) string {
|
||||
};
|
||||
window.addEventListener("submit", (event) => {
|
||||
window.sent = !event.defaultPrevented;
|
||||
});`, answer)
|
||||
});`, answer), nil)
|
||||
}
|
||||
|
||||
// checkDeletePrompt loads a webhook page and clicks Delete beside
|
||||
@@ -1442,9 +1441,7 @@ func checkDeletePrompt(
|
||||
listed bool
|
||||
)
|
||||
|
||||
require.NoError(t, chromedp.Run(
|
||||
ctx, loadPage(url), chromedp.Evaluate(answerPrompt(false), nil),
|
||||
))
|
||||
require.NoError(t, chromedp.Run(ctx, loadPage(url), answerPrompt(false)))
|
||||
click(ctx, t, form+" button")
|
||||
require.NoError(t, chromedp.Run(
|
||||
ctx,
|
||||
@@ -1454,9 +1451,7 @@ func checkDeletePrompt(
|
||||
assert.Equal(t, question, asked, "Delete does not ask about the target")
|
||||
assert.False(t, sent, "answering no still sends the delete form")
|
||||
|
||||
require.NoError(t, chromedp.Run(
|
||||
ctx, chromedp.Evaluate(answerPrompt(true), nil),
|
||||
))
|
||||
require.NoError(t, chromedp.Run(ctx, answerPrompt(true)))
|
||||
clickAndLoad(ctx, t, form+" button")
|
||||
require.NoError(t, chromedp.Run(ctx, chromedp.Evaluate(
|
||||
`document.querySelector('`+form+`') !== null`, &listed,
|
||||
|
||||
Reference in New Issue
Block a user