Repository navigation
Conversation
The script that shows the spinner while the S2S connection test runs, and the onsubmit attribute that called it, are replaced by a script file that listens for the form being submitted. This helps to allow for stricter CSP settings.
The style element of the S2S connection test page, and the style attributes of its spinner, labels and output boxes, move to a stylesheet of their own. The script that shows the spinner sets its display on the element, which a stricter style-src does not block. This helps to allow for stricter CSP settings.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
guusdk
left a comment
There was a problem hiding this comment.
Thanks for this! I've found some minor improvements. No hills for me to die on.
| const form = document.getElementById('s2s-test-form'); | ||
| const spinner = document.getElementById('spinner'); | ||
| if (form && spinner) { | ||
| form.addEventListener('submit', () => { spinner.style.display = 'inline-block'; }, false); |
There was a problem hiding this comment.
The Test button stays enabled while the test runs. A test that waits on DNS or TLS timeouts can take a while, and with only the spinner to go on, an admin may click Test again and start another test on the server, each one holding a request thread. The old inline handler had the same gap, but this listener is a good place to close it:
form.addEventListener('submit', () => {
spinner.style.display = 'inline-block';
form.querySelector('input[type="submit"]').disabled = true;
}, false);There was a problem hiding this comment.
Done: the listener now cancels any later submission and disables the button.
| 100% { transform: rotate(360deg); } | ||
| } | ||
| </style> | ||
| <script src="js/server-connectiontest.js"></script> |
There was a problem hiding this comment.
The other admin pages that have their own script file (connection-settings-advanced.jsp, connection-settings-socket-s2s.jsp and so on) include it at the end of <body>. Doing the same here keeps them consistent, and it means the script can find the form straight away, without the DOMContentLoaded wrapper.
There was a problem hiding this comment.
Done: it loads at the end of <body>, without the DOMContentLoaded wrapper.
A test that waits on DNS or TLS timeouts can take a while, and an administrator who clicks Test again starts another test, each holding a request thread. The submit listener now cancels any later submission and disables the button. The button is disabled only after the current submission is under way: a button disabled inside the submit handler is left out of the submitted form, and the page runs the test only when its name (s2s-test) is present. The script now loads at the end of the body, so it finds the form without waiting for DOMContentLoaded.
https://igniterealtime.atlassian.net/browse/OF-2999
https://igniterealtime.atlassian.net/browse/OF-3020
The S2S connection test page had an inline
<script>, anonsubmitattribute, an inline<style>andstyleattributes, which a Content-Security-Policy without'unsafe-inline'blocks. They move tojs/server-connectiontest.jsandstyle/server-connectiontest.css, one commit per ticket, so the page has no inline script or style left. The page looks and behaves as before: the spinner shows while the test runs.Split out of #3541 at review, which builds on these two files.