1 Commits
Author SHA1 Message Date
sneak 9778ad7130 Drop 'unsafe-inline' from the Content-Security-Policy (closes #530)
check / check (push) Canceled after 0s
The delete prompts on the webhook page were inline onsubmit handlers.
Each delete form now carries its question in a data-confirm attribute,
which one submit listener in static/js/app.js asks. The three style
attributes became Tailwind classes, with tailwind.css regenerated, and
the x-cloak rule moved to style.css. The policy now sends
script-src 'self' and style-src 'self'.

The browser test now answers a target's delete prompt no and then yes,
and loads the webhook list, settings and profile pages under the
policy. The README states the policy as sent.

Model: opus-5-5
2026-10-15 09:26:11 +00:00
+10 -15
View File
@@ -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,