Skip to content

OF-2999, OF-3020: Remove inline script and style from server-connectiontest.jsp - #3566

Open
viv wants to merge 3 commits into
igniterealtime:mainfrom
surevine:OF-2999
Open

viv wants to merge 3 commits into
igniterealtime:mainfrom
surevine:OF-2999

Conversation

@viv

@viv viv commented Nov 12, 2026

Copy link
Copy Markdown
Member

https://igniterealtime.atlassian.net/browse/OF-2999
https://igniterealtime.atlassian.net/browse/OF-3020

The S2S connection test page had an inline <script>, an onsubmit attribute, an inline <style> and style attributes, which a Content-Security-Policy without 'unsafe-inline' blocks. They move to js/server-connectiontest.js and style/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.

viv added 2 commits November 12, 2026 11:47
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.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The connection test page now uses external JavaScript to handle form submissions, prevent duplicate submissions, display a spinner, and disable the submit button. The script also resets submission state when the page returns from the back-forward cache. External CSS defines the spinner animation and styles the labels and output fields. The JSP replaces inline spinner behavior and styling with the external assets and updates its copyright year.

Suggested reviewers: guusdk

Merge Risk: Minimal · up to dbd14

The connection test page keeps its spinner and duplicate-submission protection while moving inline code to external files to support a Content-Security-Policy. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description states the PR moves the inline script, onsubmit attribute, inline style block, and style attributes from the S2S connection test page into js/server-connectiontest.js and style/server-…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description states the PR moves the inline script, onsubmit attribute, inline style block, and style attributes from the S2S connection test page into js/server-connectiontest.js and style/server-connectiontest.css. This matches the raw summary, which shows the same file changes. It also notes the spinner still shows while the test runs, which the JS and CSS changes cover. The description is specific and on-topic.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9db7ed28-8cfc-4de1-aba9-9aa1408a48fa
Commits

Reviewing files that changed from the base of the PR and between 8906654 and dbd1430.

Files selected for processing: 2

  • xmppserver/src/main/webapp/js/server-connectiontest.js
  • xmppserver/src/main/webapp/server-connectiontest.jsp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@guusdk guusdk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: the listener now cancels any later submission and disables the button.

100% { transform: rotate(360deg); }
}
</style>
<script src="js/server-connectiontest.js"></script>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@viv
viv requested a review from guusdk November 13, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants