Skip to content

Commit

Permalink
[JENKINS-70895] skip isSecureContext check in automated tests
Browse files Browse the repository at this point in the history
https://issues.jenkins.io/browse/JENKINS-70895 reports that
`isSecureContext` is not recognized by HTMLUnit in its JavaScript
handling.  That breaks tests for some plugins that use HTMLUnit to test
configuration round trips.

jenkinsci#7665 introduced this change
to notify users running over HTTP connections (insecure) that the copy
button does not work over insecure connections.

https://issues.jenkins.io/browse/JENKINS-21052 was the original motivation
for that informational message to the user.

James Nord tested this change in the automated test that was failing
with Jenkins 2.397 and confirmed that the test passes with this change.

I tested interactively over HTTP and confirmed that the copy button on
the inbound agent page still reports that copy is not supported over an
insecure session.

I tested interactively over HTTPS and confirmed that the copy button on
the inbound agent page still correctly copies the expected content.

I spent several unsuccessful hours trying to create an automated test
to show the failure.  I think we should include this fix without an
automated test because the automated tests in the plugin that James
maintains will detect the issue.
  • Loading branch information
MarkEWaite committed Mar 30, 2023
1 parent 48733a5 commit 7d0392e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/resources/lib/layout/copyButton/copyButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Behaviour.specify(
0,
function (copyButton) {
copyButton.addEventListener("click", () => {
if (isSecureContext) {
// HTMLUnit 2.70.0 does not recognize isSecureContext
// https://issues.jenkins.io/browse/JENKINS-70895
if (!window.isRunAsTest && isSecureContext) {
// Make an invisible textarea element containing the text
const fakeInput = document.createElement("textarea");
fakeInput.value = copyButton.getAttribute("text");
Expand Down

0 comments on commit 7d0392e

Please sign in to comment.